mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 00:25:19 +02: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:
@@ -158,9 +158,13 @@ public:
|
||||
//! Sets the new position of the cursor.
|
||||
void setPosition(s32 x, s32 y) override
|
||||
{
|
||||
#ifndef __ANDROID__
|
||||
// On Android, this somehow results in a camera jump when enabling
|
||||
// relative mouse mode and it isn't supported anyway.
|
||||
SDL_WarpMouseInWindow(Device->Window,
|
||||
static_cast<int>(x / Device->ScaleX),
|
||||
static_cast<int>(y / Device->ScaleY));
|
||||
#endif
|
||||
|
||||
if (SDL_GetRelativeMouseMode()) {
|
||||
// There won't be an event for this warp (details on libsdl-org/SDL/issues/6034)
|
||||
@@ -298,6 +302,7 @@ private:
|
||||
#endif
|
||||
|
||||
s32 MouseX, MouseY;
|
||||
// these two only continue to exist for some Emscripten stuff idk about
|
||||
s32 MouseXRel, MouseYRel;
|
||||
u32 MouseButtonStates;
|
||||
|
||||
|
Reference in New Issue
Block a user