mirror of https://github.com/encounter/SDL.git
Fixed bug 2931 - Large relative mouse motion jumps when using touch input
This commit is contained in:
parent
b2e2bcc203
commit
bfd5a13473
|
@ -173,6 +173,7 @@ SDL_SetMouseFocus(SDL_Window * window)
|
||||||
}
|
}
|
||||||
|
|
||||||
mouse->focus = window;
|
mouse->focus = window;
|
||||||
|
mouse->has_position = SDL_FALSE;
|
||||||
|
|
||||||
if (mouse->focus) {
|
if (mouse->focus) {
|
||||||
SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
|
SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
|
||||||
|
@ -271,7 +272,7 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mouse->relative_mode_warp) {
|
if (mouseID != SDL_TOUCH_MOUSEID && mouse->relative_mode_warp) {
|
||||||
int center_x = 0, center_y = 0;
|
int center_x = 0, center_y = 0;
|
||||||
SDL_GetWindowSize(window, ¢er_x, ¢er_y);
|
SDL_GetWindowSize(window, ¢er_x, ¢er_y);
|
||||||
center_x /= 2;
|
center_x /= 2;
|
||||||
|
@ -309,6 +310,19 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ignore relative motion when first positioning the mouse */
|
||||||
|
if (!mouse->has_position) {
|
||||||
|
xrel = 0;
|
||||||
|
yrel = 0;
|
||||||
|
mouse->has_position = SDL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ignore relative motion positioning the first touch */
|
||||||
|
if (mouseID == SDL_TOUCH_MOUSEID && !mouse->buttonstate) {
|
||||||
|
xrel = 0;
|
||||||
|
yrel = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Update internal mouse coordinates */
|
/* Update internal mouse coordinates */
|
||||||
if (!mouse->relative_mode) {
|
if (!mouse->relative_mode) {
|
||||||
mouse->x = x;
|
mouse->x = x;
|
||||||
|
|
|
@ -81,6 +81,7 @@ typedef struct
|
||||||
int ydelta;
|
int ydelta;
|
||||||
int last_x, last_y; /* the last reported x and y coordinates */
|
int last_x, last_y; /* the last reported x and y coordinates */
|
||||||
Uint32 buttonstate;
|
Uint32 buttonstate;
|
||||||
|
SDL_bool has_position;
|
||||||
SDL_bool relative_mode;
|
SDL_bool relative_mode;
|
||||||
SDL_bool relative_mode_warp;
|
SDL_bool relative_mode_warp;
|
||||||
float normal_speed_scale;
|
float normal_speed_scale;
|
||||||
|
|
Loading…
Reference in New Issue