From 3f51758ec54910d634d9c87aa6b14db52c3ef8d9 Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Wed, 6 May 2015 21:10:48 +0200 Subject: [PATCH] Emscripten: Fixed touch coordinates not being normalized. --- src/video/emscripten/SDL_emscriptenevents.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/video/emscripten/SDL_emscriptenevents.c b/src/video/emscripten/SDL_emscriptenevents.c index 6a04d4cc8..9dd13e26a 100644 --- a/src/video/emscripten/SDL_emscriptenevents.c +++ b/src/video/emscripten/SDL_emscriptenevents.c @@ -371,7 +371,7 @@ Emscripten_HandleFocus(int eventType, const EmscriptenFocusEvent *wheelEvent, vo EM_BOOL Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData) { - /*SDL_WindowData *window_data = userData;*/ + SDL_WindowData *window_data = userData; int i; SDL_TouchID deviceId = 0; @@ -382,14 +382,15 @@ Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, vo } for (i = 0; i < touchEvent->numTouches; i++) { - long x, y, id; + SDL_FingerID id; + float x, y; if (!touchEvent->touches[i].isChanged) continue; id = touchEvent->touches[i].identifier; - x = touchEvent->touches[i].canvasX; - y = touchEvent->touches[i].canvasY; + x = touchEvent->touches[i].canvasX / (float)window_data->windowed_width; + y = touchEvent->touches[i].canvasY / (float)window_data->windowed_height; if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) { SDL_SendTouchMotion(deviceId, id, x, y, 1.0f);