make brighter in games was to dim

This commit is contained in:
izzy2lost
2025-08-22 08:04:47 -04:00
parent ecf84f3f47
commit ec7ac6cb7e
5 changed files with 175 additions and 12 deletions
+6 -1
View File
@@ -12,4 +12,9 @@ local.properties
app/build/
# NDK
app/.cxx/
app/.cxx/
# IDE
.vscode/
.idea/
*.iml
+47
View File
@@ -488,6 +488,53 @@ Java_com_izzy2lost_psx2_NativeApp_setAsyncTextureLoading(JNIEnv *env, jclass cla
}
}
extern "C"
JNIEXPORT void JNICALL
Java_com_izzy2lost_psx2_NativeApp_setShadeBoost(JNIEnv *env, jclass clazz,
jboolean p_enabled) {
s_settings_interface.SetBoolValue("EmuCore/GS", "ShadeBoost", p_enabled);
if (VMManager::HasValidVM()) {
VMManager::ApplySettings();
}
}
extern "C"
JNIEXPORT void JNICALL
Java_com_izzy2lost_psx2_NativeApp_setShadeBoostBrightness(JNIEnv *env, jclass clazz,
jint p_brightness) {
int brightness = std::max(1, std::min(100, (int)p_brightness));
s_settings_interface.SetIntValue("EmuCore/GS", "ShadeBoost_Brightness", brightness);
if (VMManager::HasValidVM()) {
VMManager::ApplySettings();
}
}
extern "C"
JNIEXPORT void JNICALL
Java_com_izzy2lost_psx2_NativeApp_setShadeBoostContrast(JNIEnv *env, jclass clazz,
jint p_contrast) {
int contrast = std::max(1, std::min(100, (int)p_contrast));
s_settings_interface.SetIntValue("EmuCore/GS", "ShadeBoost_Contrast", contrast);
if (VMManager::HasValidVM()) {
VMManager::ApplySettings();
}
}
extern "C"
JNIEXPORT void JNICALL
Java_com_izzy2lost_psx2_NativeApp_setShadeBoostSaturation(JNIEnv *env, jclass clazz,
jint p_saturation) {
int saturation = std::max(1, std::min(100, (int)p_saturation));
s_settings_interface.SetIntValue("EmuCore/GS", "ShadeBoost_Saturation", saturation);
if (VMManager::HasValidVM()) {
VMManager::ApplySettings();
}
}
extern "C"
JNIEXPORT void JNICALL
Java_com_izzy2lost_psx2_NativeApp_saveGameSettings(JNIEnv *env, jclass clazz, jstring p_filename,
@@ -345,8 +345,8 @@ public class MainActivity extends AppCompatActivity implements GamesCoverDialogF
// Improve button outline contrast across all MaterialButtons
tintAllMaterialButtonOutlines();
// Apply saved graphics settings (renderer, scaling, aspect)
applySavedSettings();
// Settings are already applied in Initialize() -> loadAndApplySettings()
// No need to call applySavedSettings() again here
// Apply orientation-specific constraints once at startup
int currentOrientation = getResources().getConfiguration().orientation;
@@ -464,19 +464,60 @@ public class MainActivity extends AppCompatActivity implements GamesCoverDialogF
MaterialButton btn_ogl = findViewById(R.id.btn_ogl);
if(btn_ogl != null) {
btn_ogl.setOnClickListener(v -> {
NativeApp.renderGpu(12);
// Save setting first with commit() to ensure immediate write
getSharedPreferences("app_prefs", MODE_PRIVATE).edit().putInt("renderer", 12).commit();
// Small delay to ensure setting is persisted
try {
Thread.sleep(100);
} catch (InterruptedException ignored) {}
try {
NativeApp.renderGpu(12);
} catch (Exception e) {
// Setting saved for next restart
}
});
}
MaterialButton btn_vulkan = findViewById(R.id.btn_vulkan);
if(btn_vulkan != null) {
btn_vulkan.setOnClickListener(v -> {
NativeApp.renderGpu(14);
// Save setting first with commit() to ensure immediate write
getSharedPreferences("app_prefs", MODE_PRIVATE).edit().putInt("renderer", 14).commit();
// Small delay to ensure setting is persisted
try {
Thread.sleep(100);
} catch (InterruptedException ignored) {}
try {
NativeApp.renderGpu(14);
} catch (Exception e) {
// Setting saved for next restart
}
});
}
MaterialButton btn_sw = findViewById(R.id.btn_sw);
if(btn_sw != null) {
btn_sw.setOnClickListener(v -> {
NativeApp.renderGpu(13);
android.util.Log.d("MainActivity", "SW button clicked - saving renderer 13");
// Save setting first with commit() to ensure immediate write
getSharedPreferences("app_prefs", MODE_PRIVATE).edit().putInt("renderer", 13).commit();
android.util.Log.d("MainActivity", "SW renderer setting saved");
// Small delay to ensure setting is persisted
try {
Thread.sleep(100);
} catch (InterruptedException ignored) {}
try {
NativeApp.renderGpu(13);
android.util.Log.d("MainActivity", "Applied SW renderer (13)");
} catch (Exception e) {
android.util.Log.e("MainActivity", "Failed to apply SW renderer: " + e.getMessage());
// Setting saved for next restart
}
});
}
@@ -855,8 +896,12 @@ public class MainActivity extends AppCompatActivity implements GamesCoverDialogF
private void applySavedSettings() {
SharedPreferences prefs = getSharedPreferences("app_prefs", MODE_PRIVATE);
// Renderer: 12=OpenGL, 13=Software, 14=Vulkan
int renderer = prefs.getInt("renderer", 14);
// Renderer constants (match SettingsDialogFragment)
final int RENDERER_OPENGL = 12;
final int RENDERER_SOFTWARE = 13;
final int RENDERER_VULKAN = 14;
int renderer = prefs.getInt("renderer", RENDERER_VULKAN);
NativeApp.renderGpu(renderer);
// Resolution scale multiplier (float), default 1.0
@@ -875,9 +920,22 @@ public class MainActivity extends AppCompatActivity implements GamesCoverDialogF
boolean noInterlacingPatches = prefs.getBoolean("no_interlacing_patches", false);
NativeApp.setNoInterlacingPatches(noInterlacingPatches);
// Texture loading options
boolean loadTextures = prefs.getBoolean("load_textures", false);
NativeApp.setLoadTextures(loadTextures);
boolean asyncTextureLoading = prefs.getBoolean("async_texture_loading", true);
NativeApp.setAsyncTextureLoading(asyncTextureLoading);
// HUD visibility
boolean hudVisible = prefs.getBoolean("hud_visible", false);
NativeApp.setHudVisible(hudVisible);
// Set brighter default brightness (60 instead of 50)
NativeApp.setShadeBoost(true);
NativeApp.setShadeBoostBrightness(60);
NativeApp.setShadeBoostContrast(50);
NativeApp.setShadeBoostSaturation(50);
}
public final ActivityResultLauncher<Intent> startActivityResultLocalFilePlay = registerForActivityResult(
@@ -1103,6 +1161,14 @@ public class MainActivity extends AppCompatActivity implements GamesCoverDialogF
SettingsDialogFragment.loadAndApplySettings(this);
mHIDDeviceManager = HIDDeviceManager.acquire(this);
// Apply renderer setting again after a delay to override any automatic detection
new android.os.Handler(android.os.Looper.getMainLooper()).postDelayed(() -> {
SharedPreferences prefs = getSharedPreferences("app_prefs", MODE_PRIVATE);
int renderer = prefs.getInt("renderer", 14); // Default to Vulkan if no setting
android.util.Log.d("MainActivity", "Re-applying renderer setting after delay: " + renderer);
NativeApp.renderGpu(renderer);
}, 1000); // 1 second delay
}
private void setSurfaceView(Object p_value) {
@@ -1134,6 +1200,13 @@ public class MainActivity extends AppCompatActivity implements GamesCoverDialogF
}
catch (InterruptedException ignored) {}
}
// Apply global renderer setting before starting new game
SharedPreferences prefs = getSharedPreferences("app_prefs", MODE_PRIVATE);
int renderer = prefs.getInt("renderer", 14); // Default to Vulkan if no setting
android.util.Log.d("MainActivity", "Applying global renderer before game restart: " + renderer);
NativeApp.renderGpu(renderer);
////
startEmuThread();
}
@@ -69,6 +69,12 @@ public class NativeApp {
public static native void setLoadTextures(boolean enabled);
public static native void setAsyncTextureLoading(boolean enabled);
public static native void setBlendingAccuracy(int level);
// Shade Boost (brightness/contrast/saturation)
public static native void setShadeBoost(boolean enabled);
public static native void setShadeBoostBrightness(int brightness);
public static native void setShadeBoostContrast(int contrast);
public static native void setShadeBoostSaturation(int saturation);
// Per-game settings
public static native void saveGameSettings(String filename, int blendingAccuracy, int renderer,
@@ -41,8 +41,13 @@ public class SettingsDialogFragment extends DialogFragment {
boolean asyncTextureLoading = prefs.getBoolean("async_texture_loading", true);
boolean hudVisible = prefs.getBoolean("hud_visible", false);
// Debug logging
android.util.Log.d("SettingsDialog", "Loading renderer setting: " + renderer +
" (12=OpenGL, 13=Software, 14=Vulkan)");
// Apply all settings
NativeApp.renderGpu(renderer);
android.util.Log.d("SettingsDialog", "Applied renderer: " + renderer);
NativeApp.renderUpscalemultiplier(scale);
NativeApp.setAspectRatio(aspectRatio);
NativeApp.setWidescreenPatches(widescreenPatches);
@@ -50,6 +55,12 @@ public class SettingsDialogFragment extends DialogFragment {
NativeApp.setLoadTextures(loadTextures);
NativeApp.setAsyncTextureLoading(asyncTextureLoading);
NativeApp.setHudVisible(hudVisible);
// Set brighter default brightness (60 instead of 50)
NativeApp.setShadeBoost(true);
NativeApp.setShadeBoostBrightness(60);
NativeApp.setShadeBoostContrast(50);
NativeApp.setShadeBoostSaturation(50);
}
@NonNull
@@ -223,9 +234,31 @@ public class SettingsDialogFragment extends DialogFragment {
boolean asyncTextureLoading = swAsyncTextureLoading.isChecked();
boolean hudVisible = (swDevHud != null && swDevHud.isChecked());
// Persist
// Debug logging
android.util.Log.d("SettingsDialog", "Saving renderer setting: " + renderer +
" (12=OpenGL, 13=Software, 14=Vulkan)");
// Save renderer setting first with commit() to ensure immediate write
prefs.edit().putInt("renderer", renderer).commit();
android.util.Log.d("SettingsDialog", "Renderer setting saved successfully");
// Small delay to ensure setting is persisted
try {
Thread.sleep(100);
} catch (InterruptedException ignored) {}
// Apply renderer change (might crash, but setting is already saved)
try {
NativeApp.renderGpu(renderer);
android.util.Log.d("SettingsDialog", "Applied renderer change to: " + renderer);
} catch (Exception e) {
android.util.Log.e("SettingsDialog", "Failed to apply renderer: " + e.getMessage());
// If renderer change fails, we'll still have the setting saved
// for next app restart
}
// Persist all other settings
prefs.edit()
.putInt("renderer", renderer)
.putFloat("upscale_multiplier", scale)
.putInt("aspect_ratio", aspectRatio)
.putBoolean("widescreen_patches", widescreenPatches)
@@ -235,8 +268,7 @@ public class SettingsDialogFragment extends DialogFragment {
.putBoolean("hud_visible", hudVisible)
.apply();
// Apply immediately
NativeApp.renderGpu(renderer);
// Apply other settings
NativeApp.renderUpscalemultiplier(scale);
NativeApp.setAspectRatio(aspectRatio);
NativeApp.setWidescreenPatches(widescreenPatches);