Android: default SDL_HINT_MOUSE_TOUCH_EVENTS to 1 as previous behaviour
authorSylvain Becker <sylvain.becker@gmail.com>
Fri, 05 Apr 2019 08:36:31 +0200
changeset 1269269f24f4ef99e
parent 12691 3125dc339d8d
child 12693 d311fcb8066a
Android: default SDL_HINT_MOUSE_TOUCH_EVENTS to 1 as previous behaviour
WhatsNew.txt
include/SDL_hints.h
src/events/SDL_mouse.c
     1.1 --- a/WhatsNew.txt	Thu Apr 04 20:24:22 2019 +0200
     1.2 +++ b/WhatsNew.txt	Fri Apr 05 08:36:31 2019 +0200
     1.3 @@ -8,7 +8,8 @@
     1.4  
     1.5  Android:
     1.6  * Removed SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH (replaced by SDL_HINT_MOUSE_TOUCH_EVENTS and SDL_HINT_TOUCH_MOUSE_EVENTS)
     1.7 -  (Changed old default behavior from hardware mouse triggering touch events to now not doing so (SDL_MOUSE_TOUCH_EVENTS=0) to match the default behavior of other platforms")
     1.8 +  SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH=1, should be replaced by setting both previous hints to 0.
     1.9 +  SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH=0, should be replaced by setting both previous hints to 1.
    1.10  
    1.11  
    1.12  ---------------------------------------------------------------------------
     2.1 --- a/include/SDL_hints.h	Thu Apr 04 20:24:22 2019 +0200
     2.2 +++ b/include/SDL_hints.h	Fri Apr 05 08:36:31 2019 +0200
     2.3 @@ -323,6 +323,7 @@
     2.4   *    "1"       - Mouse events will generate touch events
     2.5   *
     2.6   *  By default SDL will *not* generate touch events for mouse events
     2.7 + *  Except for Android, they are generated by default.
     2.8   */
     2.9  
    2.10  #define SDL_HINT_MOUSE_TOUCH_EVENTS    "SDL_MOUSE_TOUCH_EVENTS"
     3.1 --- a/src/events/SDL_mouse.c	Thu Apr 04 20:24:22 2019 +0200
     3.2 +++ b/src/events/SDL_mouse.c	Fri Apr 05 08:36:31 2019 +0200
     3.3 @@ -112,14 +112,22 @@
     3.4  {
     3.5      SDL_Mouse *mouse = (SDL_Mouse *)userdata;
     3.6  
     3.7 -    if (hint && (*hint == '1' || SDL_strcasecmp(hint, "true") == 0)) {
     3.8 -
     3.9 -        SDL_AddTouch(SDL_MOUSE_TOUCHID, SDL_TOUCH_DEVICE_DIRECT, "mouse_input");
    3.10 -
    3.11 +    if (hint == NULL || *hint == '\0') {
    3.12 +        /* Default */
    3.13 +#if defined(__ANDROID__)
    3.14 +        mouse->mouse_touch_events = SDL_TRUE;
    3.15 +#else
    3.16 +        mouse->mouse_touch_events = SDL_FALSE;
    3.17 +#endif
    3.18 +    } else if (*hint == '1' || SDL_strcasecmp(hint, "true") == 0) {
    3.19          mouse->mouse_touch_events = SDL_TRUE;
    3.20      } else {
    3.21          mouse->mouse_touch_events = SDL_FALSE;
    3.22      }
    3.23 +
    3.24 +    if (mouse->mouse_touch_events) {
    3.25 +        SDL_AddTouch(SDL_MOUSE_TOUCHID, SDL_TOUCH_DEVICE_DIRECT, "mouse_input");
    3.26 +    }
    3.27  }
    3.28  
    3.29  /* Public functions */