From e28e4588e501d84409dbd49419775b60045498c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Ro=C3=9F?= Date: Sat, 27 Apr 2024 18:43:53 +0200 Subject: [PATCH 1/3] [Windows,Mouse] Reactivate code to evaluate mouse mode. --- ddio_win/winmouse.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ddio_win/winmouse.cpp b/ddio_win/winmouse.cpp index 437aa070..cfc601bd 100644 --- a/ddio_win/winmouse.cpp +++ b/ddio_win/winmouse.cpp @@ -392,10 +392,10 @@ bool InitNewMouse() { //TODO: This code should be renabled when some solution for mouse capturing is decided on. // The game should free the capture when the cursor is visible, and recapture it when it isn't visible. // Account for the original mode. - //if (DDIO_mouse_state.mode == MOUSE_EXCLUSIVE_MODE) + if (DDIO_mouse_state.mode == MOUSE_EXCLUSIVE_MODE) rawInputDevice.dwFlags = RIDEV_CAPTUREMOUSE | RIDEV_NOLEGACY; - //else - // rawInputDevice.dwFlags = 0; + else + rawInputDevice.dwFlags = 0; rawInputDevice.hwndTarget = DInputData.hwnd; From 318a8f6462de353dabc4689c6038dc286747e6d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Ro=C3=9F?= Date: Sat, 27 Apr 2024 18:54:07 +0200 Subject: [PATCH 2/3] [Windows,Mouse] Removed call to DDIOShowCursor() from ddio_MouseMode() so we can set the mode before ddio_MouseInit() gets called and also prevent overrideing the mode always with MOUSE_STANDARD_MODE. --- ddio_win/winmouse.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/ddio_win/winmouse.cpp b/ddio_win/winmouse.cpp index cfc601bd..49d604a9 100644 --- a/ddio_win/winmouse.cpp +++ b/ddio_win/winmouse.cpp @@ -110,15 +110,6 @@ void DDIOShowCursor(BOOL show) { } void ddio_MouseMode(int mode) { - if (mode == MOUSE_EXCLUSIVE_MODE) { - DDIOShowCursor(FALSE); - } else if (mode == MOUSE_STANDARD_MODE) { - DDIOShowCursor(TRUE); - } else { - Int3(); - return; - } - DDIO_mouse_state.mode = mode; } @@ -446,7 +437,7 @@ bool ddio_MouseInit() { DDIO_mouse_state.cursor_count = ShowCursor(FALSE); } - ddio_MouseMode(MOUSE_STANDARD_MODE); + DDIOShowCursor(DDIO_mouse_state.mode == MOUSE_EXCLUSIVE_MODE ? FALSE : TRUE); DDIO_mouse_state.suspended = false; ddio_MouseReset(); From e5626c88d6d1ce116e4feec062b00869cfa2c234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Ro=C3=9F?= Date: Sat, 27 Apr 2024 18:55:26 +0200 Subject: [PATCH 3/3] [Windows,Mouse] Call ddio_MouseMode() before ddio_MouseInit() so the correct flags get set for RegisterRawInputDevices(). --- Descent3/init.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Descent3/init.cpp b/Descent3/init.cpp index da83633f..b58383fd 100644 --- a/Descent3/init.cpp +++ b/Descent3/init.cpp @@ -1671,6 +1671,14 @@ void InitIOSystems(bool editor) { Descent->set_defer_handler(D3DeferHandler); + if (!editor && !FindArg("-windowed")) { + if (Dedicated_server) { + ddio_MouseMode(MOUSE_STANDARD_MODE); + } else { + ddio_MouseMode(MOUSE_EXCLUSIVE_MODE); + } + } + // do io init stuff io_info.obj = Descent; io_info.use_lo_res_time = (bool)(FindArg("-lorestimer") != 0); @@ -1680,14 +1688,6 @@ void InitIOSystems(bool editor) { Error("I/O initialization failed."); } - if (!editor && !FindArg("-windowed")) { - if (Dedicated_server) { - ddio_MouseMode(MOUSE_STANDARD_MODE); - } else { - ddio_MouseMode(MOUSE_EXCLUSIVE_MODE); - } - } - int rocknride_arg = FindArg("-rocknride"); if (rocknride_arg) { int comm_port = atoi(GameArgs[rocknride_arg + 1]); @@ -2544,6 +2544,14 @@ void RestartD3() { mprintf((0, "Restarting D3...\n")); + if (!FindArg("-windowed")) { + if (Dedicated_server) { + ddio_MouseMode(MOUSE_STANDARD_MODE); + } else { + ddio_MouseMode(MOUSE_EXCLUSIVE_MODE); + } + } + // startup io io_info.obj = Descent; io_info.use_lo_res_time = (bool)(FindArg("-lorestimer") != 0); @@ -2553,14 +2561,6 @@ void RestartD3() { Error("I/O initialization failed."); } - if (!FindArg("-windowed")) { - if (Dedicated_server) { - ddio_MouseMode(MOUSE_STANDARD_MODE); - } else { - ddio_MouseMode(MOUSE_EXCLUSIVE_MODE); - } - } - // startup screen. ddvid_Init(Descent, App_ddvid_subsystem); ddio_KeyFlush();