mirror of
https://github.com/halpz/re3.git
synced 2024-12-25 18:05:27 +00:00
Fix mouse lock/high-dpi
This commit is contained in:
parent
2ce9e540da
commit
54214dd2c4
|
@ -1188,12 +1188,12 @@ Idle(void *arg)
|
||||||
|
|
||||||
if(!FrontEndMenuManager.m_bMenuActive && TheCamera.GetScreenFadeStatus() != FADE_2)
|
if(!FrontEndMenuManager.m_bMenuActive && TheCamera.GetScreenFadeStatus() != FADE_2)
|
||||||
{
|
{
|
||||||
#ifdef GTA_PC
|
// This is from SA, but it's nice for windowed mode
|
||||||
// This is from SA, but it's nice for windowed mode
|
#if defined(GTA_PC) && !defined(RW_GL3)
|
||||||
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;
|
||||||
RsMouseSetPos(&pos);
|
RsMouseSetPos(&pos);
|
||||||
#endif
|
#endif
|
||||||
#ifdef NEW_RENDERER
|
#ifdef NEW_RENDERER
|
||||||
if(!gbNewRenderer)
|
if(!gbNewRenderer)
|
||||||
|
|
|
@ -896,9 +896,12 @@ void _InputInitialiseJoys()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int lastCursorMode = GLFW_CURSOR_HIDDEN;
|
||||||
long _InputInitialiseMouse(bool exclusive)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -907,10 +910,17 @@ void _InputShutdownMouse()
|
||||||
// Not needed
|
// Not needed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Not "needs exclusive" on GLFW, but more like "needs to change mode"
|
||||||
bool _InputMouseNeedsExclusive()
|
bool _InputMouseNeedsExclusive()
|
||||||
{
|
{
|
||||||
// That was the cause of infamous mouse bug on Win. Not supported on glfw anyway
|
// That was the cause of infamous mouse bug on Win.
|
||||||
return false;
|
|
||||||
|
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)
|
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
|
// 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
|
||||||
|
@ -1672,8 +1684,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 a new issue