Fix mouse lock/high-dpi 2

This commit is contained in:
erorcun 2020-11-16 15:49:00 +03:00
parent 3b1debaa0d
commit f33ed2892a
2 changed files with 5 additions and 8 deletions

View File

@ -5433,6 +5433,10 @@ CMenuManager::SetHelperText(int text)
void void
CMenuManager::ShutdownJustMenu() CMenuManager::ShutdownJustMenu()
{ {
// In case we're windowed, keep mouse centered while in game. Done in main.cpp in other conditions.
#if defined(RW_GL3) && defined(IMPROVED_VIDEOMODE)
glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, GLFW_CURSOR_DISABLED);
#endif
m_bMenuActive = false; m_bMenuActive = false;
CTimer::EndUserPause(); CTimer::EndUserPause();
} }
@ -5532,8 +5536,7 @@ CMenuManager::SwitchMenuOnAndOff()
if (m_bMenuActive != menuWasActive) { if (m_bMenuActive != menuWasActive) {
m_bMenuStateChanged = true; m_bMenuStateChanged = true;
// Keep mouse centered while in game. Done in main.cpp in other conditions. // In case we're windowed, keep mouse centered while in game. Done in main.cpp in other conditions.
// IMPROVED_VIDEOMODE because otherwise there is no way for windowed mode.
#if defined(RW_GL3) && defined(IMPROVED_VIDEOMODE) #if defined(RW_GL3) && defined(IMPROVED_VIDEOMODE)
glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, m_bMenuActive && m_nPrefsWindowed ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_DISABLED); glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, m_bMenuActive && m_nPrefsWindowed ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_DISABLED);
#endif #endif

View File

@ -885,13 +885,7 @@ void _InputInitialiseJoys()
long _InputInitialiseMouse() long _InputInitialiseMouse()
{ {
#ifdef IMPROVED_VIDEOMODE
// May be windowed, transition will be handled in CMenuManager::SwitchMenuOnAndOff()
glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, GLFW_CURSOR_HIDDEN); glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
#else
// Always fullscreen, disable mouse
glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, GLFW_CURSOR_DISABLED);
#endif
return 0; return 0;
} }