mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Auto-toggle TouchControls in-game when receiving touch/mouse input
This commit is contained in:
parent
3c5f05b284
commit
4952f17df4
15 changed files with 152 additions and 89 deletions
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue