From e63f71c787ab955b48950dc9414625e15dc0980c Mon Sep 17 00:00:00 2001 From: xbzk Date: Tue, 25 Nov 2025 00:41:45 +0100 Subject: [PATCH] [android, qt] 16 bit debug knob set for quick development toggles (#3076) **Aims to dismiss the needing of developers to wait for someone to provide new toggles only to test temporary stuff** This is a classic debug knob set for development use. Developers will be able to call Settings::getDebugKnobAt(0 to 15) to pick one of the 16 bits of that setting, allowing users to easily enable or disable multiple features in testing builds, by entering values instructed by the developers. Co-authored-by: Allison Cunha Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3076 Reviewed-by: Lizzie Reviewed-by: MaranBr Reviewed-by: Caio Oliveira Co-authored-by: xbzk Co-committed-by: xbzk --- .../features/settings/model/IntSetting.kt | 3 ++- .../settings/model/view/SettingsItem.kt | 10 ++++++++ .../settings/ui/SettingsDialogFragment.kt | 7 ++++++ .../settings/ui/SettingsFragmentPresenter.kt | 3 ++- .../app/src/main/res/values/strings.xml | 5 ++++ src/common/settings.cpp | 4 +++ src/common/settings.h | 12 +++++++++ src/yuzu/configuration/configure_debug.cpp | 8 ++++++ src/yuzu/configuration/configure_debug.h | 6 +++-- src/yuzu/configuration/configure_debug.ui | 25 +++++++++++++++++++ 10 files changed, 79 insertions(+), 4 deletions(-) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt index 3bccc97607..aa9ba664e7 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt @@ -61,7 +61,8 @@ enum class IntSetting(override val key: String) : AbstractIntSetting { LOGIN_SHARE_APPLET("login_share_applet_mode"), WIFI_WEB_AUTH_APPLET("wifi_web_auth_applet_mode"), MY_PAGE_APPLET("my_page_applet_mode"), - INPUT_OVERLAY_AUTO_HIDE("input_overlay_auto_hide") + INPUT_OVERLAY_AUTO_HIDE("input_overlay_auto_hide"), + DEBUG_KNOBS("debug_knobs") ; override fun getInt(needsGlobal: Boolean): Int = NativeConfig.getInt(key, needsGlobal) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt index d8100e07e2..248e40cdd1 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt @@ -788,6 +788,16 @@ abstract class SettingsItem( descriptionId = R.string.use_auto_stub_description ) ) + put( + SpinBoxSetting( + IntSetting.DEBUG_KNOBS, + titleId = R.string.debug_knobs, + descriptionId = R.string.debug_knobs_description, + valueHint = R.string.debug_knobs_hint, + min = 0, + max = 65535 + ) + ) val fastmem = object : AbstractBooleanSetting { override fun getBoolean(needsGlobal: Boolean): Boolean = diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsDialogFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsDialogFragment.kt index 51d0455fd5..f66f4bac7f 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsDialogFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsDialogFragment.kt @@ -186,6 +186,12 @@ class SettingsDialogFragment : DialogFragment(), DialogInterface.OnClickListener updateButtonState(isValid) } + /* + * xbzk: these two events, along with attachRepeat feature, + * were causing spinbox buttons to respond twice per press + * cutting these out to retain accelerated press functionality + * TODO: clean this out later if no issues arise + * spinboxBinding.buttonDecrement.setOnClickListener { val current = spinboxBinding.editValue.text.toString().toIntOrNull() ?: currentValue val newValue = current - 1 @@ -199,6 +205,7 @@ class SettingsDialogFragment : DialogFragment(), DialogInterface.OnClickListener spinboxBinding.editValue.setText(newValue.toString()) updateValidity(newValue) } + */ fun attachRepeat(button: View, delta: Int) { val handler = Handler(Looper.getMainLooper()) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt index bb05c19b5e..eb3682757b 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt @@ -1167,9 +1167,10 @@ class SettingsFragmentPresenter( add(IntSetting.CPU_ACCURACY.key) add(BooleanSetting.USE_AUTO_STUB.key) add(SettingsItem.FASTMEM_COMBINED) - add(HeaderSetting(R.string.log)) add(BooleanSetting.DEBUG_FLUSH_BY_LINE.key) + add(HeaderSetting(R.string.general)) + add(IntSetting.DEBUG_KNOBS.key) } } } diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 2d071b45d5..2dcee90404 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -135,6 +135,9 @@ (EXPERIMENTAL) Change the emulated memory layout. This setting will not increase performance, but may help with games utilizing high resolutions via mods. Do not use on phones with 8GB of RAM or less. Only works on the Dynarmic (JIT) backend. DMA Accuracy Controls the DMA precision accuracy. Safe precision can fix issues in some games, but it can also impact performance in some cases. If unsure, leave this on Default. + Debug knobs + For development use only. + 0 to 65535 Shader Backend @@ -534,6 +537,8 @@ Flush debug logs by line Flushes debugging logs on each line written, making debugging easier in cases of crashing or freezing. + General + Output engine Volume diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 56b65c527c..d3f7d9afea 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -141,6 +141,10 @@ void LogSettings() { log_path("DataStorage_SDMCDir", Common::FS::GetEdenPath(Common::FS::EdenPath::SDMCDir)); } +bool getDebugKnobAt(u8 i) { + return (values.debug_knobs.GetValue() & (1 << (i & 0xF))) != 0; +} + void UpdateGPUAccuracy() { values.current_gpu_accuracy = values.gpu_accuracy.GetValue(); } diff --git a/src/common/settings.h b/src/common/settings.h index 4114a21680..25bdfb1bf2 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -739,6 +739,16 @@ struct Values { Setting perform_vulkan_check{linkage, true, "perform_vulkan_check", Category::Debugging}; Setting disable_web_applet{linkage, true, "disable_web_applet", Category::Debugging}; + SwitchableSetting debug_knobs{linkage, + 0, + 0, + 65535, + "debug_knobs", + Category::Debugging, + Specialization::Countable, + true, + true}; + // Miscellaneous Setting serial_battery{linkage, std::string(), "serial_battery", Category::Miscellaneous}; Setting serial_unit{linkage, std::string(), "serial_unit", Category::Miscellaneous}; @@ -768,6 +778,8 @@ struct Values { extern Values values; +bool getDebugKnobAt(u8 i); + void UpdateGPUAccuracy(); bool IsGPULevelExtreme(); bool IsGPULevelHigh(); diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp index 3164f418ac..0de5f46dcc 100644 --- a/src/yuzu/configuration/configure_debug.cpp +++ b/src/yuzu/configuration/configure_debug.cpp @@ -88,6 +88,13 @@ void ConfigureDebug::SetConfiguration() { ui->disable_loop_safety_checks->setEnabled(runtime_lock); ui->disable_loop_safety_checks->setChecked(Settings::values.disable_shader_loop_safety_checks.GetValue()); ui->perform_vulkan_check->setChecked(Settings::values.perform_vulkan_check.GetValue()); + ui->debug_knobs_spinbox->setValue(Settings::values.debug_knobs.GetValue()); +#ifdef YUZU_USE_QT_WEB_ENGINE + ui->disable_web_applet->setChecked(Settings::values.disable_web_applet.GetValue()); +#else + ui->disable_web_applet->setChecked(true); + ui->disable_web_applet->setVisible(false); +#endif } void ConfigureDebug::ApplyConfiguration() { @@ -118,6 +125,7 @@ void ConfigureDebug::ApplyConfiguration() { Settings::values.extended_logging = ui->extended_logging->isChecked(); Settings::values.perform_vulkan_check = ui->perform_vulkan_check->isChecked(); Settings::values.disable_web_applet = ui->disable_web_applet->isChecked(); + Settings::values.debug_knobs = ui->debug_knobs_spinbox->value(); Debugger::ToggleConsole(); Common::Log::Filter filter; filter.ParseFilterString(Settings::values.log_filter.GetValue()); diff --git a/src/yuzu/configuration/configure_debug.h b/src/yuzu/configuration/configure_debug.h index 030a0b7f75..2133f1a81f 100644 --- a/src/yuzu/configuration/configure_debug.h +++ b/src/yuzu/configuration/configure_debug.h @@ -1,11 +1,13 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later #pragma once #include #include +class QSpinBox; + namespace Core { class System; } diff --git a/src/yuzu/configuration/configure_debug.ui b/src/yuzu/configuration/configure_debug.ui index 005bbc014d..1b1423b62c 100644 --- a/src/yuzu/configuration/configure_debug.ui +++ b/src/yuzu/configuration/configure_debug.ui @@ -507,6 +507,31 @@ + + + + 0 + + + 65535 + + + Bitmask for quick development toggles + + + Set debug knobs (bitmask) + + + 16-bit debug knob set for quick development toggles + + + (bitmask) + + + Debug Knobs: + + +