From fdfc4cbe40e66a33e523687d2b19d476cdd4be8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 31 Dec 2022 21:36:16 +0100 Subject: [PATCH] Android: Remove return value from touch event functions --- Common/System/NativeApp.h | 2 +- Common/VR/PPSSPPVR.cpp | 8 ++++---- Common/VR/PPSSPPVR.h | 2 +- UI/NativeApp.cpp | 20 +++++++++---------- android/jni/app-android.cpp | 5 ++--- android/src/org/ppsspp/ppsspp/NativeApp.java | 2 +- .../src/org/ppsspp/ppsspp/NativeGLView.java | 5 ++--- .../org/ppsspp/ppsspp/NativeSurfaceView.java | 5 ++--- 8 files changed, 23 insertions(+), 26 deletions(-) diff --git a/Common/System/NativeApp.h b/Common/System/NativeApp.h index d911fd9076..e484d8207e 100644 --- a/Common/System/NativeApp.h +++ b/Common/System/NativeApp.h @@ -63,7 +63,7 @@ void NativeUpdate(); // Useful for triggering audio events, saving a few ms. // If you don't care about touch latency, just do a no-op implementation of this. // time is not yet implemented. finger can be from 0 to 7, inclusive. -bool NativeTouch(const TouchInput &touch); +void NativeTouch(const TouchInput &touch); bool NativeKey(const KeyInput &key); bool NativeAxis(const AxisInput &axis); diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 67360d2335..47e2d78bf7 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -46,9 +46,9 @@ static bool vrFlatGame = false; static float vrMatrix[VR_MATRIX_COUNT][16]; static bool vrMirroring[VR_MIRRORING_COUNT]; -static bool(*NativeAxis)(const AxisInput &axis); -static bool(*NativeKey)(const KeyInput &key); -static bool(*NativeTouch)(const TouchInput &touch); +static bool (*NativeAxis)(const AxisInput &axis); +static bool (*NativeKey)(const KeyInput &key); +static void (*NativeTouch)(const TouchInput &touch); /* ================================================================================ @@ -189,7 +189,7 @@ void GetVRResolutionPerEye(int* width, int* height) { } } -void SetVRCallbacks(bool(*axis)(const AxisInput &axis), bool(*key)(const KeyInput &key), bool(*touch)(const TouchInput &touch)) { +void SetVRCallbacks(bool(*axis)(const AxisInput &axis), bool(*key)(const KeyInput &key), void (*touch)(const TouchInput &touch)) { NativeAxis = axis; NativeKey = key; NativeTouch = touch; diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index 009726a948..eb83c118fe 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -29,7 +29,7 @@ bool IsVREnabled(); void InitVROnAndroid(void* vm, void* activity, const char* system, int version, const char* name); void EnterVR(bool firstStart, void* vulkanContext); void GetVRResolutionPerEye(int* width, int* height); -void SetVRCallbacks(bool(*axis)(const AxisInput &axis), bool(*key)(const KeyInput &key), bool(*touch)(const TouchInput &touch)); +void SetVRCallbacks(bool(*axis)(const AxisInput &axis), bool(*key)(const KeyInput &key), void(*touch)(const TouchInput &touch)); // VR input integration void SetVRAppMode(VRAppMode mode); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index a2215befdc..e20e1424b4 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1315,17 +1315,17 @@ bool NativeIsAtTopLevel() { } } -bool NativeTouch(const TouchInput &touch) { - if (screenManager) { - // Brute force prevent NaNs from getting into the UI system - if (my_isnan(touch.x) || my_isnan(touch.y)) { - return false; - } - screenManager->touch(touch); - return true; - } else { - return false; +void NativeTouch(const TouchInput &touch) { + if (!screenManager) { + return; } + + // Brute force prevent NaNs from getting into the UI system. + // Don't think this is actually necessary in practice. + if (my_isnan(touch.x) || my_isnan(touch.y)) { + return; + } + screenManager->touch(touch); } bool NativeKey(const KeyInput &key) { diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 855ce4d51e..b572a4e0ca 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -1113,7 +1113,7 @@ PermissionStatus System_GetPermissionStatus(SystemPermission permission) { } } -extern "C" jboolean JNICALL Java_org_ppsspp_ppsspp_NativeApp_touch +extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_touch (JNIEnv *, jclass, float x, float y, int code, int pointerId) { float scaledX = x * g_dpi_scale_x; @@ -1125,8 +1125,7 @@ extern "C" jboolean JNICALL Java_org_ppsspp_ppsspp_NativeApp_touch touch.y = scaledY; touch.flags = code; - bool retval = NativeTouch(touch); - return retval; + NativeTouch(touch); } extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_keyDown(JNIEnv *, jclass, jint deviceId, jint key, jboolean isRepeat) { diff --git a/android/src/org/ppsspp/ppsspp/NativeApp.java b/android/src/org/ppsspp/ppsspp/NativeApp.java index 2fb7fa45a4..22d3ebf45e 100644 --- a/android/src/org/ppsspp/ppsspp/NativeApp.java +++ b/android/src/org/ppsspp/ppsspp/NativeApp.java @@ -46,7 +46,7 @@ public class NativeApp { public static native boolean mouseWheelEvent(float x, float y); // Sensor/input data. These are asynchronous, beware! - public static native boolean touch(float x, float y, int data, int pointerId); + public static native void touch(float x, float y, int data, int pointerId); public static native boolean accelerometer(float x, float y, float z); diff --git a/android/src/org/ppsspp/ppsspp/NativeGLView.java b/android/src/org/ppsspp/ppsspp/NativeGLView.java index d899fa5ce4..6dbf91974d 100644 --- a/android/src/org/ppsspp/ppsspp/NativeGLView.java +++ b/android/src/org/ppsspp/ppsspp/NativeGLView.java @@ -62,7 +62,6 @@ public class NativeGLView extends GLSurfaceView implements SensorEventListener, public boolean onTouchEvent(final MotionEvent ev) { boolean canReadToolType = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH; - int numTouchesHandled = 0; for (int i = 0; i < ev.getPointerCount(); i++) { int pid = ev.getPointerId(i); int code = 0; @@ -94,10 +93,10 @@ public class NativeGLView extends GLSurfaceView implements SensorEventListener, code |= tool << 10; // We use the Android tool type codes } // Can't use || due to short circuit evaluation - numTouchesHandled += NativeApp.touch(ev.getX(i), ev.getY(i), code, pid) ? 1 : 0; + NativeApp.touch(ev.getX(i), ev.getY(i), code, pid); } } - return numTouchesHandled > 0; + return true; } // Sensor management diff --git a/android/src/org/ppsspp/ppsspp/NativeSurfaceView.java b/android/src/org/ppsspp/ppsspp/NativeSurfaceView.java index 01686be52f..fa70f96cce 100644 --- a/android/src/org/ppsspp/ppsspp/NativeSurfaceView.java +++ b/android/src/org/ppsspp/ppsspp/NativeSurfaceView.java @@ -63,7 +63,6 @@ public class NativeSurfaceView extends SurfaceView implements SensorEventListene public boolean onTouchEvent(final MotionEvent ev) { boolean canReadToolType = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH; - int numTouchesHandled = 0; for (int i = 0; i < ev.getPointerCount(); i++) { int pid = ev.getPointerId(i); int code = 0; @@ -95,10 +94,10 @@ public class NativeSurfaceView extends SurfaceView implements SensorEventListene code |= tool << 10; // We use the Android tool type codes } // Can't use || due to short circuit evaluation - numTouchesHandled += NativeApp.touch(ev.getX(i), ev.getY(i), code, pid) ? 1 : 0; + NativeApp.touch(ev.getX(i), ev.getY(i), code, pid); } } - return numTouchesHandled > 0; + return true; } // Sensor management