Fixed bug 3464 - Fix for Android hint SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH
authorSam Lantinga
Fri, 11 Aug 2017 13:37:40 -0700
changeset 1122510e7bb76a62a
parent 11224 aca84e42a924
child 11226 7f429e943ed3
Fixed bug 3464 - Fix for Android hint SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH

ny00

According to the current documentation in SDL_hints.h, if SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH is set to "0" (or not set at all) then mouse input should lead to touch events, along with corresponding *fake* mouse events with mouse id SDL_TOUCH_MOUSEID.

However, while moving a mouse around (actually using a trackpad identified as a mouse), I get SDL mouse motion events with differing mouse ids, as follows:
- If the mouse is moved while a mouse button is pressed, the mouse id is SDL_TOUCH_MOUSEID.
- Otherwise, the mouse id for mouse motion events is 0.

I've attached sample code for reference, which includes logs of the various mouse events (the "which" field is covered).

I believe that no actual mouse event should arrive, if the hint is unset. In particular, no mouse motion event should arrive while no mouse button is pressed.

I'm going to attach a patch which resolves this, while also disabling mouse wheel motion events.
android-project/src/org/libsdl/app/SDLActivity.java
     1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Fri Aug 11 13:24:18 2017 -0700
     1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Fri Aug 11 13:37:40 2017 -0700
     1.3 @@ -1748,6 +1748,9 @@
     1.4                  return SDLActivity.handleJoystickMotionEvent(event);
     1.5  
     1.6              case InputDevice.SOURCE_MOUSE:
     1.7 +                if (!SDLActivity.mSeparateMouseAndTouch) {
     1.8 +                    break;
     1.9 +                }
    1.10                  action = event.getActionMasked();
    1.11                  switch (action) {
    1.12                      case MotionEvent.ACTION_SCROLL: