From 324b637e69c9abf4a1f76f2edb8ff7376de95cef Mon Sep 17 00:00:00 2001 From: xbzk Date: Sun, 4 Jan 2026 14:42:31 -0300 Subject: [PATCH] added functions to enable access to debug knobs from kotlin side + docs --- docs/user/AddingDebugKnobs.md | 9 +++++++++ .../app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt | 2 ++ .../yuzu/yuzu_emu/features/settings/model/Settings.kt | 4 ++++ src/android/app/src/main/jni/native.cpp | 4 ++++ 4 files changed, 19 insertions(+) diff --git a/docs/user/AddingDebugKnobs.md b/docs/user/AddingDebugKnobs.md index 914784d9df..17d0dd46c1 100644 --- a/docs/user/AddingDebugKnobs.md +++ b/docs/user/AddingDebugKnobs.md @@ -38,6 +38,7 @@ Common advantages recap: Use the `Settings::getDebugKnobAt(u8 i)` function to check if a specific bit is set: ```cpp +//cpp side #include "common/settings.h" // Check if bit 0 is set @@ -47,6 +48,14 @@ bool feature_enabled = Settings::getDebugKnobAt(0); bool another_feature = Settings::getDebugKnobAt(15); ``` +```kotlin +//kotlin side +import org.yuzu.yuzu_emu.features.settings.model.Settings + +// Check if bit x is set +bool feature_enabled = Settings.getDebugKnobAt(x); //x as integer from 0 to 15 +`` + The function returns `true` if the specified bit (0-15) is set in the `debug_knobs` value, `false` otherwise. ### Setting Debug Knobs (user side) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt index 394a1f8e55..65d13ba2ba 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt @@ -200,6 +200,8 @@ object NativeLibrary { external fun logSettings() + external fun getDebugKnobAt(index: Int): Boolean + /** * Returns Vulkan driver version / API version / GPU model */ diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt index df96b17bec..304e6c8fd6 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt @@ -33,6 +33,10 @@ object Settings { fun getPlayerString(player: Int): String = YuzuApplication.appContext.getString(R.string.preferences_player, player) + fun getDebugKnobAt(index: Int): Boolean { + return org.yuzu.yuzu_emu.NativeLibrary.getDebugKnobAt(index) + } + const val PREF_FIRST_APP_LAUNCH = "FirstApplicationLaunch" const val PREF_SHOULD_SHOW_DRIVER_WARNING = "ShouldShowDriverWarning" const val PREF_MEMORY_WARNING_SHOWN = "MemoryWarningShown" diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index d2daef4eb2..391f4e4506 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -1113,6 +1113,10 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_logSettings(JNIEnv* env, jobject jobj Settings::LogSettings(); } +jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_getDebugKnobAt(JNIEnv* env, jobject jobj, jint index) { + return static_cast(Settings::getDebugKnobAt(static_cast(index))); +} + void Java_org_yuzu_yuzu_1emu_NativeLibrary_run(JNIEnv* env, jobject jobj, jstring j_path, jint j_program_index, jboolean j_frontend_initiated) {