mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Android: Fix camera jump when switching to mouse mode
Easy way to reproduce: 1. Connect a bluetooth mouse to your Android phone with Minetest installed 2. Play Minetest 3. Slowly move the mouse to the right so that the camera rotates continously 4. While still moving the mouse continously, tap the screen a few times per second Before this commit: The camera jumps around randomly. After this commit: The camera moves like it should. This is a combination of two Irrlicht changes copied from MoNTE48/irrlicht and one Minetest change authored by me. I have no idea why this works, but it does work and I have spent way too much time on this bug already.
This commit is contained in:
parent
4952f17df4
commit
f5076723e8
3 changed files with 19 additions and 5 deletions
|
@ -721,12 +721,19 @@ bool CIrrDeviceSDL::run()
|
|||
|
||||
irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
|
||||
irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
|
||||
MouseX = irrevent.MouseInput.X =
|
||||
static_cast<s32>(SDL_event.motion.x * ScaleX);
|
||||
MouseY = irrevent.MouseInput.Y =
|
||||
static_cast<s32>(SDL_event.motion.y * ScaleY);
|
||||
|
||||
MouseXRel = static_cast<s32>(SDL_event.motion.xrel * ScaleX);
|
||||
MouseYRel = static_cast<s32>(SDL_event.motion.yrel * ScaleY);
|
||||
if (!SDL_GetRelativeMouseMode()) {
|
||||
MouseX = static_cast<s32>(SDL_event.motion.x * ScaleX);
|
||||
MouseY = static_cast<s32>(SDL_event.motion.y * ScaleY);
|
||||
} else {
|
||||
MouseX += MouseXRel;
|
||||
MouseY += MouseYRel;
|
||||
}
|
||||
irrevent.MouseInput.X = MouseX;
|
||||
irrevent.MouseInput.Y = MouseY;
|
||||
|
||||
irrevent.MouseInput.ButtonStates = MouseButtonStates;
|
||||
irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0;
|
||||
irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue