[debug] added functions to enable access to debug knobs from kotlin side + docs (#3265)
Co-authored-by: Caio Oliveira <caiooliveirafarias0@gmail.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3265 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: DraVee <dravee@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: xbzk <xbzk@eden-emu.dev> Co-committed-by: xbzk <xbzk@eden-emu.dev>
This commit is contained in:
parent
b1daffad19
commit
9c5203d922
|
|
@ -9,32 +9,28 @@ This guide will walk you through adding a new boolean toggle setting to Eden's c
|
||||||
|
|
||||||
## Index
|
## Index
|
||||||
|
|
||||||
1. [Step 1 - src/common/settings](#step-1-src-common-settings)
|
1. [Step 1 - Common Setting](#step-1-common-setting)
|
||||||
2. [Qt's (PC) Steps](#qt-pc-steps)
|
2. [Step 2 - Qt Toggle](#step-2-qt-toggle)
|
||||||
|
3. [Step 3 - Kotlin (Android)](#step-3-kotlin-android)
|
||||||
|
|
||||||
* [Step 2 - src/qt_common/config/shared_translation.cpp](#step-2-src-qt_common-config-shared_translation-cpp)
|
* [Step 3.1 - BooleanSetting.kt](#step-3-1-booleansetting-kt)
|
||||||
3. [ Kotlin's (Android) Steps](#android-steps)
|
* [Step 3.2 - SettingsItem.kt](#step-3-2-settingsitem-kt)
|
||||||
|
* [Step 3.3 - SettingsFragmentPresenter.kt](#step-3-3-settingsfragmentpresenter-kt)
|
||||||
* [Step 3 - BooleanSetting.kt](#step-3-src-android-app-src-main-java-org-yuzu-yuzu_emu-features-settings-model-booleansetting-kt)
|
* [Step 3.4 - Localization](#step-3-4-localization)
|
||||||
* [Step 4 - SettingsItem.kt](#step-4-src-android-app-src-main-java-org-yuzu-yuzu_emu-features-settings-model-view-settingsitem-kt)
|
4. [Step 4 - Use Your Toggle](#step-4-use-your-toggle)
|
||||||
* [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)
|
|
||||||
5. [Best Practices](#best-practices)
|
5. [Best Practices](#best-practices)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Step 1 - src/common/settings.
|
## Step 1 - Common Setting
|
||||||
|
|
||||||
Firstly add your desired toggle inside `setting.h`,
|
Firstly add your desired toggle:
|
||||||
Example:
|
|
||||||
|
|
||||||
```
|
Example: `src/common/setting.h`
|
||||||
|
```cpp
|
||||||
SwitchableSetting<bool> your_setting_name{linkage, false, "your_setting_name", Category::RendererExtensions};
|
SwitchableSetting<bool> 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:
|
### Remember to add your toggle to the appropriate category, for example:
|
||||||
|
|
||||||
Common Categories:
|
Common Categories:
|
||||||
|
|
@ -45,17 +41,17 @@ Common Categories:
|
||||||
* Category::System
|
* Category::System
|
||||||
* Category::Core
|
* 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`,
|
Example: `src/qt_common/config/shared_translation.cpp`
|
||||||
Find where you wish for it to appear and place it there.
|
```cpp
|
||||||
Example:
|
|
||||||
|
|
||||||
```
|
|
||||||
INSERT(Settings,
|
INSERT(Settings,
|
||||||
your_setting_name,
|
your_setting_name,
|
||||||
tr("Your Setting Display 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.
|
Add where it should be in the settings.
|
||||||
Example:
|
|
||||||
|
|
||||||
```
|
Example: `src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt`
|
||||||
|
```kts
|
||||||
RENDERER_YOUR_SETTING_NAME("your_setting_name"),
|
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(
|
put(
|
||||||
SwitchSetting(
|
SwitchSetting(
|
||||||
BooleanSetting.RENDERER_YOUR_SETTING_NAME,
|
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
|
---
|
||||||
|
|
||||||
Now add your setting to the correct location inside `SettingsFragmentPresenter.kt` within the right category.
|
### Step 3.3 - SettingsFragmentPresenter.kt
|
||||||
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)
|
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.
|
### Step 3.4 - Localization
|
||||||
Example:
|
|
||||||
|
|
||||||
```
|
Add your setting and description in the appropriate place.
|
||||||
|
|
||||||
|
Example: `src/android/app/src/main/res/values/strings.xml`
|
||||||
|
```xml
|
||||||
<string name="your_setting_name">Your Setting Display Name</string>
|
<string name="your_setting_name">Your Setting Display Name</string>
|
||||||
<string name="your_setting_name_description">Detailed description of what this setting does. Explain any caveats, requirements, or warnings here.</string>
|
<string name="your_setting_name_description">Detailed description of what this setting does. Explain any caveats, requirements, or warnings here.</string>
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 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,
|
Now the UI part is done find a place in the code for the toggle,
|
||||||
And use it to your heart's desire!
|
And use it to your heart's desire!
|
||||||
Example:
|
|
||||||
|
|
||||||
```
|
Example:
|
||||||
|
```cpp
|
||||||
const bool your_value = Settings::values.your_setting_name.GetValue();
|
const bool your_value = Settings::values.your_setting_name.GetValue();
|
||||||
|
|
||||||
if (your_value) {
|
if (your_value) {
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ Common advantages recap:
|
||||||
Use the `Settings::getDebugKnobAt(u8 i)` function to check if a specific bit is set:
|
Use the `Settings::getDebugKnobAt(u8 i)` function to check if a specific bit is set:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
|
//cpp side
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
|
|
||||||
// Check if bit 0 is set
|
// Check if bit 0 is set
|
||||||
|
|
@ -47,6 +48,14 @@ bool feature_enabled = Settings::getDebugKnobAt(0);
|
||||||
bool another_feature = Settings::getDebugKnobAt(15);
|
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.
|
The function returns `true` if the specified bit (0-15) is set in the `debug_knobs` value, `false` otherwise.
|
||||||
|
|
||||||
### Setting Debug Knobs (user side)
|
### Setting Debug Knobs (user side)
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,8 @@ object NativeLibrary {
|
||||||
|
|
||||||
external fun logSettings()
|
external fun logSettings()
|
||||||
|
|
||||||
|
external fun getDebugKnobAt(index: Int): Boolean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns Vulkan driver version / API version / GPU model
|
* Returns Vulkan driver version / API version / GPU model
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,10 @@ object Settings {
|
||||||
fun getPlayerString(player: Int): String =
|
fun getPlayerString(player: Int): String =
|
||||||
YuzuApplication.appContext.getString(R.string.preferences_player, player)
|
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_FIRST_APP_LAUNCH = "FirstApplicationLaunch"
|
||||||
const val PREF_SHOULD_SHOW_DRIVER_WARNING = "ShouldShowDriverWarning"
|
const val PREF_SHOULD_SHOW_DRIVER_WARNING = "ShouldShowDriverWarning"
|
||||||
const val PREF_MEMORY_WARNING_SHOWN = "MemoryWarningShown"
|
const val PREF_MEMORY_WARNING_SHOWN = "MemoryWarningShown"
|
||||||
|
|
|
||||||
|
|
@ -1130,6 +1130,10 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_logSettings(JNIEnv* env, jobject jobj
|
||||||
Settings::LogSettings();
|
Settings::LogSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_getDebugKnobAt(JNIEnv* env, jobject jobj, jint index) {
|
||||||
|
return static_cast<jboolean>(Settings::getDebugKnobAt(static_cast<u8>(index)));
|
||||||
|
}
|
||||||
|
|
||||||
void Java_org_yuzu_yuzu_1emu_NativeLibrary_run(JNIEnv* env, jobject jobj, jstring j_path,
|
void Java_org_yuzu_yuzu_1emu_NativeLibrary_run(JNIEnv* env, jobject jobj, jstring j_path,
|
||||||
jint j_program_index,
|
jint j_program_index,
|
||||||
jboolean j_frontend_initiated) {
|
jboolean j_frontend_initiated) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue