android: add a listener for custom cpu ticks toggle

This commit is contained in:
Gamer64 2024-09-22 20:55:38 +02:00
parent 5b89098255
commit 33d1a7360a
5 changed files with 41 additions and 18 deletions

View File

@ -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),

View File

@ -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),

View File

@ -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,

View File

@ -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());
}

View File

@ -550,7 +550,7 @@ struct Values {
SwitchableSetting<bool> disable_flush_cpu_write{false, "disable_flush_cpu_write"};
SwitchableSetting<bool> priority_boost_starved_threads{true, "priority_boost_starved_threads"};
SwitchableSetting<bool> 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<u64> frame_skip{0, "frame_skip"};