Fix mouse lock/high-dpi
This commit is contained in:
parent
72c0a6a680
commit
3b1debaa0d
@ -5529,8 +5529,15 @@ CMenuManager::SwitchMenuOnAndOff()
|
|||||||
gMusicPlaying = 0;
|
gMusicPlaying = 0;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
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.
|
||||||
|
// IMPROVED_VIDEOMODE because otherwise there is no way for windowed mode.
|
||||||
|
#if defined(RW_GL3) && defined(IMPROVED_VIDEOMODE)
|
||||||
|
glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, m_bMenuActive && m_nPrefsWindowed ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_DISABLED);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
m_bStartUpFrontEndRequested = false;
|
m_bStartUpFrontEndRequested = false;
|
||||||
m_bShutDownFrontEndRequested = false;
|
m_bShutDownFrontEndRequested = false;
|
||||||
|
@ -1090,9 +1090,9 @@ Idle(void *arg)
|
|||||||
if((!FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bRenderGameInMenu) &&
|
if((!FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bRenderGameInMenu) &&
|
||||||
TheCamera.GetScreenFadeStatus() != FADE_2)
|
TheCamera.GetScreenFadeStatus() != FADE_2)
|
||||||
{
|
{
|
||||||
#ifdef GTA_PC
|
// This is from SA, but it's nice for windowed mode
|
||||||
|
#if defined(GTA_PC) && !defined(RW_GL3)
|
||||||
if (!FrontEndMenuManager.m_bRenderGameInMenu) {
|
if (!FrontEndMenuManager.m_bRenderGameInMenu) {
|
||||||
// This is from SA, but it's nice for windowed mode
|
|
||||||
RwV2d pos;
|
RwV2d pos;
|
||||||
pos.x = SCREEN_WIDTH / 2.0f;
|
pos.x = SCREEN_WIDTH / 2.0f;
|
||||||
pos.y = SCREEN_HEIGHT / 2.0f;
|
pos.y = SCREEN_HEIGHT / 2.0f;
|
||||||
|
@ -885,7 +885,13 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1416,11 +1422,13 @@ _InputTranslateShiftKeyUpDown(RsKeyCodes *rs) {
|
|||||||
// TODO this only works in frontend(and luckily only frontend use this). Fun fact: if I get pos manually in game, glfw reports that it's > 32000
|
// TODO this only works in frontend(and luckily only frontend use this). Fun fact: if I get pos manually in game, glfw reports that it's > 32000
|
||||||
void
|
void
|
||||||
cursorCB(GLFWwindow* window, double xpos, double ypos) {
|
cursorCB(GLFWwindow* window, double xpos, double ypos) {
|
||||||
int bufw, bufh, winw, winh;
|
if (!FrontEndMenuManager.m_bMenuActive)
|
||||||
glfwGetWindowSize(window, &winw, &winh);
|
return;
|
||||||
glfwGetFramebufferSize(window, &bufw, &bufh);
|
|
||||||
FrontEndMenuManager.m_nMouseTempPosX = xpos * (bufw / winw);
|
int winw, winh;
|
||||||
FrontEndMenuManager.m_nMouseTempPosY = ypos * (bufh / winh);
|
glfwGetWindowSize(PSGLOBAL(window), &winw, &winh);
|
||||||
|
FrontEndMenuManager.m_nMouseTempPosX = xpos * (RsGlobal.maximumWidth / winw);
|
||||||
|
FrontEndMenuManager.m_nMouseTempPosY = ypos * (RsGlobal.maximumHeight / winh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1648,8 +1656,6 @@ main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR,
|
|
||||||
(FrontEndMenuManager.m_bMenuActive && !PSGLOBAL(fullScreen)) ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_DISABLED);
|
|
||||||
if( ForegroundApp )
|
if( ForegroundApp )
|
||||||
{
|
{
|
||||||
switch ( gGameState )
|
switch ( gGameState )
|
||||||
|
Loading…
Reference in New Issue
Block a user