diff options
Diffstat (limited to '')
-rw-r--r-- | src/core/main.cpp | 12 | ||||
-rw-r--r-- | src/skel/glfw/glfw.cpp | 30 |
2 files changed, 26 insertions, 16 deletions
diff --git a/src/core/main.cpp b/src/core/main.cpp index 48e0ff76..5786fb4e 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1188,12 +1188,12 @@ Idle(void *arg) if(!FrontEndMenuManager.m_bMenuActive && TheCamera.GetScreenFadeStatus() != FADE_2) { -#ifdef GTA_PC - // This is from SA, but it's nice for windowed mode - RwV2d pos; - pos.x = SCREEN_WIDTH / 2.0f; - pos.y = SCREEN_HEIGHT / 2.0f; - RsMouseSetPos(&pos); + // This is from SA, but it's nice for windowed mode +#if defined(GTA_PC) && !defined(RW_GL3) + RwV2d pos; + pos.x = SCREEN_WIDTH / 2.0f; + pos.y = SCREEN_HEIGHT / 2.0f; + RsMouseSetPos(&pos); #endif #ifdef NEW_RENDERER if(!gbNewRenderer) diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index fbd40ba2..cac487b1 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -896,9 +896,12 @@ void _InputInitialiseJoys() } } +int lastCursorMode = GLFW_CURSOR_HIDDEN; long _InputInitialiseMouse(bool exclusive) { - glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, GLFW_CURSOR_HIDDEN); + // Disabled = keep cursor centered and hide + lastCursorMode = exclusive ? GLFW_CURSOR_DISABLED : GLFW_CURSOR_HIDDEN; + glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, lastCursorMode); return 0; } @@ -907,10 +910,17 @@ void _InputShutdownMouse() // Not needed } +// Not "needs exclusive" on GLFW, but more like "needs to change mode" bool _InputMouseNeedsExclusive() { - // That was the cause of infamous mouse bug on Win. Not supported on glfw anyway - return false; + // That was the cause of infamous mouse bug on Win. + + RwVideoMode vm; + RwEngineGetVideoModeInfo(&vm, GcurSelVM); + + // If windowed, free the cursor on menu(where this func. is called and DISABLED-HIDDEN transition is done accordingly) + // If it's fullscreen, be sure that it didn't stuck on HIDDEN. + return !(vm.flags & rwVIDEOMODEEXCLUSIVE) || lastCursorMode == GLFW_CURSOR_HIDDEN; } void psPostRWinit(void) @@ -1440,11 +1450,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 void cursorCB(GLFWwindow* window, double xpos, double ypos) { - int bufw, bufh, winw, winh; - glfwGetWindowSize(window, &winw, &winh); - glfwGetFramebufferSize(window, &bufw, &bufh); - FrontEndMenuManager.m_nMouseTempPosX = xpos * (bufw / winw); - FrontEndMenuManager.m_nMouseTempPosY = ypos * (bufh / winh); + if (!FrontEndMenuManager.m_bMenuActive) + return; + + int winw, winh; + glfwGetWindowSize(PSGLOBAL(window), &winw, &winh); + FrontEndMenuManager.m_nMouseTempPosX = xpos * (RsGlobal.maximumWidth / winw); + FrontEndMenuManager.m_nMouseTempPosY = ypos * (RsGlobal.maximumHeight / winh); } void @@ -1672,8 +1684,6 @@ main(int argc, char *argv[]) #endif { glfwPollEvents(); - glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, - (FrontEndMenuManager.m_bMenuActive && !PSGLOBAL(fullScreen)) ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_DISABLED); if( ForegroundApp ) { switch ( gGameState ) |