src/events/SDL_mouse.c
changeset 11182 27ed95cf83d6
parent 10780 4ea5472ed455
child 11258 9fc2e83124ba
     1.1 --- a/src/events/SDL_mouse.c	Wed Aug 02 17:45:15 2017 -0700
     1.2 +++ b/src/events/SDL_mouse.c	Thu Aug 03 09:48:44 2017 -0700
     1.3 @@ -64,6 +64,18 @@
     1.4      }
     1.5  }
     1.6  
     1.7 +static void
     1.8 +SDL_TouchMouseEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
     1.9 +{
    1.10 +    SDL_Mouse *mouse = (SDL_Mouse *)userdata;
    1.11 +
    1.12 +    if (hint && (*hint == '0' || SDL_strcasecmp(hint, "false") == 0)) {
    1.13 +        mouse->touch_mouse_events = SDL_FALSE;
    1.14 +    } else {
    1.15 +        mouse->touch_mouse_events = SDL_TRUE;
    1.16 +    }
    1.17 +}
    1.18 +
    1.19  /* Public functions */
    1.20  int
    1.21  SDL_MouseInit(void)
    1.22 @@ -76,6 +88,9 @@
    1.23      SDL_AddHintCallback(SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE,
    1.24                          SDL_MouseRelativeSpeedScaleChanged, mouse);
    1.25  
    1.26 +    SDL_AddHintCallback(SDL_HINT_TOUCH_MOUSE_EVENTS,
    1.27 +                        SDL_TouchMouseEventsChanged, mouse);
    1.28 +
    1.29      mouse->cursor_shown = SDL_TRUE;
    1.30  
    1.31      return (0);
    1.32 @@ -252,6 +267,10 @@
    1.33      int xrel;
    1.34      int yrel;
    1.35  
    1.36 +    if (mouseID == SDL_TOUCH_MOUSEID && !mouse->touch_mouse_events) {
    1.37 +        return 0;
    1.38 +    }
    1.39 +
    1.40      if (mouse->relative_mode_warp) {
    1.41          int center_x = 0, center_y = 0;
    1.42          SDL_GetWindowSize(window, &center_x, &center_y);
    1.43 @@ -384,6 +403,10 @@
    1.44      Uint32 type;
    1.45      Uint32 buttonstate = mouse->buttonstate;
    1.46  
    1.47 +    if (mouseID == SDL_TOUCH_MOUSEID && !mouse->touch_mouse_events) {
    1.48 +        return 0;
    1.49 +    }
    1.50 +
    1.51      /* Figure out which event to perform */
    1.52      switch (state) {
    1.53      case SDL_PRESSED: