diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/CoreDevice.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/CoreDevice.java deleted file mode 100644 index b69e9a0236..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/CoreDevice.java +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later - -package org.dolphinemu.dolphinemu.features.input.model; - -import androidx.annotation.Keep; - -/** - * Represents a C++ ciface::Core::Device. - */ -public final class CoreDevice -{ - /** - * Represents a C++ ciface::Core::Device::Control. - * - * This class is non-static to ensure that the CoreDevice parent does not get garbage collected - * while a Control is still accessible. (CoreDevice's finalizer may delete the native controls.) - */ - @SuppressWarnings("InnerClassMayBeStatic") - public final class Control - { - @Keep - private final long mPointer; - - @Keep - private Control(long pointer) - { - mPointer = pointer; - } - - public native String getName(); - } - - @Keep - private final long mPointer; - - @Keep - private CoreDevice(long pointer) - { - mPointer = pointer; - } - - @Override - protected native void finalize(); - - public native Control[] getInputs(); - - public native Control[] getOutputs(); -} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/CoreDevice.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/CoreDevice.kt new file mode 100644 index 0000000000..1483422c50 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/CoreDevice.kt @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.dolphinemu.features.input.model + +import androidx.annotation.Keep + +/** + * Represents a C++ ciface::Core::Device. + */ +@Keep +class CoreDevice private constructor(private val pointer: Long) { + /** + * Represents a C++ ciface::Core::Device::Control. + * + * This class is marked inner to ensure that the CoreDevice parent does not get garbage collected + * while a Control is still accessible. (CoreDevice's finalizer may delete the native controls.) + */ + @Keep + inner class Control private constructor(private val pointer: Long) { + external fun getName(): String + } + + protected external fun finalize() + + external fun getInputs(): Array + + external fun getOutputs(): Array +} diff --git a/Source/Android/jni/AndroidCommon/IDCache.cpp b/Source/Android/jni/AndroidCommon/IDCache.cpp index b5c91be10c..67b6af4d71 100644 --- a/Source/Android/jni/AndroidCommon/IDCache.cpp +++ b/Source/Android/jni/AndroidCommon/IDCache.cpp @@ -739,7 +739,7 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) const jclass core_device_class = env->FindClass("org/dolphinemu/dolphinemu/features/input/model/CoreDevice"); s_core_device_class = reinterpret_cast(env->NewGlobalRef(core_device_class)); - s_core_device_pointer = env->GetFieldID(core_device_class, "mPointer", "J"); + s_core_device_pointer = env->GetFieldID(core_device_class, "pointer", "J"); s_core_device_constructor = env->GetMethodID(core_device_class, "", "(J)V"); env->DeleteLocalRef(core_device_class); @@ -747,7 +747,7 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) env->FindClass("org/dolphinemu/dolphinemu/features/input/model/CoreDevice$Control"); s_core_device_control_class = reinterpret_cast(env->NewGlobalRef(core_device_control_class)); - s_core_device_control_pointer = env->GetFieldID(core_device_control_class, "mPointer", "J"); + s_core_device_control_pointer = env->GetFieldID(core_device_control_class, "pointer", "J"); s_core_device_control_constructor = env->GetMethodID(core_device_control_class, "", "(Lorg/dolphinemu/dolphinemu/features/input/model/CoreDevice;J)V");