Android: Convert ControlReference to Kotlin
This commit is contained in:
parent
7c79ff0100
commit
4ce069cf4f
|
@ -1,39 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.dolphinemu.dolphinemu.features.input.model.controlleremu;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a C++ ControlReference.
|
||||
*
|
||||
* 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 ControlReference
|
||||
{
|
||||
@Keep
|
||||
private final long mPointer;
|
||||
|
||||
@Keep
|
||||
private ControlReference(long pointer)
|
||||
{
|
||||
mPointer = pointer;
|
||||
}
|
||||
|
||||
public native double getState();
|
||||
|
||||
public native String getExpression();
|
||||
|
||||
/**
|
||||
* Sets the expression for this control reference.
|
||||
*
|
||||
* @param expr The new expression
|
||||
* @return null on success, a human-readable error on failure
|
||||
*/
|
||||
@Nullable
|
||||
public native String setExpression(String expr);
|
||||
|
||||
public native boolean isInput();
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.dolphinemu.dolphinemu.features.input.model.controlleremu
|
||||
|
||||
import androidx.annotation.Keep
|
||||
|
||||
/**
|
||||
* Represents a C++ ControlReference.
|
||||
*
|
||||
* 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 ControlReference private constructor(private val pointer: Long) {
|
||||
external fun getState(): Double
|
||||
|
||||
external fun getExpression(): String
|
||||
|
||||
/**
|
||||
* Sets the expression for this control reference.
|
||||
*
|
||||
* @param expr The new expression
|
||||
* @return null on success, a human-readable error on failure
|
||||
*/
|
||||
external fun setExpression(expr: String): String?
|
||||
|
||||
external fun isInput(): Boolean
|
||||
}
|
|
@ -717,7 +717,7 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
|
|||
const jclass control_reference_class = env->FindClass(
|
||||
"org/dolphinemu/dolphinemu/features/input/model/controlleremu/ControlReference");
|
||||
s_control_reference_class = reinterpret_cast<jclass>(env->NewGlobalRef(control_reference_class));
|
||||
s_control_reference_pointer = env->GetFieldID(control_reference_class, "mPointer", "J");
|
||||
s_control_reference_pointer = env->GetFieldID(control_reference_class, "pointer", "J");
|
||||
s_control_reference_constructor = env->GetMethodID(control_reference_class, "<init>", "(J)V");
|
||||
env->DeleteLocalRef(control_reference_class);
|
||||
|
||||
|
|
Loading…
Reference in New Issue