mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Android: Convert NumericSetting to Kotlin
This commit is contained in:
parent
82298dc408
commit
9ac1847cbd
@ -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();
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
@ -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()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user