Skip to content
Permalink
Browse files

Mouse events use CSS coordinates, so don't scale by pixel_ratio

  • Loading branch information
dreamlayers committed Sep 13, 2016
1 parent a20c40c commit 3e5c4cec94aeb2dd0afd3e6c2a53210a4ff54b9e
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/video/emscripten/SDL_emscriptenevents.c
@@ -308,8 +308,8 @@ Emscripten_HandleMouseMove(int eventType, const EmscriptenMouseEvent *mouseEvent
/* rescale (in case canvas is being scaled)*/
double client_w, client_h, xscale, yscale;
emscripten_get_element_css_size(NULL, &client_w, &client_h);
xscale = window_data->window->w / (client_w * window_data->pixel_ratio);
yscale = window_data->window->h / (client_h * window_data->pixel_ratio);
xscale = window_data->window->w / client_w;
yscale = window_data->window->h / client_h;

/* check for pointer lock */
int isPointerLockSupported = emscripten_get_pointerlock_status(&pointerlock_status);
@@ -371,8 +371,8 @@ Emscripten_HandleMouseFocus(int eventType, const EmscriptenMouseEvent *mouseEven
double client_w, client_h;
emscripten_get_element_css_size(NULL, &client_w, &client_h);

mx = mx * (window_data->window->w / (client_w * window_data->pixel_ratio));
my = my * (window_data->window->h / (client_h * window_data->pixel_ratio));
mx = mx * (window_data->window->w / client_w);
my = my * (window_data->window->h / client_h);
SDL_SendMouseMotion(window_data->window, 0, isPointerLocked, mx, my);
}

0 comments on commit 3e5c4ce

Please sign in to comment.