From e1f830c7f7c3b734f7666f76192f39262cdc6613 Mon Sep 17 00:00:00 2001 From: Ishan09811 <156402647+Ishan09811@users.noreply.github.com> Date: Sun, 1 Dec 2024 00:55:58 +0530 Subject: [PATCH] Android: Implement enable audio option (#652) * AlberDriver: add static void to enable audio * implement enable audio option * Typo --- .../java/com/panda3ds/pandroid/AlberDriver.java | 1 + .../app/preferences/AdvancedPreferences.java | 2 ++ .../pandroid/data/config/GlobalConfig.java | 1 + .../panda3ds/pandroid/view/PandaGlRenderer.java | 1 + src/pandroid/app/src/main/res/values/strings.xml | 3 +++ .../app/src/main/res/xml/advanced_preferences.xml | 14 +++++++++++++- 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/AlberDriver.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/AlberDriver.java index bb3945b5f..83392b0ae 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/AlberDriver.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/AlberDriver.java @@ -34,6 +34,7 @@ public class AlberDriver { public static native void setShaderJitEnabled(boolean enable); public static native void setAccurateShaderMulEnable(boolean enable); + public static native void setAudioEnabled(boolean enable); public static int openDocument(String path, String mode) { try { diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/preferences/AdvancedPreferences.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/preferences/AdvancedPreferences.java index 8d04403ec..13c579ddb 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/preferences/AdvancedPreferences.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/preferences/AdvancedPreferences.java @@ -23,6 +23,7 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable S setItemClick("performanceMonitor", pref -> GlobalConfig.set(GlobalConfig.KEY_SHOW_PERFORMANCE_OVERLAY, ((SwitchPreferenceCompat) pref).isChecked())); setItemClick("shaderJit", pref -> GlobalConfig.set(GlobalConfig.KEY_SHADER_JIT, ((SwitchPreferenceCompat) pref).isChecked())); setItemClick("accurateShaderMul", pref -> GlobalConfig.set(GlobalConfig.KEY_ACCURATE_SHADER_MULTIPLY, ((SwitchPreferenceCompat) pref).isChecked())); + setItemClick("enableAudio", pref -> GlobalConfig.set(GlobalConfig.KEY_ENABLE_AUDIO, ((SwitchPreferenceCompat) pref).isChecked())); setItemClick("loggerService", pref -> { boolean checked = ((SwitchPreferenceCompat) pref).isChecked(); Context ctx = PandroidApplication.getAppContext(); @@ -48,5 +49,6 @@ private void refresh() { ((SwitchPreferenceCompat) findPreference("loggerService")).setChecked(GlobalConfig.get(GlobalConfig.KEY_LOGGER_SERVICE)); ((SwitchPreferenceCompat) findPreference("shaderJit")).setChecked(GlobalConfig.get(GlobalConfig.KEY_SHADER_JIT)); ((SwitchPreferenceCompat) findPreference("accurateShaderMul")).setChecked(GlobalConfig.get(GlobalConfig.KEY_ACCURATE_SHADER_MULTIPLY)); + ((SwitchPreferenceCompat) findPreference("enableAudio")).setChecked(GlobalConfig.get(GlobalConfig.KEY_ENABLE_AUDIO)); } } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/data/config/GlobalConfig.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/data/config/GlobalConfig.java index c8750f88e..e9e32aed8 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/data/config/GlobalConfig.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/data/config/GlobalConfig.java @@ -23,6 +23,7 @@ public class GlobalConfig { public static final Key KEY_SHADER_JIT = new Key<>("emu.shader_jit", true); public static final Key KEY_ACCURATE_SHADER_MULTIPLY = new Key<>("emu.accurate_shader_mul", false); + public static final Key KEY_ENABLE_AUDIO = new Key<>("emu.enable_audio", true); public static final Key KEY_PICTURE_IN_PICTURE = new Key<>("app.behavior.pictureInPicture", false); public static final Key KEY_SHOW_PERFORMANCE_OVERLAY = new Key<>("dev.performanceOverlay", false); public static final Key KEY_LOGGER_SERVICE = new Key<>("dev.loggerService", false); diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java index 3fb435b4c..dfdad225d 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java @@ -94,6 +94,7 @@ public void onSurfaceCreated(GL10 unused, EGLConfig config) { AlberDriver.Initialize(); AlberDriver.setShaderJitEnabled(GlobalConfig.get(GlobalConfig.KEY_SHADER_JIT)); AlberDriver.setAccurateShaderMulEnable(GlobalConfig.get(GlobalConfig.KEY_ACCURATE_SHADER_MULTIPLY)); + AlberDriver.setAudioEnabled(GlobalConfig.get(GlobalConfig.KEY_ENABLE_AUDIO)); // If loading the ROM failed, display an error message and early exit if (!AlberDriver.LoadRom(romPath)) { diff --git a/src/pandroid/app/src/main/res/values/strings.xml b/src/pandroid/app/src/main/res/values/strings.xml index 63a6c2465..b0479ade7 100644 --- a/src/pandroid/app/src/main/res/values/strings.xml +++ b/src/pandroid/app/src/main/res/values/strings.xml @@ -59,6 +59,9 @@ Graphics Shader JIT Use shader recompiler. + Audio + Enable Audio + Audio will be enabled Tools Logger Store application logs to file. diff --git a/src/pandroid/app/src/main/res/xml/advanced_preferences.xml b/src/pandroid/app/src/main/res/xml/advanced_preferences.xml index 9ef81dbfd..0f0259949 100644 --- a/src/pandroid/app/src/main/res/xml/advanced_preferences.xml +++ b/src/pandroid/app/src/main/res/xml/advanced_preferences.xml @@ -35,4 +35,16 @@ app:iconSpaceReserved="false"/> - \ No newline at end of file + + + + + + +