mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-01-10 23:55:43 +00:00
Cancel any accumulated mouse wheel motion in the opposite direction when the wheel direction changes
Fixes https://github.com/libsdl-org/SDL/issues/2912
This commit is contained in:
parent
5dbbc8e61f
commit
a3e8fd49e6
|
@ -623,20 +623,38 @@ SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, S
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (x > 0.0f) {
|
||||||
|
if (mouse->accumulated_wheel_x < 0.0f) {
|
||||||
|
mouse->accumulated_wheel_x = 0.0f;
|
||||||
|
}
|
||||||
|
} else if (x < 0.0f) {
|
||||||
|
if (mouse->accumulated_wheel_x > 0.0f) {
|
||||||
|
mouse->accumulated_wheel_x = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
mouse->accumulated_wheel_x += x;
|
mouse->accumulated_wheel_x += x;
|
||||||
if (mouse->accumulated_wheel_x > 0) {
|
if (mouse->accumulated_wheel_x > 0.0f) {
|
||||||
integral_x = (int)SDL_floor(mouse->accumulated_wheel_x);
|
integral_x = (int)SDL_floor(mouse->accumulated_wheel_x);
|
||||||
} else if (mouse->accumulated_wheel_x < 0) {
|
} else if (mouse->accumulated_wheel_x < 0.0f) {
|
||||||
integral_x = (int)SDL_ceil(mouse->accumulated_wheel_x);
|
integral_x = (int)SDL_ceil(mouse->accumulated_wheel_x);
|
||||||
} else {
|
} else {
|
||||||
integral_x = 0;
|
integral_x = 0;
|
||||||
}
|
}
|
||||||
mouse->accumulated_wheel_x -= integral_x;
|
mouse->accumulated_wheel_x -= integral_x;
|
||||||
|
|
||||||
|
if (y > 0.0f) {
|
||||||
|
if (mouse->accumulated_wheel_y < 0.0f) {
|
||||||
|
mouse->accumulated_wheel_y = 0.0f;
|
||||||
|
}
|
||||||
|
} else if (y < 0.0f) {
|
||||||
|
if (mouse->accumulated_wheel_y > 0.0f) {
|
||||||
|
mouse->accumulated_wheel_y = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
mouse->accumulated_wheel_y += y;
|
mouse->accumulated_wheel_y += y;
|
||||||
if (mouse->accumulated_wheel_y > 0) {
|
if (mouse->accumulated_wheel_y > 0.0f) {
|
||||||
integral_y = (int)SDL_floor(mouse->accumulated_wheel_y);
|
integral_y = (int)SDL_floor(mouse->accumulated_wheel_y);
|
||||||
} else if (mouse->accumulated_wheel_y < 0) {
|
} else if (mouse->accumulated_wheel_y < 0.0f) {
|
||||||
integral_y = (int)SDL_ceil(mouse->accumulated_wheel_y);
|
integral_y = (int)SDL_ceil(mouse->accumulated_wheel_y);
|
||||||
} else {
|
} else {
|
||||||
integral_y = 0;
|
integral_y = 0;
|
||||||
|
|
Loading…
Reference in a new issue