Skip to content

Commit

Permalink
Fixed mouse warping while in relative mode
Browse files Browse the repository at this point in the history
We should get a mouse event with an absolute position and no relative motion and shouldn't change the OS cursor position at all
  • Loading branch information
slouken committed Oct 14, 2021
1 parent 072e3fd commit 82793ac
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/events/SDL_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ
if (!mouse->has_position) {
xrel = 0;
yrel = 0;
mouse->x = x;
mouse->y = y;
mouse->has_position = SDL_TRUE;
} else if (!xrel && !yrel) { /* Drop events that don't change state */
#ifdef DEBUG_MOUSE
Expand Down Expand Up @@ -765,10 +767,14 @@ SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
return;
}

if (mouse->WarpMouse) {
/* Ignore the previous position when we warp */
mouse->has_position = SDL_FALSE;

if (mouse->WarpMouse &&
(!mouse->relative_mode || mouse->relative_mode_warp)) {
mouse->WarpMouse(window, x, y);
} else {
SDL_SendMouseMotion(window, mouse->mouseID, 0, x, y);
SDL_PrivateSendMouseMotion(window, mouse->mouseID, 0, x, y);
}
}

Expand Down

0 comments on commit 82793ac

Please sign in to comment.