diff options
author | erorcun <erorcunerorcun@hotmail.com.tr> | 2020-11-16 13:28:10 +0100 |
---|---|---|
committer | erorcun <erorcunerorcun@hotmail.com.tr> | 2020-11-18 15:42:21 +0100 |
commit | 54214dd2c4da79945b9f6b8b3a31ba5ddb8a0b84 (patch) | |
tree | 9b9a1f1fb6331c59cb9e41371bd241018a3231de /src/skel/glfw/glfw.cpp | |
parent | Use CLOCK_MONOTONIC_FAST when available (FreeBSD) (diff) | |
download | re3-54214dd2c4da79945b9f6b8b3a31ba5ddb8a0b84.tar re3-54214dd2c4da79945b9f6b8b3a31ba5ddb8a0b84.tar.gz re3-54214dd2c4da79945b9f6b8b3a31ba5ddb8a0b84.tar.bz2 re3-54214dd2c4da79945b9f6b8b3a31ba5ddb8a0b84.tar.lz re3-54214dd2c4da79945b9f6b8b3a31ba5ddb8a0b84.tar.xz re3-54214dd2c4da79945b9f6b8b3a31ba5ddb8a0b84.tar.zst re3-54214dd2c4da79945b9f6b8b3a31ba5ddb8a0b84.zip |
Diffstat (limited to 'src/skel/glfw/glfw.cpp')
-rw-r--r-- | src/skel/glfw/glfw.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
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 ) |