Bug 4576: remove touch/mouse duplication for Emscripten
authorSylvain Becker <sylvain.becker@gmail.com>
Tue, 02 Apr 2019 17:10:29 +0200
changeset 12680798c467b33c9
parent 12679 108f8fab6175
child 12681 450b42f2f24c
Bug 4576: remove touch/mouse duplication for Emscripten
src/video/emscripten/SDL_emscriptenevents.c
src/video/emscripten/SDL_emscriptenvideo.h
     1.1 --- a/src/video/emscripten/SDL_emscriptenevents.c	Tue Apr 02 17:07:54 2019 +0200
     1.2 +++ b/src/video/emscripten/SDL_emscriptenevents.c	Tue Apr 02 17:10:29 2019 +0200
     1.3 @@ -446,7 +446,6 @@
     1.4      for (i = 0; i < touchEvent->numTouches; i++) {
     1.5          SDL_FingerID id;
     1.6          float x, y;
     1.7 -        int mx, my;
     1.8  
     1.9          if (!touchEvent->touches[i].isChanged)
    1.10              continue;
    1.11 @@ -455,16 +454,7 @@
    1.12          x = touchEvent->touches[i].canvasX / client_w;
    1.13          y = touchEvent->touches[i].canvasY / client_h;
    1.14  
    1.15 -        mx = x * window_data->window->w;
    1.16 -        my = y * window_data->window->h;
    1.17 -
    1.18          if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) {
    1.19 -            if (!window_data->finger_touching) {
    1.20 -                window_data->finger_touching = SDL_TRUE;
    1.21 -                window_data->first_finger = id;
    1.22 -                SDL_SendMouseMotion(window_data->window, SDL_TOUCH_MOUSEID, 0, mx, my);
    1.23 -                SDL_SendMouseButton(window_data->window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
    1.24 -            }
    1.25              SDL_SendTouch(deviceId, id, SDL_TRUE, x, y, 1.0f);
    1.26  
    1.27              /* disable browser scrolling/pinch-to-zoom if app handles touch events */
    1.28 @@ -472,15 +462,8 @@
    1.29                  preventDefault = 1;
    1.30              }
    1.31          } else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) {
    1.32 -            if ((window_data->finger_touching) && (window_data->first_finger == id)) {
    1.33 -                SDL_SendMouseMotion(window_data->window, SDL_TOUCH_MOUSEID, 0, mx, my);
    1.34 -            }
    1.35              SDL_SendTouchMotion(deviceId, id, x, y, 1.0f);
    1.36          } else {
    1.37 -            if ((window_data->finger_touching) && (window_data->first_finger == id)) {
    1.38 -                SDL_SendMouseButton(window_data->window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
    1.39 -                window_data->finger_touching = SDL_FALSE;
    1.40 -            }
    1.41              SDL_SendTouch(deviceId, id, SDL_FALSE, x, y, 1.0f);
    1.42  
    1.43              /* block browser's simulated mousedown/mouseup on touchscreen devices */
     2.1 --- a/src/video/emscripten/SDL_emscriptenvideo.h	Tue Apr 02 17:07:54 2019 +0200
     2.2 +++ b/src/video/emscripten/SDL_emscriptenvideo.h	Tue Apr 02 17:10:29 2019 +0200
     2.3 @@ -47,9 +47,6 @@
     2.4      int requested_fullscreen_mode;
     2.5      SDL_bool fullscreen_resize;
     2.6  
     2.7 -    SDL_bool finger_touching;  /* for mapping touch events to mice */
     2.8 -    SDL_FingerID first_finger;
     2.9 -
    2.10      SDL_bool has_pointer_lock;
    2.11  } SDL_WindowData;
    2.12