src/video/emscripten/SDL_emscriptenevents.c
changeset 10284 c09f06c4e8c8
parent 9998 f67cf37e9cd4
child 10316 76bcc22dc5e4
     1.1 --- a/src/video/emscripten/SDL_emscriptenevents.c	Fri Aug 12 00:03:58 2016 -0400
     1.2 +++ b/src/video/emscripten/SDL_emscriptenevents.c	Fri Aug 12 19:59:00 2016 -0400
     1.3 @@ -391,11 +391,24 @@
     1.4          x = touchEvent->touches[i].canvasX / (float)window_data->windowed_width;
     1.5          y = touchEvent->touches[i].canvasY / (float)window_data->windowed_height;
     1.6  
     1.7 -        if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) {
     1.8 +        if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) {
     1.9 +            if (!window_data->finger_touching) {
    1.10 +                window_data->finger_touching = SDL_TRUE;
    1.11 +                window_data->first_finger = id;
    1.12 +                SDL_SendMouseMotion(window_data->window, SDL_TOUCH_MOUSEID, 0, x, y);
    1.13 +                SDL_SendMouseButton(window_data->window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
    1.14 +            }
    1.15 +            SDL_SendTouch(deviceId, id, SDL_TRUE, x, y, 1.0f);
    1.16 +        } else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) {
    1.17 +            if ((window_data->finger_touching) && (window_data->first_finger == id)) {
    1.18 +                SDL_SendMouseMotion(window_data->window, SDL_TOUCH_MOUSEID, 0, x, y);
    1.19 +            }
    1.20              SDL_SendTouchMotion(deviceId, id, x, y, 1.0f);
    1.21 -        } else if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) {
    1.22 -            SDL_SendTouch(deviceId, id, SDL_TRUE, x, y, 1.0f);
    1.23          } else {
    1.24 +            if ((window_data->finger_touching) && (window_data->first_finger == id)) {
    1.25 +                SDL_SendMouseButton(window_data->window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
    1.26 +                window_data->finger_touching = SDL_FALSE;
    1.27 +            }
    1.28              SDL_SendTouch(deviceId, id, SDL_FALSE, x, y, 1.0f);
    1.29          }
    1.30      }