[Commits] SDL: Emscripten: fixed incorrect conversion of touch motion even...

libsdl.org revision control commits-owner at libsdl.org
Wed May 24 06:06:49 PDT 2017


details:   https://hg.libsdl.org/SDL/rev/32026cc5015a
changeset: 11024:32026cc5015a
user:      Patrick Monaghan <pat at patsown.com>
date:      Wed May 24 14:04:25 2017 +0100
description:
Emscripten: fixed incorrect conversion of touch motion events to mouse motion events

diffstat:

 src/video/emscripten/SDL_emscriptenevents.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (36 lines):

diff -r 0b4a3c824d38 -r 32026cc5015a src/video/emscripten/SDL_emscriptenevents.c
--- a/src/video/emscripten/SDL_emscriptenevents.c	Wed May 24 01:28:03 2017 -0400
+++ b/src/video/emscripten/SDL_emscriptenevents.c	Wed May 24 14:04:25 2017 +0100
@@ -437,6 +437,7 @@
     for (i = 0; i < touchEvent->numTouches; i++) {
         SDL_FingerID id;
         float x, y;
+        int mx, my;
 
         if (!touchEvent->touches[i].isChanged)
             continue;
@@ -445,11 +446,14 @@
         x = touchEvent->touches[i].canvasX / client_w;
         y = touchEvent->touches[i].canvasY / client_h;
 
+        mx = x * window_data->window->w;
+        my = y * window_data->window->h;
+
         if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) {
             if (!window_data->finger_touching) {
                 window_data->finger_touching = SDL_TRUE;
                 window_data->first_finger = id;
-                SDL_SendMouseMotion(window_data->window, SDL_TOUCH_MOUSEID, 0, x, y);
+                SDL_SendMouseMotion(window_data->window, SDL_TOUCH_MOUSEID, 0, mx, my);
                 SDL_SendMouseButton(window_data->window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
             }
             SDL_SendTouch(deviceId, id, SDL_TRUE, x, y, 1.0f);
@@ -459,7 +463,7 @@
             }
         } else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) {
             if ((window_data->finger_touching) && (window_data->first_finger == id)) {
-                SDL_SendMouseMotion(window_data->window, SDL_TOUCH_MOUSEID, 0, x, y);
+                SDL_SendMouseMotion(window_data->window, SDL_TOUCH_MOUSEID, 0, mx, my);
             }
             SDL_SendTouchMotion(deviceId, id, x, y, 1.0f);
 


More information about the commits mailing list