Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't enable relative mouse mode if in touchscreen mode #14118

Merged
merged 2 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/client/clientlauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
ICursorControl *cur_control = m_rendering_engine->get_raw_device()->getCursorControl();
grorp marked this conversation as resolved.
Show resolved Hide resolved
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);
Expand Down
32 changes: 16 additions & 16 deletions src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
ICursorControl *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;
Expand All @@ -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;

}
}

Expand Down