mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 08:35:20 +02:00
Auto-toggle TouchControls in-game when receiving touch/mouse input
This commit is contained in:
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "gui/touchcontrols.h"
|
||||
#include "hud.h"
|
||||
#include "log_internal.h"
|
||||
#include "client/renderingengine.h"
|
||||
|
||||
void KeyCache::populate_nonchanging()
|
||||
{
|
||||
@@ -142,6 +143,11 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
|
||||
}
|
||||
}
|
||||
|
||||
if (event.EventType == EET_MOUSE_INPUT_EVENT && !event.MouseInput.Simulated)
|
||||
last_pointer_type = PointerType::Mouse;
|
||||
else if (event.EventType == EET_TOUCH_INPUT_EVENT)
|
||||
last_pointer_type = PointerType::Touch;
|
||||
|
||||
// Let the menu handle events, if one is active.
|
||||
if (isMenuActive()) {
|
||||
if (g_touchcontrols)
|
||||
@@ -237,6 +243,26 @@ float RealInputHandler::getJoystickDirection()
|
||||
return joystick.getMovementDirection();
|
||||
}
|
||||
|
||||
v2s32 RealInputHandler::getMousePos()
|
||||
{
|
||||
auto control = RenderingEngine::get_raw_device()->getCursorControl();
|
||||
if (control) {
|
||||
return control->getPosition();
|
||||
}
|
||||
|
||||
return m_mousepos;
|
||||
}
|
||||
|
||||
void RealInputHandler::setMousePos(s32 x, s32 y)
|
||||
{
|
||||
auto control = RenderingEngine::get_raw_device()->getCursorControl();
|
||||
if (control) {
|
||||
control->setPosition(x, y);
|
||||
} else {
|
||||
m_mousepos = v2s32(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RandomInputHandler
|
||||
*/
|
||||
|
Reference in New Issue
Block a user