diff --git a/docs/user/AddingBooleanToggles.md b/docs/user/AddingBooleanToggles.md index 0c4b58a47c..1af5fd932d 100644 --- a/docs/user/AddingBooleanToggles.md +++ b/docs/user/AddingBooleanToggles.md @@ -9,32 +9,28 @@ This guide will walk you through adding a new boolean toggle setting to Eden's c ## Index -1. [Step 1 - src/common/settings](#step-1-src-common-settings) -2. [Qt's (PC) Steps](#qt-pc-steps) - - * [Step 2 - src/qt_common/config/shared_translation.cpp](#step-2-src-qt_common-config-shared_translation-cpp) -3. [ Kotlin's (Android) Steps](#android-steps) - - * [Step 3 - BooleanSetting.kt](#step-3-src-android-app-src-main-java-org-yuzu-yuzu_emu-features-settings-model-booleansetting-kt) - * [Step 4 - SettingsItem.kt](#step-4-src-android-app-src-main-java-org-yuzu-yuzu_emu-features-settings-model-view-settingsitem-kt) - * [Step 5 - SettingsFragmentPresenter.kt](#step-5-src-android-app-src-main-java-org-yuzu-yuzu_emu-features-settings-ui-settingsfragmentpresenter-kt) - * [Step 6 - strings.xml](#step-6-src-android-app-src-main-res-values-strings-xml) -4. [Step 7 - Use Your Toggle](#step-7-use-your-toggle) +1. [Step 1 - Common Setting](#step-1-common-setting) +2. [Step 2 - Qt Toggle](#step-2-qt-toggle) +3. [Step 3 - Kotlin (Android)](#step-3-kotlin-android) + + * [Step 3.1 - BooleanSetting.kt](#step-3-1-booleansetting-kt) + * [Step 3.2 - SettingsItem.kt](#step-3-2-settingsitem-kt) + * [Step 3.3 - SettingsFragmentPresenter.kt](#step-3-3-settingsfragmentpresenter-kt) + * [Step 3.4 - Localization](#step-3-4-localization) +4. [Step 4 - Use Your Toggle](#step-4-use-your-toggle) 5. [Best Practices](#best-practices) --- -## Step 1 - src/common/settings. +## Step 1 - Common Setting -Firstly add your desired toggle inside `setting.h`, -Example: +Firstly add your desired toggle: -``` +Example: `src/common/setting.h` +```cpp SwitchableSetting your_setting_name{linkage, false, "your_setting_name", Category::RendererExtensions}; ``` -NOTE - If you wish for your toggle to be on by default then change `false` to `true` after `linkage,`. - ### Remember to add your toggle to the appropriate category, for example: Common Categories: @@ -45,17 +41,17 @@ Common Categories: * Category::System * Category::Core +> [!WARNING] +> If you wish for your toggle to be `on by default` then change `false` to `true` after `linkage,`. + --- -## Qt (PC) Steps +## Step 2 - Qt Toggle -### Step 2 - src/qt_common/config/shared_translation.cpp +Add the toggle to the Qt UI, where you wish for it to appear and place it there. -Now you can add the toggle to the QT (PC) UI inside `shared_translation.cpp`, -Find where you wish for it to appear and place it there. -Example: - -``` +Example: `src/qt_common/config/shared_translation.cpp` +```cpp INSERT(Settings, your_setting_name, tr("Your Setting Display Name"), @@ -72,25 +68,29 @@ INSERT(Settings, --- -## Android Steps +## Step 3 - Kotlin (Android) -### Step 3 - src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt +### Step 3.1 - BooleanSetting.kt -Now add it inside `BooleanSetting.kt` where it should be in the settings. -Example: +Add where it should be in the settings. -``` +Example: `src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt` +```kts RENDERER_YOUR_SETTING_NAME("your_setting_name"), ``` -Remember to make sure the naming of the prefix matches the desired category. +### Make sure to: -### Step 4 - src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt +* Ensure the prefix naming matches the intended category. -Now you may add the toggle to the Kotlin (Android) UI inside `SettingsItem.kt`. -Example: +--- -``` +### Step 3.2 - SettingsItem.kt + +Add the toggle to the Kotlin (Android) UI + +Example: `src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt` +```kts put( SwitchSetting( BooleanSetting.RENDERER_YOUR_SETTING_NAME, @@ -100,36 +100,41 @@ put( ) ``` -### Step 5 - src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt +--- + +### Step 3.3 - SettingsFragmentPresenter.kt -Now add your setting to the correct location inside `SettingsFragmentPresenter.kt` within the right category. -Example: +Add your setting within the right category. -``` +Example: `src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt` +```kts add(BooleanSetting.RENDERER_YOUR_SETTING_NAME.key) ``` -Remember, placing matters! Settings appear in the order of where you add them. +> [!WARNING] +> Remember, placing matters! Settings appear in the order of where you add them. -### Step 6 - src/android/app/src/main/res/values/strings.xml +--- -Now add your setting and description to `strings.xml` in the appropriate place. -Example: +### Step 3.4 - Localization -``` +Add your setting and description in the appropriate place. + +Example: `src/android/app/src/main/res/values/strings.xml` +```xml Your Setting Display Name Detailed description of what this setting does. Explain any caveats, requirements, or warnings here. ``` --- -## Step 7 - Use Your Toggle! +## Step 4 - Use Your Toggle! Now the UI part is done find a place in the code for the toggle, And use it to your heart's desire! -Example: -``` +Example: +```cpp const bool your_value = Settings::values.your_setting_name.GetValue(); if (your_value) { diff --git a/docs/user/AddingDebugKnobs.md b/docs/user/AddingDebugKnobs.md index 914784d9df..bcf3f1fcc6 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); ``` +```kts +//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 fdf9e8b32b..37a331b385 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 @@ -34,6 +34,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 2fd532870c..e656c2edad 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -1130,6 +1130,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) {