src/video/emscripten/SDL_emscriptenevents.c
changeset 11024 32026cc5015a
parent 11003 ced20e690a19
child 11025 2215b66794ba
     1.1 --- a/src/video/emscripten/SDL_emscriptenevents.c	Wed May 24 01:28:03 2017 -0400
     1.2 +++ b/src/video/emscripten/SDL_emscriptenevents.c	Wed May 24 14:04:25 2017 +0100
     1.3 @@ -437,6 +437,7 @@
     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 @@ -445,11 +446,14 @@
    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, x, y);
    1.23 +                SDL_SendMouseMotion(window_data->window, SDL_TOUCH_MOUSEID, 0, mx, my);
    1.24                  SDL_SendMouseButton(window_data->window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
    1.25              }
    1.26              SDL_SendTouch(deviceId, id, SDL_TRUE, x, y, 1.0f);
    1.27 @@ -459,7 +463,7 @@
    1.28              }
    1.29          } else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) {
    1.30              if ((window_data->finger_touching) && (window_data->first_finger == id)) {
    1.31 -                SDL_SendMouseMotion(window_data->window, SDL_TOUCH_MOUSEID, 0, x, y);
    1.32 +                SDL_SendMouseMotion(window_data->window, SDL_TOUCH_MOUSEID, 0, mx, my);
    1.33              }
    1.34              SDL_SendTouchMotion(deviceId, id, x, y, 1.0f);
    1.35