From 33d1a7360aeff4ea25a7675e15afa7da33ce2fc7 Mon Sep 17 00:00:00 2001 From: Gamer64 <76565986+Gamer64ytb@users.noreply.github.com> Date: Sun, 22 Sep 2024 20:55:38 +0200 Subject: [PATCH] android: add a listener for custom cpu ticks toggle --- .../features/settings/model/BooleanSetting.kt | 1 + .../features/settings/model/IntSetting.kt | 1 - .../settings/ui/SettingsFragmentPresenter.kt | 51 +++++++++++++------ src/common/settings.cpp | 4 +- src/common/settings.h | 2 +- 5 files changed, 41 insertions(+), 18 deletions(-) diff --git a/src/android/app/src/main/java/io/github/mandarine3ds/mandarine/features/settings/model/BooleanSetting.kt b/src/android/app/src/main/java/io/github/mandarine3ds/mandarine/features/settings/model/BooleanSetting.kt index 54c0eaaad..9dd20fc43 100644 --- a/src/android/app/src/main/java/io/github/mandarine3ds/mandarine/features/settings/model/BooleanSetting.kt +++ b/src/android/app/src/main/java/io/github/mandarine3ds/mandarine/features/settings/model/BooleanSetting.kt @@ -10,6 +10,7 @@ enum class BooleanSetting( override val defaultValue: Boolean ) : AbstractBooleanSetting { EXPAND_TO_CUTOUT_AREA("expand_to_cutout_area", Settings.SECTION_LAYOUT, false), + CUSTOM_CPU_TICKS("custom_cpu_ticks", Settings.SECTION_CORE, false), SPIRV_SHADER_GEN("spirv_shader_gen", Settings.SECTION_RENDERER, true), ASYNC_SHADERS("async_shader_compilation", Settings.SECTION_RENDERER, false), ADRENO_GPU_BOOST("adreno_gpu_boost", Settings.SECTION_RENDERER, false), diff --git a/src/android/app/src/main/java/io/github/mandarine3ds/mandarine/features/settings/model/IntSetting.kt b/src/android/app/src/main/java/io/github/mandarine3ds/mandarine/features/settings/model/IntSetting.kt index 182048f82..42dbbeb61 100644 --- a/src/android/app/src/main/java/io/github/mandarine3ds/mandarine/features/settings/model/IntSetting.kt +++ b/src/android/app/src/main/java/io/github/mandarine3ds/mandarine/features/settings/model/IntSetting.kt @@ -62,7 +62,6 @@ enum class IntSetting( DEBUG_RENDERER("renderer_debug", Settings.SECTION_DEBUG, 0), TEXTURE_FILTER("texture_filter", Settings.SECTION_RENDERER, 0), FRAME_SKIP("frame_skip", Settings.SECTION_CORE, 0), - CUSTOM_CPU_TICKS("custom_cpu_ticks", Settings.SECTION_CORE, 0), CPU_TICKS("cpu_ticks", Settings.SECTION_CORE, 16000), USE_FRAME_LIMIT("use_frame_limit", Settings.SECTION_RENDERER, 1), DELAY_RENDER_THREAD_US("delay_game_render_thread_us", Settings.SECTION_RENDERER, 0), diff --git a/src/android/app/src/main/java/io/github/mandarine3ds/mandarine/features/settings/ui/SettingsFragmentPresenter.kt b/src/android/app/src/main/java/io/github/mandarine3ds/mandarine/features/settings/ui/SettingsFragmentPresenter.kt index 2b551e9c4..db8f186fc 100644 --- a/src/android/app/src/main/java/io/github/mandarine3ds/mandarine/features/settings/ui/SettingsFragmentPresenter.kt +++ b/src/android/app/src/main/java/io/github/mandarine3ds/mandarine/features/settings/ui/SettingsFragmentPresenter.kt @@ -232,27 +232,48 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) IntSetting.FRAME_SKIP.defaultValue ) ) + + val customCPUTicks: AbstractBooleanSetting = object : AbstractBooleanSetting { + override var boolean: Boolean + get() = preferences.getBoolean(BooleanSetting.CUSTOM_CPU_TICKS.key, false) + set(value) { + preferences.edit() + .putBoolean(BooleanSetting.CUSTOM_CPU_TICKS.key, value) + .apply() + settingsActivity.recreate() + } + override val key: String? = null + override val section: String? = null + override val isRuntimeEditable: Boolean = true + override val valueAsString: String + get() = preferences.getBoolean(BooleanSetting.CUSTOM_CPU_TICKS.key, false) + .toString() + override val defaultValue: Any = false + } + add( SwitchSetting( - IntSetting.CUSTOM_CPU_TICKS, + customCPUTicks, R.string.custom_cpu_ticks, - R.string.custom_cpu_ticks_description, - IntSetting.CUSTOM_CPU_TICKS.key, - IntSetting.CUSTOM_CPU_TICKS.defaultValue + R.string.custom_cpu_ticks_description ) ) - add( - SliderSetting( - IntSetting.CPU_TICKS, - R.string.cpu_ticks, - 0, - 77, - 65535, - "", - IntSetting.CPU_TICKS.key, - IntSetting.CPU_TICKS.defaultValue.toFloat() + + if (BooleanSetting.CUSTOM_CPU_TICKS.boolean) { + add( + SliderSetting( + IntSetting.CPU_TICKS, + R.string.cpu_ticks, + 0, + 77, + 65535, + "", + IntSetting.CPU_TICKS.key, + IntSetting.CPU_TICKS.defaultValue.toFloat() + ) ) - ) + } + add( SwitchSetting( IntSetting.USE_FRAME_LIMIT, diff --git a/src/common/settings.cpp b/src/common/settings.cpp index e38a8cfde..dc896a207 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -160,7 +160,9 @@ void LogSettings() { log_setting("System_PluginLoaderAllowed", values.allow_plugin_loader.GetValue()); log_setting("Debugging_DelayStartForLLEModules", values.delay_start_for_lle_modules.GetValue()); log_setting("Debugging_UseGdbstub", values.use_gdbstub.GetValue()); - log_setting("Debugging_GdbstubPort", values.gdbstub_port.GetValue()); + if (values.use_gdbstub) { + log_setting("Debugging_GdbstubPort", values.gdbstub_port.GetValue()); + } log_setting("Debugging_InstantDebugLog", values.instant_debug_log.GetValue()); } diff --git a/src/common/settings.h b/src/common/settings.h index 199f3282c..7b7437669 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -550,7 +550,7 @@ struct Values { SwitchableSetting disable_flush_cpu_write{false, "disable_flush_cpu_write"}; SwitchableSetting priority_boost_starved_threads{true, "priority_boost_starved_threads"}; SwitchableSetting reduce_downcount_slice{false, "reduce_downcount_slice"}; - // Reimplementation of old (and fixed) citra frameskip + // Reimplementation of old citra frameskip // See https://github.com/mandarine3ds/mandarine/commit/e279a6955edf644cf832dd329ac72931aea8add7 SwitchableSetting frame_skip{0, "frame_skip"};