summaryrefslogtreecommitdiff
path: root/Source/Android
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-06-10 05:08:08 -0400
committerCharles Lombardo <clombardo169@gmail.com>2023-08-25 14:20:31 -0400
commit9ac1847cbd08024b2da8e201b2d5c03cc94595c6 (patch)
treefdc151c5a443eac0f3b38b329a068873d1451f0a /Source/Android
parent82298dc408b315467ac3e035e158895e64465fa1 (diff)
Android: Convert NumericSetting to Kotlin
Diffstat (limited to 'Source/Android')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/NumericSetting.java104
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/NumericSetting.kt97
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt14
-rw-r--r--Source/Android/jni/AndroidCommon/IDCache.cpp2
4 files changed, 105 insertions, 112 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/NumericSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/NumericSetting.java
deleted file mode 100644
index bcb9dce181..0000000000
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/NumericSetting.java
+++ /dev/null
@@ -1,104 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-package org.dolphinemu.dolphinemu.features.input.model.controlleremu;
-
-import androidx.annotation.Keep;
-
-/**
- * Represents a C++ ControllerEmu::NumericSetting.
- *
- * The lifetime of this class is managed by C++ code. Calling methods on it after it's destroyed
- * in C++ is undefined behavior!
- */
-public class NumericSetting
-{
- public static final int TYPE_INT = 0;
- public static final int TYPE_DOUBLE = 1;
- public static final int TYPE_BOOLEAN = 2;
-
- @Keep
- private final long mPointer;
-
- @Keep
- private NumericSetting(long pointer)
- {
- mPointer = pointer;
- }
-
- /**
- * @return The name used in the UI.
- */
- public native String getUiName();
-
- /**
- * @return A string applied to the number in the UI (unit of measure).
- */
- public native String getUiSuffix();
-
- /**
- * @return Detailed description of the setting.
- */
- public native String getUiDescription();
-
- /**
- * @return TYPE_INT, TYPE_DOUBLE or TYPE_BOOLEAN
- */
- public native int getType();
-
- public native ControlReference getControlReference();
-
- /**
- * If the type is TYPE_INT, gets the current value. Otherwise, undefined behavior!
- */
- public native int getIntValue();
-
- /**
- * If the type is TYPE_INT, sets the current value. Otherwise, undefined behavior!
- */
- public native void setIntValue(int value);
-
- /**
- * If the type is TYPE_INT, gets the default value. Otherwise, undefined behavior!
- */
- public native int getIntDefaultValue();
-
- /**
- * If the type is TYPE_DOUBLE, gets the current value. Otherwise, undefined behavior!
- */
- public native double getDoubleValue();
-
- /**
- * If the type is TYPE_DOUBLE, sets the current value. Otherwise, undefined behavior!
- */
- public native void setDoubleValue(double value);
-
- /**
- * If the type is TYPE_DOUBLE, gets the default value. Otherwise, undefined behavior!
- */
- public native double getDoubleDefaultValue();
-
- /**
- * If the type is TYPE_DOUBLE, returns the minimum valid value. Otherwise, undefined behavior!
- */
- public native double getDoubleMin();
-
- /**
- * If the type is TYPE_DOUBLE, returns the maximum valid value. Otherwise, undefined behavior!
- */
- public native double getDoubleMax();
-
- /**
- * If the type is TYPE_BOOLEAN, gets the current value. Otherwise, undefined behavior!
- */
- public native boolean getBooleanValue();
-
- /**
- * If the type is TYPE_BOOLEAN, sets the current value. Otherwise, undefined behavior!
- */
- public native void setBooleanValue(boolean value);
-
- /**
- * If the type is TYPE_BOOLEAN, gets the default value. Otherwise, undefined behavior!
- */
- public native boolean getBooleanDefaultValue();
-}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/NumericSetting.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/NumericSetting.kt
new file mode 100644
index 0000000000..0a2485deab
--- /dev/null
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/NumericSetting.kt
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+package org.dolphinemu.dolphinemu.features.input.model.controlleremu
+
+import androidx.annotation.Keep
+
+/**
+ * Represents a C++ ControllerEmu::NumericSetting.
+ *
+ * The lifetime of this class is managed by C++ code. Calling methods on it after it's destroyed
+ * in C++ is undefined behavior!
+ */
+@Keep
+class NumericSetting private constructor(private val pointer: Long) {
+ /**
+ * @return The name used in the UI.
+ */
+ external fun getUiName(): String
+
+ /**
+ * @return A string applied to the number in the UI (unit of measure).
+ */
+ external fun getUiSuffix(): String
+
+ /**
+ * @return Detailed description of the setting.
+ */
+ external fun getUiDescription(): String
+
+ /**
+ * @return TYPE_INT, TYPE_DOUBLE or TYPE_BOOLEAN
+ */
+ external fun getType(): Int
+
+ external fun getControlReference(): ControlReference
+
+ /**
+ * If the type is TYPE_INT, gets the current value. Otherwise, undefined behavior!
+ */
+ external fun getIntValue(): Int
+
+ /**
+ * If the type is TYPE_INT, sets the current value. Otherwise, undefined behavior!
+ */
+ external fun setIntValue(value: Int)
+
+ /**
+ * If the type is TYPE_INT, gets the default value. Otherwise, undefined behavior!
+ */
+ external fun getIntDefaultValue(): Int
+
+ /**
+ * If the type is TYPE_DOUBLE, gets the current value. Otherwise, undefined behavior!
+ */
+ external fun getDoubleValue(): Double
+
+ /**
+ * If the type is TYPE_DOUBLE, sets the current value. Otherwise, undefined behavior!
+ */
+ external fun setDoubleValue(value: Double)
+
+ /**
+ * If the type is TYPE_DOUBLE, gets the default value. Otherwise, undefined behavior!
+ */
+ external fun getDoubleDefaultValue(): Double
+
+ /**
+ * If the type is TYPE_DOUBLE, returns the minimum valid value. Otherwise, undefined behavior!
+ */
+ external fun getDoubleMin(): Double
+
+ /**
+ * If the type is TYPE_DOUBLE, returns the maximum valid value. Otherwise, undefined behavior!
+ */
+ external fun getDoubleMax(): Double
+
+ /**
+ * If the type is TYPE_BOOLEAN, gets the current value. Otherwise, undefined behavior!
+ */
+ external fun getBooleanValue(): Boolean
+
+ /**
+ * If the type is TYPE_BOOLEAN, sets the current value. Otherwise, undefined behavior!
+ */
+ external fun setBooleanValue(value: Boolean)
+
+ /**
+ * If the type is TYPE_BOOLEAN, gets the default value. Otherwise, undefined behavior!
+ */
+ external fun getBooleanDefaultValue(): Boolean
+
+ companion object {
+ const val TYPE_INT = 0
+ const val TYPE_DOUBLE = 1
+ const val TYPE_BOOLEAN = 2
+ }
+}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt
index 8cb63c420e..2ec27cff72 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt
@@ -2295,23 +2295,23 @@ class SettingsFragmentPresenter(
}
private fun addNumericSetting(sl: ArrayList<SettingsItem>, setting: NumericSetting) {
- when (setting.type) {
+ when (setting.getType()) {
NumericSetting.TYPE_DOUBLE -> sl.add(
FloatSliderSetting(
InputMappingDoubleSetting(setting),
- setting.uiName,
+ setting.getUiName(),
"",
- ceil(setting.doubleMin).toInt(),
- floor(setting.doubleMax).toInt(),
- setting.uiSuffix
+ ceil(setting.getDoubleMin()).toInt(),
+ floor(setting.getDoubleMax()).toInt(),
+ setting.getUiSuffix()
)
)
NumericSetting.TYPE_BOOLEAN -> sl.add(
SwitchSetting(
InputMappingBooleanSetting(setting),
- setting.uiName,
- setting.uiDescription
+ setting.getUiName(),
+ setting.getUiDescription()
)
)
}
diff --git a/Source/Android/jni/AndroidCommon/IDCache.cpp b/Source/Android/jni/AndroidCommon/IDCache.cpp
index 67b6af4d71..2b437c10c0 100644
--- a/Source/Android/jni/AndroidCommon/IDCache.cpp
+++ b/Source/Android/jni/AndroidCommon/IDCache.cpp
@@ -732,7 +732,7 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
const jclass numeric_setting_class =
env->FindClass("org/dolphinemu/dolphinemu/features/input/model/controlleremu/NumericSetting");
s_numeric_setting_class = reinterpret_cast<jclass>(env->NewGlobalRef(numeric_setting_class));
- s_numeric_setting_pointer = env->GetFieldID(numeric_setting_class, "mPointer", "J");
+ s_numeric_setting_pointer = env->GetFieldID(numeric_setting_class, "pointer", "J");
s_numeric_setting_constructor = env->GetMethodID(numeric_setting_class, "<init>", "(J)V");
env->DeleteLocalRef(numeric_setting_class);