Android: remove SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH java layer runs as if separate mouse and touch was 1, Use SDL_HINT_MOUSE_TOUCH_EVENTS and SDL_HINT_TOUCH_MOUSE_EVENTS for generating synthetic touch/mouse events
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
index caee004..0e3580c 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
@@ -73,10 +73,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
/** If shared libraries (e.g. SDL or the native application) could not be loaded. */
public static boolean mBrokenLibraries;
- // If we want to separate mouse and touch events.
- // This is only toggled in native code when a hint is set!
- public static boolean mSeparateMouseAndTouch;
-
// Main components
protected static SDLActivity mSingleton;
protected static SDLSurface mSurface;
@@ -1772,8 +1768,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
// 12290 = Samsung DeX mode desktop mouse
// 12290 = 0x3002 = 0x2002 | 0x1002 = SOURCE_MOUSE | SOURCE_TOUCHSCREEN
// 0x2 = SOURCE_CLASS_POINTER
- if ((event.getSource() == InputDevice.SOURCE_MOUSE || event.getSource() == (InputDevice.SOURCE_MOUSE | InputDevice.SOURCE_TOUCHSCREEN))
- && SDLActivity.mSeparateMouseAndTouch) {
+ if (event.getSource() == InputDevice.SOURCE_MOUSE || event.getSource() == (InputDevice.SOURCE_MOUSE | InputDevice.SOURCE_TOUCHSCREEN)) {
try {
mouseButton = (Integer) event.getClass().getMethod("getButtonState").invoke(event);
} catch(Exception e) {
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
index d3329c9..a81e97b 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
@@ -555,9 +555,6 @@ class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener {
return SDLControllerManager.handleJoystickMotionEvent(event);
case InputDevice.SOURCE_MOUSE:
- if (!SDLActivity.mSeparateMouseAndTouch) {
- break;
- }
action = event.getActionMasked();
switch (action) {
case MotionEvent.ACTION_SCROLL:
@@ -624,14 +621,12 @@ class SDLGenericMotionListener_API24 extends SDLGenericMotionListener_API12 {
// Handle relative mouse mode
if (mRelativeModeEnabled) {
if (event.getSource() == InputDevice.SOURCE_MOUSE) {
- if (SDLActivity.mSeparateMouseAndTouch) {
- int action = event.getActionMasked();
- if (action == MotionEvent.ACTION_HOVER_MOVE) {
- float x = event.getAxisValue(MotionEvent.AXIS_RELATIVE_X);
- float y = event.getAxisValue(MotionEvent.AXIS_RELATIVE_Y);
- SDLActivity.onNativeMouse(0, action, x, y, true);
- return true;
- }
+ int action = event.getActionMasked();
+ if (action == MotionEvent.ACTION_HOVER_MOVE) {
+ float x = event.getAxisValue(MotionEvent.AXIS_RELATIVE_X);
+ float y = event.getAxisValue(MotionEvent.AXIS_RELATIVE_Y);
+ SDLActivity.onNativeMouse(0, action, x, y, true);
+ return true;
}
}
}
@@ -696,10 +691,6 @@ class SDLGenericMotionListener_API26 extends SDLGenericMotionListener_API24 {
case InputDevice.SOURCE_MOUSE:
// DeX desktop mouse cursor is a separate non-standard input type.
case InputDevice.SOURCE_MOUSE | InputDevice.SOURCE_TOUCHSCREEN:
- if (!SDLActivity.mSeparateMouseAndTouch) {
- break;
- }
-
action = event.getActionMasked();
switch (action) {
case MotionEvent.ACTION_SCROLL:
@@ -720,9 +711,6 @@ class SDLGenericMotionListener_API26 extends SDLGenericMotionListener_API24 {
break;
case InputDevice.SOURCE_MOUSE_RELATIVE:
- if (!SDLActivity.mSeparateMouseAndTouch) {
- break;
- }
action = event.getActionMasked();
switch (action) {
case MotionEvent.ACTION_SCROLL:
diff --git a/include/SDL_hints.h b/include/SDL_hints.h
index 90d0e81..8cbcc3e 100644
--- a/include/SDL_hints.h
+++ b/include/SDL_hints.h
@@ -869,19 +869,7 @@ extern "C" {
*/
#define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING"
- /**
- * \brief A variable to control whether mouse and touch events are to be treated together or separately
- *
- * The variable can be set to the following values:
- * "0" - Mouse events will be handled as touch events, and touch will raise fake mouse
- * events. This is the behaviour of SDL <= 2.0.3. (default)
- * "1" - Mouse events will be handled separately from pure touch events.
- *
- * The value of this hint is used at runtime, so it can be changed at any time.
- */
-#define SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH "SDL_ANDROID_SEPARATE_MOUSE_AND_TOUCH"
-
- /**
+/**
* \brief A variable to control whether we trap the Android back button to handle it manually.
* This is necessary for the right mouse button to work on some Android devices, or
* to be able to trap the back button for use in your code reliably. If set to true,
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index fe365be..2368bb1 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -280,9 +280,6 @@ static jmethodID midPollHapticDevices;
static jmethodID midHapticRun;
static jmethodID midHapticStop;
-/* static fields */
-static jfieldID fidSeparateMouseAndTouch;
-
/* Accelerometer data storage */
static SDL_DisplayOrientation displayOrientation;
static float fLastAccelerometer[3];
@@ -537,12 +534,6 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
__android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLActivity.java?");
}
- fidSeparateMouseAndTouch = (*env)->GetStaticFieldID(env, mActivityClass, "mSeparateMouseAndTouch", "Z");
-
- if (!fidSeparateMouseAndTouch) {
- __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java static fields, do you have the latest version of SDLActivity.java?");
- }
-
checkJNIReady();
}
@@ -2206,13 +2197,6 @@ void Android_JNI_InitTouch() {
(*env)->CallStaticVoidMethod(env, mActivityClass, midInitTouch);
}
-/* sets the mSeparateMouseAndTouch field */
-void Android_JNI_SetSeparateMouseAndTouch(SDL_bool new_value)
-{
- JNIEnv *env = Android_JNI_GetEnv();
- (*env)->SetStaticBooleanField(env, mActivityClass, fidSeparateMouseAndTouch, new_value ? JNI_TRUE : JNI_FALSE);
-}
-
void Android_JNI_PollInputDevices(void)
{
JNIEnv *env = Android_JNI_GetEnv();
diff --git a/src/core/android/SDL_android.h b/src/core/android/SDL_android.h
index 8373786..52332fb 100644
--- a/src/core/android/SDL_android.h
+++ b/src/core/android/SDL_android.h
@@ -96,7 +96,6 @@ void Android_JNI_SuspendScreenSaver(SDL_bool suspend);
/* Touch support */
void Android_JNI_InitTouch(void);
-void Android_JNI_SetSeparateMouseAndTouch(SDL_bool new_value);
/* Threads */
#include <jni.h>
diff --git a/src/video/android/SDL_androidtouch.c b/src/video/android/SDL_androidtouch.c
index 0e48100..1320326 100644
--- a/src/video/android/SDL_androidtouch.c
+++ b/src/video/android/SDL_androidtouch.c
@@ -40,28 +40,15 @@
#define ACTION_POINTER_DOWN 5
#define ACTION_POINTER_UP 6
-static void SDLCALL
-SeparateEventsHintWatcher(void *userdata, const char *name,
- const char *oldValue, const char *newValue)
-{
- SDL_bool separate_mouse_and_touch = (newValue && (SDL_strcmp(newValue, "1") == 0));
-
- Android_JNI_SetSeparateMouseAndTouch(separate_mouse_and_touch);
-}
-
void Android_InitTouch(void)
{
- SDL_AddHintCallback(SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH,
- SeparateEventsHintWatcher, NULL);
-
/* Add all touch devices */
Android_JNI_InitTouch();
}
void Android_QuitTouch(void)
{
- SDL_DelHintCallback(SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH,
- SeparateEventsHintWatcher, NULL);
+ return;
}
void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p)