mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-14 17:15:21 +02:00
TouchScreenGUI: Read coordinates directly for virtual joystick (#13567)
The movement's direction and speed are calculated directly from the button's relative screen coordinate. The previous method was to trigger the movement using a keyboard event. The only virtual joystick status left is Aux1 button. --------- Co-authored-by: Gregor Parzefall <gregor.parzefall@posteo.de>
This commit is contained in:
committed by
GitHub
parent
c549e84abb
commit
a4e69d6843
@@ -332,7 +332,11 @@ public:
|
||||
return 0.0f;
|
||||
return 1.0f; // If there is a keyboard event, assume maximum speed
|
||||
}
|
||||
#ifdef HAVE_TOUCHSCREENGUI
|
||||
return m_receiver->m_touchscreengui->getMovementSpeed();
|
||||
#else
|
||||
return joystick.getMovementSpeed();
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual float getMovementDirection()
|
||||
@@ -352,7 +356,11 @@ public:
|
||||
if (x != 0 || z != 0) /* If there is a keyboard event, it takes priority */
|
||||
return atan2(x, z);
|
||||
else
|
||||
#ifdef HAVE_TOUCHSCREENGUI
|
||||
return m_receiver->m_touchscreengui->getMovementDirection();
|
||||
#else
|
||||
return joystick.getMovementDirection();
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual bool cancelPressed()
|
||||
|
Reference in New Issue
Block a user