Android: Convert EmulatedController to Kotlin
This commit is contained in:
parent
4ce069cf4f
commit
3011c0dc64
|
@ -1,52 +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::EmulatedController.
|
||||
*
|
||||
* 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 EmulatedController
|
||||
{
|
||||
@Keep
|
||||
private final long mPointer;
|
||||
|
||||
@Keep
|
||||
private EmulatedController(long pointer)
|
||||
{
|
||||
mPointer = pointer;
|
||||
}
|
||||
|
||||
public native String getDefaultDevice();
|
||||
|
||||
public native void setDefaultDevice(String device);
|
||||
|
||||
public native int getGroupCount();
|
||||
|
||||
public native ControlGroup getGroup(int index);
|
||||
|
||||
public native void updateSingleControlReference(ControlReference controlReference);
|
||||
|
||||
public native void loadDefaultSettings();
|
||||
|
||||
public native void clearSettings();
|
||||
|
||||
public native void loadProfile(String path);
|
||||
|
||||
public native void saveProfile(String path);
|
||||
|
||||
public static native EmulatedController getGcPad(int controllerIndex);
|
||||
|
||||
public static native EmulatedController getWiimote(int controllerIndex);
|
||||
|
||||
public static native EmulatedController getWiimoteAttachment(int controllerIndex,
|
||||
int attachmentIndex);
|
||||
|
||||
public static native int getSelectedWiimoteAttachment(int controllerIndex);
|
||||
|
||||
public static native NumericSetting getSidewaysWiimoteSetting(int controllerIndex);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.dolphinemu.dolphinemu.features.input.model.controlleremu
|
||||
|
||||
import androidx.annotation.Keep
|
||||
|
||||
/**
|
||||
* Represents a C++ ControllerEmu::EmulatedController.
|
||||
*
|
||||
* 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 EmulatedController private constructor(private val pointer: Long) {
|
||||
external fun getDefaultDevice(): String
|
||||
|
||||
external fun setDefaultDevice(device: String)
|
||||
|
||||
external fun getGroupCount(): Int
|
||||
|
||||
external fun getGroup(index: Int): ControlGroup
|
||||
|
||||
external fun updateSingleControlReference(controlReference: ControlReference)
|
||||
|
||||
external fun loadDefaultSettings()
|
||||
|
||||
external fun clearSettings()
|
||||
|
||||
external fun loadProfile(path: String)
|
||||
|
||||
external fun saveProfile(path: String)
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
external fun getGcPad(controllerIndex: Int): EmulatedController
|
||||
|
||||
@JvmStatic
|
||||
external fun getWiimote(controllerIndex: Int): EmulatedController
|
||||
|
||||
@JvmStatic
|
||||
external fun getWiimoteAttachment(
|
||||
controllerIndex: Int,
|
||||
attachmentIndex: Int
|
||||
): EmulatedController
|
||||
|
||||
@JvmStatic
|
||||
external fun getSelectedWiimoteAttachment(controllerIndex: Int): Int
|
||||
|
||||
@JvmStatic
|
||||
external fun getSidewaysWiimoteSetting(controllerIndex: Int): NumericSetting
|
||||
}
|
||||
}
|
|
@ -258,7 +258,7 @@ class SettingsAdapter(
|
|||
}
|
||||
|
||||
fun onInputMappingClick(item: InputMappingControlSetting, position: Int) {
|
||||
if (item.controller.defaultDevice.isEmpty() && !fragmentView.isMappingAllDevices) {
|
||||
if (item.controller.getDefaultDevice().isEmpty() && !fragmentView.isMappingAllDevices) {
|
||||
MaterialAlertDialogBuilder(fragmentView.fragmentActivity)
|
||||
.setMessage(R.string.input_binding_no_device)
|
||||
.setPositiveButton(R.string.ok, this)
|
||||
|
|
|
@ -2251,7 +2251,7 @@ class SettingsFragmentPresenter(
|
|||
) {
|
||||
updateOldControllerSettingsWarningVisibility(controller)
|
||||
|
||||
val groupCount = controller.groupCount
|
||||
val groupCount = controller.getGroupCount()
|
||||
for (i in 0 until groupCount) {
|
||||
val group = controller.getGroup(i)
|
||||
val groupType = group.getGroupType()
|
||||
|
@ -2322,7 +2322,7 @@ class SettingsFragmentPresenter(
|
|||
}
|
||||
|
||||
private fun updateOldControllerSettingsWarningVisibility(controller: EmulatedController) {
|
||||
val defaultDevice = controller.defaultDevice
|
||||
val defaultDevice = controller.getDefaultDevice()
|
||||
|
||||
hasOldControllerSettings = defaultDevice.startsWith("Android/") &&
|
||||
defaultDevice.endsWith("/Touchscreen")
|
||||
|
|
|
@ -725,7 +725,7 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
|
|||
"org/dolphinemu/dolphinemu/features/input/model/controlleremu/EmulatedController");
|
||||
s_emulated_controller_class =
|
||||
reinterpret_cast<jclass>(env->NewGlobalRef(emulated_controller_class));
|
||||
s_emulated_controller_pointer = env->GetFieldID(emulated_controller_class, "mPointer", "J");
|
||||
s_emulated_controller_pointer = env->GetFieldID(emulated_controller_class, "pointer", "J");
|
||||
s_emulated_controller_constructor = env->GetMethodID(emulated_controller_class, "<init>", "(J)V");
|
||||
env->DeleteLocalRef(emulated_controller_class);
|
||||
|
||||
|
|
Loading…
Reference in New Issue