mirror of https://github.com/encounter/SDL.git
Emscripten: Fixed touch coordinates not being normalized.
This commit is contained in:
parent
5715097a0c
commit
3f51758ec5
|
@ -371,7 +371,7 @@ Emscripten_HandleFocus(int eventType, const EmscriptenFocusEvent *wheelEvent, vo
|
||||||
EM_BOOL
|
EM_BOOL
|
||||||
Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData)
|
Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData)
|
||||||
{
|
{
|
||||||
/*SDL_WindowData *window_data = userData;*/
|
SDL_WindowData *window_data = userData;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
SDL_TouchID deviceId = 0;
|
SDL_TouchID deviceId = 0;
|
||||||
|
@ -382,14 +382,15 @@ Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, vo
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < touchEvent->numTouches; i++) {
|
for (i = 0; i < touchEvent->numTouches; i++) {
|
||||||
long x, y, id;
|
SDL_FingerID id;
|
||||||
|
float x, y;
|
||||||
|
|
||||||
if (!touchEvent->touches[i].isChanged)
|
if (!touchEvent->touches[i].isChanged)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
id = touchEvent->touches[i].identifier;
|
id = touchEvent->touches[i].identifier;
|
||||||
x = touchEvent->touches[i].canvasX;
|
x = touchEvent->touches[i].canvasX / (float)window_data->windowed_width;
|
||||||
y = touchEvent->touches[i].canvasY;
|
y = touchEvent->touches[i].canvasY / (float)window_data->windowed_height;
|
||||||
|
|
||||||
if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) {
|
if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) {
|
||||||
SDL_SendTouchMotion(deviceId, id, x, y, 1.0f);
|
SDL_SendTouchMotion(deviceId, id, x, y, 1.0f);
|
||||||
|
|
Loading…
Reference in New Issue