]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Disable keyboard/game controllers option when not captured.
authorToni Wilen <twilen@winuae.net>
Sun, 19 Feb 2023 16:00:18 +0000 (18:00 +0200)
committerToni Wilen <twilen@winuae.net>
Sun, 19 Feb 2023 16:00:18 +0000 (18:00 +0200)
include/options.h
od-win32/dinput.cpp
od-win32/resources/resource.h
od-win32/resources/winuae.rc
od-win32/win32.cpp
od-win32/win32gfx.cpp
od-win32/win32gui.cpp

index 69b1521b2eb889fd6f8c4927fd98e4fb27236431..c00a70b0230b6ba3096aa62052e15887e0fc00ee 100644 (file)
@@ -866,6 +866,7 @@ struct uae_prefs {
        int win32_active_capture_priority;
        bool win32_active_nocapture_pause;
        bool win32_active_nocapture_nosound;
+       int win32_active_input;
        int win32_inactive_priority;
        bool win32_inactive_pause;
        bool win32_inactive_nosound;
index 5a9e3d08a3d62c13ef33e3e580f1095161955284..e7ccd1d7f6f8b7a08b8b6606af76a82ea38e3bfd 100644 (file)
@@ -2291,6 +2291,10 @@ static void handle_rawinput_2 (RAWINPUT *raw, LPARAM lParam)
                if (rp_isactive ())
                        return;
 #endif
+               if (!istest && !mouseactive && !(currprefs.win32_active_input & 4)) {
+                       return;
+               }
+
                if (num < num_joystick) {
 
                        rawdata = (PCHAR)hid->bRawData;
@@ -2598,6 +2602,12 @@ static void handle_rawinput_2 (RAWINPUT *raw, LPARAM lParam)
                                return;
                        if (isfocus () < 2 && currprefs.input_tablet >= TABLET_MOUSEHACK && (currprefs.input_mouse_untrap & MOUSEUNTRAP_MAGIC))
                                return;
+                       if (!mouseactive && !(currprefs.win32_active_input & 1)) {
+                               if ((currprefs.win32_guikey <= 0 && scancode == DIK_F12) || (scancode == currprefs.win32_guikey)) {
+                                       inputdevice_add_inputcode(AKS_ENTERGUI, 1, NULL);
+                               }
+                               return;
+                       }
                        if (pressed) {
                                di_keycodes[num][scancode] = 1;
                        } else {
@@ -4092,6 +4102,9 @@ static void read_joystick (void)
        if (rp_isactive ())
                return;
 #endif
+       if (!istest && !mouseactive && !(currprefs.win32_active_input & 4)) {
+               return;
+       }
 
        for (i = 0; i < MAX_INPUT_DEVICES; i++) {
                struct didata *did = &di_joystick[i];
index dd191529d8ff1120b42bf106a24131cbca3777a3..73b8f2bb9ab06849774ad7107a2abe2c32de26b0 100644 (file)
 #define IDC_ACTIVE_NOSOUND              1535
 #define IDC_STATECLEAR                  1536
 #define IDC_MINIMIZED_NOJOY             1537
+#define IDC_ACTIVE_NOJOY                1538
+#define IDC_ACTIVE_NOKEYBOARD           1539
 #define IDC_SER_SHARED                  1553
 #define IDC_GUI_RESIZE                  1553
 #define IDC_SER_CTSRTS                  1554
index f4fd8ce3a4ca4cafffad21a2b1ff6a3417aa82d0..573f13281fcf113295805c8ca20f165adeefae87 100644 (file)
@@ -1013,28 +1013,30 @@ IDD_MISC2 DIALOGEX 0, 0, 396, 316
 STYLE DS_LOCALEDIT | DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD
 FONT 8, "MS Sans Serif", 0, 0, 0x1
 BEGIN
-    GROUPBOX        "When Active",IDC_STATIC,1,24,125,105
+    GROUPBOX        "When Active",IDC_STATIC,1,24,125,119
     CTEXT           "Run at priority:",IDC_ACTIVE_PRI,10,35,108,10,SS_CENTERIMAGE | WS_TABSTOP
     COMBOBOX        IDC_ACTIVE_PRIORITY,10,50,108,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
     CTEXT           "Mouse uncaptured:",IDC_STATIC,10,67,101,15,SS_CENTERIMAGE
     CONTROL         "Pause emulation",IDC_ACTIVE_PAUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,84,109,10
     CONTROL         "Disable sound",IDC_ACTIVE_NOSOUND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,98,109,10
-    GROUPBOX        "When Inactive",IDC_STATIC,133,24,126,105
+    GROUPBOX        "When Inactive",IDC_STATIC,133,24,126,119
     CTEXT           "Run at priority:",IDC_INACTIVE_PRI,144,35,107,10,SS_CENTERIMAGE | WS_TABSTOP
     COMBOBOX        IDC_INACTIVE_PRIORITY,144,50,108,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
     CONTROL         "Pause emulation",IDC_INACTIVE_PAUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,143,84,109,10
     CONTROL         "Disable sound",IDC_INACTIVE_NOSOUND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,143,98,109,10
     CONTROL         "Disable game controllers",IDC_INACTIVE_NOJOY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,143,112,109,10
-    GROUPBOX        "When Minimized",IDC_STATIC,269,24,125,105
+    GROUPBOX        "When Minimized",IDC_STATIC,269,24,125,119
     CTEXT           "Run at priority:",IDC_MINIMIZED_PRI,278,36,109,10,SS_CENTERIMAGE | WS_TABSTOP
     COMBOBOX        IDC_MINIMIZED_PRIORITY,278,50,108,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
     CONTROL         "Pause emulation",IDC_MINIMIZED_PAUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,280,84,108,10
     CONTROL         "Disable sound",IDC_MINIMIZED_NOSOUND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,280,98,108,10
     CONTROL         "Disable game controllers",IDC_MINIMIZED_NOJOY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,280,112,107,10
-    GROUPBOX        "File Extension Associations",IDC_STATIC,0,137,260,155
-    CONTROL         "",IDC_ASSOCIATELIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,9,154,238,108
-    PUSHBUTTON      "Associate all",IDC_ASSOCIATE_ON,36,270,85,14
-    PUSHBUTTON      "Deassociate all",IDC_ASSOCIATE_OFF,125,270,85,14
+    GROUPBOX        "File Extension Associations",IDC_STATIC,0,148,260,155
+    CONTROL         "",IDC_ASSOCIATELIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,9,165,238,108
+    PUSHBUTTON      "Associate all",IDC_ASSOCIATE_ON,36,281,85,14
+    PUSHBUTTON      "Deassociate all",IDC_ASSOCIATE_OFF,125,281,85,14
+    CONTROL         "Disable keyboard",IDC_ACTIVE_NOKEYBOARD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,126,109,10
+    CONTROL         "Disable game controllers",IDC_ACTIVE_NOJOY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,112,109,10
 END
 
 IDD_DISK DIALOGEX 0, 0, 396, 316
index 3f1b304b0752b36bb54b710c431e40b46eede11b..e7aba9be979db17d891c32b68ccb177fb0e73f55 100644 (file)
@@ -1249,11 +1249,11 @@ static void winuae_inactive(struct AmigaMonitor *mon, HWND hWnd, int minimized)
                                setpaused(1);
                                sound_closed = 1;
                        } else if (currprefs.win32_iconified_nosound) {
-                               inputdevice_unacquire(true, currprefs.win32_iconified_input);
+                               inputdevice_unacquire(currprefs.win32_iconified_input);
                                setsoundpaused();
                                sound_closed = -1;
                        } else {
-                               inputdevice_unacquire(true, currprefs.win32_iconified_input);
+                               inputdevice_unacquire(currprefs.win32_iconified_input);
                        }
                } else if (mouseactive) {
                        inputdevice_unacquire();
@@ -1270,11 +1270,11 @@ static void winuae_inactive(struct AmigaMonitor *mon, HWND hWnd, int minimized)
                                setpaused(2);
                                sound_closed = 1;
                        } else if (currprefs.win32_inactive_nosound) {
-                               inputdevice_unacquire(true, currprefs.win32_inactive_input);
+                               inputdevice_unacquire(currprefs.win32_inactive_input);
                                setsoundpaused();
                                sound_closed = -1;
                        } else {
-                               inputdevice_unacquire(true, currprefs.win32_inactive_input);
+                               inputdevice_unacquire(currprefs.win32_inactive_input);
                        }
                }
        } else {
@@ -4229,6 +4229,7 @@ void target_default_options (struct uae_prefs *p, int type)
                p->win32_logfile = 0;
                p->win32_active_nocapture_pause = 0;
                p->win32_active_nocapture_nosound = 0;
+               p->win32_active_input = 1 | 2 | 4;
                p->win32_iconified_nosound = 1;
                p->win32_iconified_pause = 1;
                p->win32_iconified_input = 0;
@@ -4340,6 +4341,7 @@ void target_save_options (struct zfile *f, struct uae_prefs *p)
 #endif
        cfgfile_target_dwrite_bool(f, _T("active_not_captured_nosound"), p->win32_active_nocapture_nosound);
        cfgfile_target_dwrite_bool(f, _T("active_not_captured_pause"), p->win32_active_nocapture_pause);
+       cfgfile_target_dwrite(f, _T("active_input"), _T("%d"), p->win32_active_input);
        cfgfile_target_dwrite(f, _T("inactive_priority"), _T("%d"), priorities[p->win32_inactive_priority].value);
        cfgfile_target_dwrite_bool(f, _T("inactive_nosound"), p->win32_inactive_nosound);
        cfgfile_target_dwrite_bool(f, _T("inactive_pause"), p->win32_inactive_pause);
@@ -4536,6 +4538,7 @@ static int target_parse_option_host(struct uae_prefs *p, const TCHAR *option, co
                || cfgfile_yesno(option, value, _T("active_not_captured_nosound"), &p->win32_active_nocapture_nosound)
                || cfgfile_yesno(option, value, _T("inactive_pause"), &p->win32_inactive_pause)
                || cfgfile_yesno(option, value, _T("inactive_nosound"), &p->win32_inactive_nosound)
+               || cfgfile_intval(option, value, _T("active_input"), &p->win32_active_input, 1)
                || cfgfile_intval(option, value, _T("inactive_input"), &p->win32_inactive_input, 1)
                || cfgfile_yesno(option, value, _T("iconified_pause"), &p->win32_iconified_pause)
                || cfgfile_yesno(option, value, _T("iconified_nosound"), &p->win32_iconified_nosound)
index 2a6da46843312a73cb5b7ca005231ac5d8e5f1f5..1f816df3c2f4dde2026e60e012de5d95bfa0e9a1 100644 (file)
@@ -2056,7 +2056,7 @@ static int open_windows(struct AmigaMonitor *mon, bool mousecapture, bool starte
        if (upd > 0) {
                inputdevice_acquire(TRUE);
                if (!isfocus())
-                       inputdevice_unacquire(true, input);
+                       inputdevice_unacquire(input);
        }
 
        if (startpaused)
@@ -2514,6 +2514,7 @@ int check_prefs_changed_gfx(void)
                currprefs.win32_iconified_priority != changed_prefs.win32_iconified_priority ||
                currprefs.win32_active_nocapture_nosound != changed_prefs.win32_active_nocapture_nosound ||
                currprefs.win32_active_nocapture_pause != changed_prefs.win32_active_nocapture_pause ||
+               currprefs.win32_active_input != changed_prefs.win32_active_input ||
                currprefs.win32_inactive_nosound != changed_prefs.win32_inactive_nosound ||
                currprefs.win32_inactive_pause != changed_prefs.win32_inactive_pause ||
                currprefs.win32_inactive_input != changed_prefs.win32_inactive_input ||
@@ -2535,6 +2536,7 @@ int check_prefs_changed_gfx(void)
                currprefs.win32_inactive_priority = changed_prefs.win32_inactive_priority;
                currprefs.win32_iconified_priority = changed_prefs.win32_iconified_priority;
                currprefs.win32_active_nocapture_nosound = changed_prefs.win32_active_nocapture_nosound;
+               currprefs.win32_active_input = changed_prefs.win32_active_input;
                currprefs.win32_active_nocapture_pause = changed_prefs.win32_active_nocapture_pause;
                currprefs.win32_inactive_nosound = changed_prefs.win32_inactive_nosound;
                currprefs.win32_inactive_pause = changed_prefs.win32_inactive_pause;
index 4d262be58ea9c59b4ab43541008fed701a3c96d8..e1e1031e5adfef4bab1221b052faadb213dc713f 100644 (file)
@@ -12433,9 +12433,11 @@ static void enable_for_miscdlg (HWND hDlg)
 
        bool paused = false;
        bool nosound = false;
+       bool activenojoy = (workprefs.win32_active_input & 4) == 0;
+       bool activenokeyboard = (workprefs.win32_active_input & 1) == 0;
        bool nojoy = (workprefs.win32_inactive_input & 4) == 0;
-       ew (hDlg, IDC_ACTIVE_PAUSE, paused == false);
-       ew (hDlg, IDC_ACTIVE_NOSOUND, nosound == false && paused == false);
+       ew(hDlg, IDC_ACTIVE_PAUSE, paused == false);
+       ew(hDlg, IDC_ACTIVE_NOSOUND, nosound == false && paused == false);
        if (!paused) {
                paused = workprefs.win32_active_nocapture_pause;
                if (!nosound)
@@ -12446,13 +12448,20 @@ static void enable_for_miscdlg (HWND hDlg)
                workprefs.win32_active_nocapture_pause = workprefs.win32_active_nocapture_nosound = true;
                nosound = true;
                nojoy = true;
+               workprefs.win32_active_input = 0;
        }
+       ew(hDlg, IDC_ACTIVE_NOJOY, paused == false);
+       ew(hDlg, IDC_ACTIVE_NOKEYBOARD, paused == false);
        if (paused)
                CheckDlgButton (hDlg, IDC_INACTIVE_PAUSE, TRUE);
        if (nosound || paused)
                CheckDlgButton(hDlg, IDC_INACTIVE_NOSOUND, TRUE);
        if (paused || nojoy)
                CheckDlgButton(hDlg, IDC_INACTIVE_NOJOY, TRUE);
+       if (paused || activenojoy)
+               CheckDlgButton(hDlg, IDC_ACTIVE_NOJOY, TRUE);
+       if (paused || activenokeyboard)
+               CheckDlgButton(hDlg, IDC_ACTIVE_NOKEYBOARD, TRUE);
        ew(hDlg, IDC_INACTIVE_PAUSE, paused == false);
        ew(hDlg, IDC_INACTIVE_NOSOUND, nosound == false && paused == false);
        ew(hDlg, IDC_INACTIVE_NOJOY, paused == false);
@@ -12691,6 +12700,8 @@ static void values_to_miscdlg (HWND hDlg)
 
                CheckDlgButton(hDlg, IDC_ACTIVE_PAUSE, workprefs.win32_active_nocapture_pause);
                CheckDlgButton(hDlg, IDC_ACTIVE_NOSOUND, workprefs.win32_active_nocapture_nosound || workprefs.win32_active_nocapture_pause);
+               CheckDlgButton(hDlg, IDC_ACTIVE_NOJOY, (workprefs.win32_active_input & 4) == 0 || workprefs.win32_active_nocapture_pause);
+               CheckDlgButton(hDlg, IDC_ACTIVE_NOKEYBOARD, (workprefs.win32_active_input & 1) == 0 || workprefs.win32_active_nocapture_pause);
                CheckDlgButton(hDlg, IDC_INACTIVE_PAUSE, workprefs.win32_inactive_pause);
                CheckDlgButton(hDlg, IDC_INACTIVE_NOSOUND, workprefs.win32_inactive_nosound || workprefs.win32_inactive_pause);
                CheckDlgButton(hDlg, IDC_INACTIVE_NOJOY, (workprefs.win32_inactive_input & 4) == 0 || workprefs.win32_inactive_pause);
@@ -13055,6 +13066,12 @@ static INT_PTR MiscDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
                        workprefs.win32_inactive_input = ischecked(hDlg, IDC_INACTIVE_NOJOY) ? 0 : 4;
                        enable_for_miscdlg(hDlg);
                        break;
+               case IDC_ACTIVE_NOJOY:
+                       if (!ischecked(hDlg, IDC_ACTIVE_NOJOY))
+                               CheckDlgButton(hDlg, IDC_ACTIVE_NOJOY, BST_UNCHECKED);
+               case IDC_ACTIVE_NOKEYBOARD:
+                       if (!ischecked(hDlg, IDC_ACTIVE_NOKEYBOARD))
+                               CheckDlgButton(hDlg, IDC_ACTIVE_NOKEYBOARD, BST_UNCHECKED);
                case IDC_ACTIVE_NOSOUND:
                        if (!ischecked (hDlg, IDC_ACTIVE_NOSOUND))
                                CheckDlgButton (hDlg, IDC_ACTIVE_PAUSE, BST_UNCHECKED);
@@ -13063,6 +13080,8 @@ static INT_PTR MiscDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
                        if (workprefs.win32_active_nocapture_pause)
                                CheckDlgButton (hDlg, IDC_ACTIVE_NOSOUND, BST_CHECKED);
                        workprefs.win32_active_nocapture_nosound = ischecked (hDlg, IDC_ACTIVE_NOSOUND);
+                       workprefs.win32_active_input = ischecked(hDlg, IDC_ACTIVE_NOJOY) ? 0 : 4;
+                       workprefs.win32_active_input |= ischecked(hDlg, IDC_ACTIVE_NOKEYBOARD) ? 0 : 1;
                        enable_for_miscdlg (hDlg);
                        break;
                case IDC_MINIMIZED_NOJOY: