mirror of
https://github.com/libsdl-org/SDL.git
synced 2024-11-26 21:33:26 +08:00
fix relative warp emulation broken by #11460
This commit is contained in:
parent
e0166256ff
commit
25390d6c21
@ -814,28 +814,31 @@ static void SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL
|
|||||||
yrel = 0.0f;
|
yrel = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // modify internal state
|
// TODO: should rework overall so that relative bool arg conveys intent,
|
||||||
if (relative) {
|
// and do this logic at the SDL_SendMouseMotion level instead of here.
|
||||||
if (mouse->has_position) {
|
bool cmd_is_meant_as_delta = relative || (mouse->relative_mode && mouse->relative_mode_warp);
|
||||||
mouse->x += xrel;
|
bool cmd_is_hardware_delta = relative;
|
||||||
mouse->y += yrel;
|
|
||||||
ConstrainMousePosition(mouse, window, &mouse->x, &mouse->y);
|
// modify internal state
|
||||||
} else {
|
{
|
||||||
mouse->x = x;
|
if (cmd_is_meant_as_delta) {
|
||||||
mouse->y = y;
|
|
||||||
}
|
|
||||||
mouse->last_x = mouse->x;
|
|
||||||
mouse->last_y = mouse->y;
|
|
||||||
mouse->x_accu += xrel;
|
mouse->x_accu += xrel;
|
||||||
mouse->y_accu += yrel;
|
mouse->y_accu += yrel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd_is_meant_as_delta && mouse->has_position) {
|
||||||
|
mouse->x += xrel;
|
||||||
|
mouse->y += yrel;
|
||||||
|
ConstrainMousePosition(mouse, window, &mouse->x, &mouse->y);
|
||||||
} else {
|
} else {
|
||||||
// Use unclamped values if we're getting events outside the window
|
|
||||||
mouse->x = x;
|
mouse->x = x;
|
||||||
mouse->y = y;
|
mouse->y = y;
|
||||||
mouse->last_x = x;
|
|
||||||
mouse->last_y = y;
|
|
||||||
}
|
}
|
||||||
mouse->has_position = true;
|
mouse->has_position = true;
|
||||||
|
|
||||||
|
// Use unclamped values if we're getting events outside the window
|
||||||
|
mouse->last_x = cmd_is_hardware_delta ? mouse->x : x;
|
||||||
|
mouse->last_y = cmd_is_hardware_delta ? mouse->y : y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the mouse cursor, if needed
|
// Move the mouse cursor, if needed
|
||||||
@ -846,7 +849,7 @@ static void SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL
|
|||||||
|
|
||||||
// Post the event, if desired
|
// Post the event, if desired
|
||||||
if (SDL_EventEnabled(SDL_EVENT_MOUSE_MOTION)) {
|
if (SDL_EventEnabled(SDL_EVENT_MOUSE_MOTION)) {
|
||||||
if (!relative && window_is_relative) {
|
if (!cmd_is_meant_as_delta && window_is_relative) {
|
||||||
if (!mouse->relative_mode_warp_motion) {
|
if (!mouse->relative_mode_warp_motion) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user