forked from Mirrorlandia_minetest/minetest
Don't enable relative mouse mode if in touchscreen mode (#14118)
This commit is contained in:
parent
59abf1bb42
commit
b12be0498e
@ -542,13 +542,13 @@ void ClientLauncher::main_menu(MainMenuData *menudata)
|
||||
}
|
||||
infostream << "Waited for other menus" << std::endl;
|
||||
|
||||
#ifndef ANDROID
|
||||
// Cursor can be non-visible when coming from the game
|
||||
m_rendering_engine->get_raw_device()->getCursorControl()->setVisible(true);
|
||||
|
||||
// Set absolute mouse mode
|
||||
m_rendering_engine->get_raw_device()->getCursorControl()->setRelativeMode(false);
|
||||
#endif
|
||||
auto *cur_control = m_rendering_engine->get_raw_device()->getCursorControl();
|
||||
if (cur_control) {
|
||||
// Cursor can be non-visible when coming from the game
|
||||
cur_control->setVisible(true);
|
||||
// Set absolute mouse mode
|
||||
cur_control->setRelativeMode(false);
|
||||
}
|
||||
|
||||
/* show main menu */
|
||||
GUIEngine mymenu(&input->joystick, guiroot, m_rendering_engine, &g_menumgr, menudata, *kill);
|
||||
|
@ -2613,23 +2613,27 @@ void Game::checkZoomEnabled()
|
||||
|
||||
void Game::updateCameraDirection(CameraOrientation *cam, float dtime)
|
||||
{
|
||||
#ifndef __ANDROID__
|
||||
if (isMenuActive())
|
||||
device->getCursorControl()->setRelativeMode(false);
|
||||
else
|
||||
device->getCursorControl()->setRelativeMode(true);
|
||||
auto *cur_control = device->getCursorControl();
|
||||
|
||||
/* With CIrrDeviceSDL on Linux and Windows, enabling relative mouse mode
|
||||
somehow results in simulated mouse events being generated from touch events,
|
||||
although SDL_HINT_MOUSE_TOUCH_EVENTS and SDL_HINT_TOUCH_MOUSE_EVENTS are set to 0.
|
||||
Since Minetest has its own code to synthesize mouse events from touch events,
|
||||
this results in duplicated input. To avoid that, we don't enable relative
|
||||
mouse mode if we're in touchscreen mode. */
|
||||
#ifndef HAVE_TOUCHSCREENGUI
|
||||
if (cur_control)
|
||||
cur_control->setRelativeMode(!isMenuActive());
|
||||
#endif
|
||||
|
||||
if ((device->isWindowActive() && device->isWindowFocused()
|
||||
&& !isMenuActive()) || input->isRandom()) {
|
||||
|
||||
#ifndef __ANDROID__
|
||||
if (!input->isRandom()) {
|
||||
if (cur_control && !input->isRandom()) {
|
||||
// Mac OSX gets upset if this is set every frame
|
||||
if (device->getCursorControl()->isVisible())
|
||||
device->getCursorControl()->setVisible(false);
|
||||
if (cur_control->isVisible())
|
||||
cur_control->setVisible(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_first_loop_after_window_activation) {
|
||||
m_first_loop_after_window_activation = false;
|
||||
@ -2641,15 +2645,11 @@ void Game::updateCameraDirection(CameraOrientation *cam, float dtime)
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
#ifndef ANDROID
|
||||
// Mac OSX gets upset if this is set every frame
|
||||
if (!device->getCursorControl()->isVisible())
|
||||
device->getCursorControl()->setVisible(true);
|
||||
#endif
|
||||
if (cur_control && !cur_control->isVisible())
|
||||
cur_control->setVisible(true);
|
||||
|
||||
m_first_loop_after_window_activation = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user