From: Toni Wilen Date: Fri, 22 Mar 2024 18:37:23 +0000 (+0200) Subject: Release rawinput devices when GUI/dialog/debugger is open, allowing standard Windows... X-Git-Tag: 5300~72 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=61f326510592213c22301e69224d4c7faf7b1c89;p=francis%2Fwinuae.git Release rawinput devices when GUI/dialog/debugger is open, allowing standard Windows shortcufts like Win+E to work. --- diff --git a/debug.cpp b/debug.cpp index 7b7eb30f..efc7125d 100644 --- a/debug.cpp +++ b/debug.cpp @@ -7496,9 +7496,10 @@ void debug (void) #ifdef WITH_PPC uae_ppc_pause(1); #endif - inputdevice_unacquire (); + inputdevice_unacquire(); pause_sound (); setmouseactive(0, 0); + target_inputdevice_unacquire(true); activate_console (); trace_mode = 0; exception_debugging = 0; diff --git a/include/inputdevice.h b/include/inputdevice.h index cba4ff56..2ffce148 100644 --- a/include/inputdevice.h +++ b/include/inputdevice.h @@ -375,7 +375,9 @@ extern int inputdevice_istest (void); extern void inputdevice_settest (int); extern int inputdevice_testread_count (void); -extern bool target_can_autoswitchdevice(void); +bool target_can_autoswitchdevice(void); +void target_inputdevice_acquire(void); +void target_inputdevice_unacquire(bool); bool key_specialpressed(void); bool key_shiftpressed(void); diff --git a/inputdevice.cpp b/inputdevice.cpp index 6eb09a68..a6403c25 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -9281,9 +9281,6 @@ void inputdevice_releasebuttons(void) } } -void target_inputdevice_acquire(void); -void target_inputdevice_unacquire(void); - void inputdevice_acquire (int allmode) { int i; @@ -9343,7 +9340,7 @@ void inputdevice_unacquire(int inputmask) if (!input_acquired) return; - target_inputdevice_unacquire(); + target_inputdevice_unacquire(false); input_acquired = 0; if (!(inputmask & 4)) diff --git a/od-win32/debug_win32.cpp b/od-win32/debug_win32.cpp index b46b3d93..c1c356b4 100644 --- a/od-win32/debug_win32.cpp +++ b/od-win32/debug_win32.cpp @@ -2080,6 +2080,7 @@ int open_debug_window(void) debuggerinitializing = FALSE; if (!hDbgWnd) return 0; + rawinput_release(); InitPages(); ShowPage(0, TRUE); if (!regqueryint (NULL, _T("DebuggerMaximized"), &maximized)) @@ -2094,6 +2095,7 @@ int open_debug_window(void) void close_debug_window(void) { DestroyWindow(hDbgWnd); + rawinput_alloc(); } int console_get_gui (TCHAR *out, int maxlen) diff --git a/od-win32/dinput.cpp b/od-win32/dinput.cpp index f7389b0f..d8c64fd8 100644 --- a/od-win32/dinput.cpp +++ b/od-win32/dinput.cpp @@ -534,10 +534,33 @@ static int doregister_rawinput (bool add) void rawinput_alloc(void) { - doregister_rawinput(true); + if (!rawinput_registered) { + doregister_rawinput(true); + } + //write_log("rawinput_alloc\n"); } void rawinput_release(void) { + UINT num = 0; + int v = GetRegisteredRawInputDevices(NULL, &num, sizeof(RAWINPUTDEVICE)); + if (num) { + PRAWINPUTDEVICE devs = xcalloc(RAWINPUTDEVICE, num); + if (devs) { + int v = GetRegisteredRawInputDevices(devs, &num, sizeof(RAWINPUTDEVICE)); + if (v >= 0) { + for (int i = 0; i < num; i++) { + PRAWINPUTDEVICE dev = devs + i; + dev->dwFlags = RIDEV_REMOVE; + dev->hwndTarget = NULL; + + } + RegisterRawInputDevices(devs, num, sizeof(RAWINPUTDEVICE)); + } + xfree(devs); + } + } + rawinput_registered = false; + //write_log("rawinput_free\n"); } static void cleardid (struct didata *did) @@ -2037,7 +2060,6 @@ static bool initialize_rawinput (void) for (int i = 0; i < num_joystick; i++) sortobjects (&di_joystick[i]); - rawinput_alloc(); return 1; error2: diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index 7df227d5..33775bcf 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -1017,16 +1017,20 @@ bool ismouseactive (void) return mouseactive > 0; } -void target_inputdevice_unacquire(void) +void target_inputdevice_unacquire(bool full) { close_tablet(tablet); tablet = NULL; + if (full) { + rawinput_release(); + } } void target_inputdevice_acquire(void) { struct AmigaMonitor *mon = &AMonitors[0]; - target_inputdevice_unacquire(); + target_inputdevice_unacquire(false); tablet = open_tablet(mon->hAmigaWnd); + rawinput_alloc(); } int getfocusedmonitor(void) diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index a310b61c..9fc4ab2f 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -2420,9 +2420,10 @@ void gui_display (int shortcut) flipgui(1); if (setpaused (7)) { - inputdevice_unacquire (); + inputdevice_unacquire(); + rawinput_release(); wait_keyrelease(); - clearallkeys (); + clearallkeys(); setmouseactive(0, 0); } @@ -2472,18 +2473,19 @@ void gui_display (int shortcut) } } mon->manual_painting_needed--; /* So that WM_PAINT doesn't need to use custom refreshing */ - reset_sound (); - inputdevice_copyconfig (&changed_prefs, &currprefs); - inputdevice_config_change_test (); - clearallkeys (); + reset_sound(); + inputdevice_copyconfig(&changed_prefs, &currprefs); + inputdevice_config_change_test(); + clearallkeys(); flipgui(0); if (resumepaused (7)) { - inputdevice_acquire (TRUE); + inputdevice_acquire(TRUE); setmouseactive(0, 1); } - fpscounter_reset (); - screenshot_free (); - write_disk_history (); + rawinput_alloc(); + fpscounter_reset(); + screenshot_free(); + write_disk_history(); gui_active--; here--; } @@ -19316,6 +19318,7 @@ static void input_find (HWND hDlg, HWND mainDlg, int mode, int set, bool oneshot ShowCursor (TRUE); wait_keyrelease (); inputdevice_unacquire (); + rawinput_release(); inputmap_disable (hDlg, false); inputdevice_settest (FALSE); SetWindowText (mainDlg, tmp); @@ -24166,6 +24169,7 @@ void gui_message (const TCHAR *format,...) pause_sound (); if (flipflop) ShowWindow(mon->hAmigaWnd, SW_MINIMIZE); + rawinput_release(); } if (hwnd == NULL) flags |= MB_TASKMODAL; @@ -24186,6 +24190,7 @@ void gui_message (const TCHAR *format,...) reset_sound (); resume_sound (); setmouseactive(0, focuso > 0 ? 1 : 0); + rawinput_alloc(); } }