diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/ControlGroup.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/ControlGroup.java deleted file mode 100644 index 1bafd4a1f2..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/ControlGroup.java +++ /dev/null @@ -1,66 +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::ControlGroup. - * - * 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 ControlGroup -{ - public static final int TYPE_OTHER = 0; - public static final int TYPE_STICK = 1; - public static final int TYPE_MIXED_TRIGGERS = 2; - public static final int TYPE_BUTTONS = 3; - public static final int TYPE_FORCE = 4; - public static final int TYPE_ATTACHMENTS = 5; - public static final int TYPE_TILT = 6; - public static final int TYPE_CURSOR = 7; - public static final int TYPE_TRIGGERS = 8; - public static final int TYPE_SLIDER = 9; - public static final int TYPE_SHAKE = 10; - public static final int TYPE_IMU_ACCELEROMETER = 11; - public static final int TYPE_IMU_GYROSCOPE = 12; - public static final int TYPE_IMU_CURSOR = 13; - - public static final int DEFAULT_ENABLED_ALWAYS = 0; - public static final int DEFAULT_ENABLED_YES = 1; - public static final int DEFAULT_ENABLED_NO = 2; - - @Keep - private final long mPointer; - - @Keep - private ControlGroup(long pointer) - { - mPointer = pointer; - } - - public native String getUiName(); - - public native int getGroupType(); - - public native int getDefaultEnabledValue(); - - public native boolean getEnabled(); - - public native void setEnabled(boolean value); - - public native int getControlCount(); - - public native Control getControl(int i); - - public native int getNumericSettingCount(); - - public native NumericSetting getNumericSetting(int i); - - /** - * If getGroupType returns TYPE_ATTACHMENTS, this returns the attachment selection setting. - * Otherwise, undefined behavior! - */ - public native NumericSetting getAttachmentSetting(); -} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/ControlGroup.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/ControlGroup.kt new file mode 100644 index 0000000000..9c5132b1a2 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/ControlGroup.kt @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.dolphinemu.features.input.model.controlleremu + +import androidx.annotation.Keep + +/** + * Represents a C++ ControllerEmu::ControlGroup. + * + * 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 ControlGroup private constructor(private val pointer: Long) { + external fun getUiName(): String + + external fun getGroupType(): Int + + external fun getDefaultEnabledValue(): Int + + external fun getEnabled(): Boolean + + external fun setEnabled(value: Boolean) + + external fun getControlCount(): Int + + external fun getControl(i: Int): Control + + external fun getNumericSettingCount(): Int + + external fun getNumericSetting(i: Int): NumericSetting + + /** + * If getGroupType returns TYPE_ATTACHMENTS, this returns the attachment selection setting. + * Otherwise, undefined behavior! + */ + external fun getAttachmentSetting(): NumericSetting + + companion object { + const val TYPE_OTHER = 0 + const val TYPE_STICK = 1 + const val TYPE_MIXED_TRIGGERS = 2 + const val TYPE_BUTTONS = 3 + const val TYPE_FORCE = 4 + const val TYPE_ATTACHMENTS = 5 + const val TYPE_TILT = 6 + const val TYPE_CURSOR = 7 + const val TYPE_TRIGGERS = 8 + const val TYPE_SLIDER = 9 + const val TYPE_SHAKE = 10 + const val TYPE_IMU_ACCELEROMETER = 11 + const val TYPE_IMU_GYROSCOPE = 12 + const val TYPE_IMU_CURSOR = 13 + + const val DEFAULT_ENABLED_ALWAYS = 0 + const val DEFAULT_ENABLED_YES = 1 + const val DEFAULT_ENABLED_NO = 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 59858193df..09298d0b8a 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 @@ -2254,12 +2254,12 @@ class SettingsFragmentPresenter( val groupCount = controller.groupCount for (i in 0 until groupCount) { val group = controller.getGroup(i) - val groupType = group.groupType + val groupType = group.getGroupType() if (groupTypeFilter != null && !groupTypeFilter.contains(groupType)) continue - sl.add(HeaderSetting(group.uiName, "")) + sl.add(HeaderSetting(group.getUiName(), "")) - if (group.defaultEnabledValue != ControlGroup.DEFAULT_ENABLED_ALWAYS) { + if (group.getDefaultEnabledValue() != ControlGroup.DEFAULT_ENABLED_ALWAYS) { sl.add( SwitchSetting( context, @@ -2270,13 +2270,13 @@ class SettingsFragmentPresenter( ) } - val controlCount = group.controlCount + val controlCount = group.getControlCount() for (j in 0 until controlCount) { sl.add(InputMappingControlSetting(group.getControl(j), controller)) } if (groupType == ControlGroup.TYPE_ATTACHMENTS) { - val attachmentSetting = group.attachmentSetting + val attachmentSetting = group.getAttachmentSetting() sl.add( SingleChoiceSetting( context, InputMappingIntSetting(attachmentSetting), @@ -2287,7 +2287,7 @@ class SettingsFragmentPresenter( ) } - val numericSettingCount = group.numericSettingCount + val numericSettingCount = group.getNumericSettingCount() for (j in 0 until numericSettingCount) { addNumericSetting(sl, group.getNumericSetting(j)) } diff --git a/Source/Android/jni/AndroidCommon/IDCache.cpp b/Source/Android/jni/AndroidCommon/IDCache.cpp index 5e9a1692d5..a9bcf93b9c 100644 --- a/Source/Android/jni/AndroidCommon/IDCache.cpp +++ b/Source/Android/jni/AndroidCommon/IDCache.cpp @@ -710,7 +710,7 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) const jclass control_group_class = env->FindClass("org/dolphinemu/dolphinemu/features/input/model/controlleremu/ControlGroup"); s_control_group_class = reinterpret_cast(env->NewGlobalRef(control_group_class)); - s_control_group_pointer = env->GetFieldID(control_group_class, "mPointer", "J"); + s_control_group_pointer = env->GetFieldID(control_group_class, "pointer", "J"); s_control_group_constructor = env->GetMethodID(control_group_class, "", "(J)V"); env->DeleteLocalRef(control_group_class);