diff --git a/src/android/app/src/main/java/org/nxemu/SettingsIdentifiers.kt b/src/android/app/src/main/java/org/nxemu/SettingsIdentifiers.kt index 918c5829..69ff609b 100644 --- a/src/android/app/src/main/java/org/nxemu/SettingsIdentifiers.kt +++ b/src/android/app/src/main/java/org/nxemu/SettingsIdentifiers.kt @@ -3,10 +3,6 @@ package org.nxemu object NXUISetting { const val GameDirectories = "nxui:GameDirectories" const val ShowInputOverlay = "nxui:ShowInputOverlay" - const val JoystickRelCenter = "nxui:JoystickRelCenter" - const val DpadSlide = "nxui:DpadSlide" - const val HapticFeedback = "nxui:HapticFeedback" - const val Touchscreen = "nxui:Touchscreen" const val OverlayScale = "nxui:OverlayScale" const val OverlayOpacity = "nxui:OverlayOpacity" const val OverlayControlData = "nxui:OverlayControlData" diff --git a/src/android/app/src/main/java/org/nxemu/features/input/NativeInput.kt b/src/android/app/src/main/java/org/nxemu/features/input/NativeInput.kt index cfc4e056..9d78b8bf 100644 --- a/src/android/app/src/main/java/org/nxemu/features/input/NativeInput.kt +++ b/src/android/app/src/main/java/org/nxemu/features/input/NativeInput.kt @@ -22,11 +22,6 @@ object NativeInput { external fun onGamePadButtonEvent(guid: String, port: Int, buttonId: Int, action: Int) external fun onGamePadAxisEvent(guid: String, port: Int, axis: Int, value: Float) - external fun onTouchPressed(fingerId: Int, xAxis: Float, yAxis: Float) - - external fun onTouchMoved(fingerId: Int, xAxis: Float, yAxis: Float) - - external fun onTouchReleased(fingerId: Int) fun onOverlayButtonEvent(port: Int, button: NativeButton, action: Int) = onOverlayButtonEventImpl(port, button.int, action) diff --git a/src/android/app/src/main/java/org/nxemu/overlay/InputOverlay.kt b/src/android/app/src/main/java/org/nxemu/overlay/InputOverlay.kt index 49da299d..2f62110b 100644 --- a/src/android/app/src/main/java/org/nxemu/overlay/InputOverlay.kt +++ b/src/android/app/src/main/java/org/nxemu/overlay/InputOverlay.kt @@ -119,7 +119,7 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : } for (dpad in overlayDpads) { - if (!dpad.updateStatus(event, NativeLibrary.getSettingBool(NXUISetting.DpadSlide))) { + if (!dpad.updateStatus(event, true)) { continue } NativeInput.onOverlayButtonEvent( @@ -169,75 +169,21 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : invalidate() } - if (!NativeLibrary.getSettingBool(NXUISetting.Touchscreen)) { - return true - } - - val pointerIndex = event.actionIndex - val xPosition = event.getX(pointerIndex).toInt() - val yPosition = event.getY(pointerIndex).toInt() - val pointerId = event.getPointerId(pointerIndex) - val motionEvent = event.action and MotionEvent.ACTION_MASK - val isActionDown = - motionEvent == MotionEvent.ACTION_DOWN || motionEvent == MotionEvent.ACTION_POINTER_DOWN - val isActionMove = motionEvent == MotionEvent.ACTION_MOVE - val isActionUp = - motionEvent == MotionEvent.ACTION_UP || motionEvent == MotionEvent.ACTION_POINTER_UP - - if (isActionDown && !isTouchInputConsumed(pointerId)) { - NativeInput.onTouchPressed(pointerId, xPosition.toFloat(), yPosition.toFloat()) - } - - if (isActionMove) { - for (i in 0 until event.pointerCount) { - val fingerId = event.getPointerId(i) - if (isTouchInputConsumed(fingerId)) { - continue - } - NativeInput.onTouchMoved(fingerId, event.getX(i), event.getY(i)) - } - } - - if (isActionUp && !isTouchInputConsumed(pointerId)) { - NativeInput.onTouchReleased(pointerId) - } - return true } private fun playHaptics(event: MotionEvent) { - if (NativeLibrary.getSettingBool(NXUISetting.HapticFeedback)) { - when (event.actionMasked) { - MotionEvent.ACTION_DOWN, - MotionEvent.ACTION_POINTER_DOWN -> - performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY) + when (event.actionMasked) { + MotionEvent.ACTION_DOWN, + MotionEvent.ACTION_POINTER_DOWN -> + performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY) - MotionEvent.ACTION_UP, - MotionEvent.ACTION_POINTER_UP -> - performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY_RELEASE) - } + MotionEvent.ACTION_UP, + MotionEvent.ACTION_POINTER_UP -> + performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY_RELEASE) } } - private fun isTouchInputConsumed(track_id: Int): Boolean { - for (button in overlayButtons) { - if (button.trackId == track_id) { - return true - } - } - for (dpad in overlayDpads) { - if (dpad.trackId == track_id) { - return true - } - } - for (joystick in overlayJoysticks) { - if (joystick.trackId == track_id) { - return true - } - } - return false - } - private fun onTouchWhileEditing(event: MotionEvent): Boolean { val pointerIndex = event.actionIndex val fingerPositionX = event.getX(pointerIndex).toInt() diff --git a/src/android/app/src/main/java/org/nxemu/overlay/InputOverlayDrawableJoystick.kt b/src/android/app/src/main/java/org/nxemu/overlay/InputOverlayDrawableJoystick.kt index bc7a288f..551e264d 100644 --- a/src/android/app/src/main/java/org/nxemu/overlay/InputOverlayDrawableJoystick.kt +++ b/src/android/app/src/main/java/org/nxemu/overlay/InputOverlayDrawableJoystick.kt @@ -13,8 +13,6 @@ import kotlin.math.atan2 import kotlin.math.cos import kotlin.math.sin import kotlin.math.sqrt -import org.nxemu.NXUISetting -import org.nxemu.NativeLibrary import org.nxemu.features.input.NativeInput.ButtonState import org.nxemu.features.input.model.NativeAnalog import org.nxemu.features.input.model.NativeButton @@ -127,12 +125,10 @@ class InputOverlayDrawableJoystick( pressedState = true outerBitmap.alpha = 0 boundsBoxBitmap.alpha = opacity - if (NativeLibrary.getSettingBool(NXUISetting.JoystickRelCenter)) { - virtBounds.offset( - xPosition - virtBounds.centerX(), - yPosition - virtBounds.centerY() - ) - } + virtBounds.offset( + xPosition - virtBounds.centerX(), + yPosition - virtBounds.centerY() + ) boundsBoxBitmap.bounds = virtBounds trackId = pointerId } diff --git a/src/android/app/src/main/jni/native_input.cpp b/src/android/app/src/main/jni/native_input.cpp index 9dbdce2c..c8508c58 100644 --- a/src/android/app/src/main/jni/native_input.cpp +++ b/src/android/app/src/main/jni/native_input.cpp @@ -282,8 +282,7 @@ JNIEXPORT jstring JNICALL Java_org_nxemu_features_input_NativeInput_getNextInput return result; } -JNIEXPORT void JNICALL Java_org_nxemu_features_input_NativeInput_stopMapping(JNIEnv * /*env*/, - jobject /*obj*/) +JNIEXPORT void JNICALL Java_org_nxemu_features_input_NativeInput_stopMapping(JNIEnv * /*env*/, jobject /*obj*/) { IOperatingSystem * os = CurrentOS(); if (os != nullptr) @@ -368,8 +367,7 @@ JNIEXPORT jstring JNICALL Java_org_nxemu_features_input_NativeInput_getButtonPar return result; } -JNIEXPORT void JNICALL Java_org_nxemu_features_input_NativeInput_setButtonParamImpl( - JNIEnv * env, jobject /*obj*/, jint j_player_index, jint j_button_id, jstring j_param) +JNIEXPORT void JNICALL Java_org_nxemu_features_input_NativeInput_setButtonParamImpl(JNIEnv * env, jobject /*obj*/, jint j_player_index, jint j_button_id, jstring j_param) { SystemModules * modules = EmulationSession::GetInstance().Modules(); if (modules == nullptr || !IsPlayerIndex(j_player_index) || j_param == nullptr) @@ -379,8 +377,7 @@ JNIEXPORT void JNICALL Java_org_nxemu_features_input_NativeInput_setButtonParamI const char * serialized = env->GetStringUTFChars(j_param, nullptr); IParamPackageImpl pkg{Common::ParamPackage{serialized}}; env->ReleaseStringUTFChars(j_param, serialized); - IEmulatedController & controller = - ConfiguredController(modules->Modules().OperatingSystem(), static_cast(j_player_index)); + IEmulatedController & controller = ConfiguredController(modules->Modules().OperatingSystem(), static_cast(j_player_index)); controller.SetButtonParam(static_cast(j_button_id), pkg); controller.SaveCurrentConfig(); modules->FlushSettings(); @@ -403,8 +400,7 @@ JNIEXPORT jstring JNICALL Java_org_nxemu_features_input_NativeInput_getStickPara return result; } -JNIEXPORT void JNICALL Java_org_nxemu_features_input_NativeInput_setStickParamImpl( - JNIEnv * env, jobject /*obj*/, jint j_player_index, jint j_stick_id, jstring j_param) +JNIEXPORT void JNICALL Java_org_nxemu_features_input_NativeInput_setStickParamImpl(JNIEnv * env, jobject /*obj*/, jint j_player_index, jint j_stick_id, jstring j_param) { SystemModules * modules = EmulationSession::GetInstance().Modules(); if (modules == nullptr || !IsPlayerIndex(j_player_index) || j_param == nullptr) @@ -414,8 +410,7 @@ JNIEXPORT void JNICALL Java_org_nxemu_features_input_NativeInput_setStickParamIm const char * serialized = env->GetStringUTFChars(j_param, nullptr); IParamPackageImpl pkg{Common::ParamPackage{serialized}}; env->ReleaseStringUTFChars(j_param, serialized); - IEmulatedController & controller = - ConfiguredController(modules->Modules().OperatingSystem(), static_cast(j_player_index)); + IEmulatedController & controller = ConfiguredController(modules->Modules().OperatingSystem(), static_cast(j_player_index)); controller.SetStickParam(static_cast(j_stick_id), pkg); controller.SaveCurrentConfig(); modules->FlushSettings(); @@ -450,8 +445,7 @@ JNIEXPORT jintArray JNICALL Java_org_nxemu_features_input_NativeInput_getSupport return result; } -JNIEXPORT jint JNICALL Java_org_nxemu_features_input_NativeInput_getStyleIndexImpl( - JNIEnv * /*env*/, jobject /*obj*/, jint j_player_index) +JNIEXPORT jint JNICALL Java_org_nxemu_features_input_NativeInput_getStyleIndexImpl(JNIEnv * /*env*/, jobject /*obj*/, jint j_player_index) { return EmulationSession::GetInstance().GetStyleIndex(j_player_index); }