mirror of
https://github.com/GTAmodding/re3.git
synced 2024-12-26 09:25:42 +00:00
Fix mouse lock/high-dpi
This commit is contained in:
parent
2ce9e540da
commit
54214dd2c4
2 changed files with 26 additions and 16 deletions
|
@ -1188,8 +1188,8 @@ 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;
|
||||||
|
|
|
@ -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