mirror of https://github.com/encounter/SDL.git
use css size for touch normalisation
This commit is contained in:
parent
1096f32309
commit
be08cc61f9
|
@ -374,12 +374,15 @@ Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, vo
|
||||||
{
|
{
|
||||||
SDL_WindowData *window_data = userData;
|
SDL_WindowData *window_data = userData;
|
||||||
int i;
|
int i;
|
||||||
|
double client_w, client_h;
|
||||||
|
|
||||||
SDL_TouchID deviceId = 1;
|
SDL_TouchID deviceId = 1;
|
||||||
if (SDL_AddTouch(deviceId, "") < 0) {
|
if (SDL_AddTouch(deviceId, "") < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emscripten_get_element_css_size(NULL, &client_w, &client_h);
|
||||||
|
|
||||||
for (i = 0; i < touchEvent->numTouches; i++) {
|
for (i = 0; i < touchEvent->numTouches; i++) {
|
||||||
SDL_FingerID id;
|
SDL_FingerID id;
|
||||||
float x, y;
|
float x, y;
|
||||||
|
@ -388,8 +391,8 @@ Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, vo
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
id = touchEvent->touches[i].identifier;
|
id = touchEvent->touches[i].identifier;
|
||||||
x = touchEvent->touches[i].canvasX / (float)window_data->windowed_width;
|
x = touchEvent->touches[i].canvasX / client_w;
|
||||||
y = touchEvent->touches[i].canvasY / (float)window_data->windowed_height;
|
y = touchEvent->touches[i].canvasY / client_h;
|
||||||
|
|
||||||
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) {
|
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) {
|
||||||
if (!window_data->finger_touching) {
|
if (!window_data->finger_touching) {
|
||||||
|
|
Loading…
Reference in New Issue