Mouse events use CSS coordinates, so don't scale by pixel_ratio
authorBoris Gjenero <boris.gjenero@gmail.com>
Tue, 13 Sep 2016 00:03:46 -0700
changeset 10326b7059a6e0de7
parent 10325 743e0f5e8ace
child 10327 47d840cce014
Mouse events use CSS coordinates, so don't scale by pixel_ratio
src/video/emscripten/SDL_emscriptenevents.c
     1.1 --- a/src/video/emscripten/SDL_emscriptenevents.c	Tue Sep 13 00:03:45 2016 -0700
     1.2 +++ b/src/video/emscripten/SDL_emscriptenevents.c	Tue Sep 13 00:03:46 2016 -0700
     1.3 @@ -308,8 +308,8 @@
     1.4      /* rescale (in case canvas is being scaled)*/
     1.5      double client_w, client_h, xscale, yscale;
     1.6      emscripten_get_element_css_size(NULL, &client_w, &client_h);
     1.7 -    xscale = window_data->window->w / (client_w * window_data->pixel_ratio);
     1.8 -    yscale = window_data->window->h / (client_h * window_data->pixel_ratio);
     1.9 +    xscale = window_data->window->w / client_w;
    1.10 +    yscale = window_data->window->h / client_h;
    1.11  
    1.12      /* check for pointer lock */
    1.13      int isPointerLockSupported = emscripten_get_pointerlock_status(&pointerlock_status);
    1.14 @@ -371,8 +371,8 @@
    1.15          double client_w, client_h;
    1.16          emscripten_get_element_css_size(NULL, &client_w, &client_h);
    1.17  
    1.18 -        mx = mx * (window_data->window->w / (client_w * window_data->pixel_ratio));
    1.19 -        my = my * (window_data->window->h / (client_h * window_data->pixel_ratio));
    1.20 +        mx = mx * (window_data->window->w / client_w);
    1.21 +        my = my * (window_data->window->h / client_h);
    1.22          SDL_SendMouseMotion(window_data->window, 0, isPointerLocked, mx, my);
    1.23      }
    1.24