]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Fix sometimes missing gameports remap entries, always select digital direction if...
authorToni Wilen <twilen@winuae.net>
Sun, 31 Aug 2025 09:05:36 +0000 (12:05 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 31 Aug 2025 09:05:36 +0000 (12:05 +0300)
include/inputdevice.h
inputdevice.cpp
od-win32/win32gui.cpp

index a0bc70657364b24504c42ada8c29662ed7e1f77a..832d75043c6aececf2f7905559e0af5f0f4cf7bf 100644 (file)
@@ -373,10 +373,10 @@ extern int handle_custom_event (const TCHAR *custom, int append);
 extern int inputdevice_geteventid(const TCHAR *s);
 extern void inputdevice_playevents(void);
 
-extern int inputdevice_testread (int*, int*, int*, bool);
-extern int inputdevice_istest (void);
-extern void inputdevice_settest (int);
-extern int inputdevice_testread_count (void);
+extern int inputdevice_testread(int*, int*, int*, bool);
+extern int inputdevice_istest(void);
+extern void inputdevice_settest(bool, bool);
+extern int inputdevice_testread_count(void);
 
 bool target_can_autoswitchdevice(void);
 void target_inputdevice_acquire(void);
index 32d7744e45d1e9a3b4fc1c83eea30282d3f6fd15..150558ea1a4996232fe1c31a0f47b8330b0449a8 100644 (file)
@@ -153,7 +153,7 @@ static int joymodes[MAX_JPORTS][MAX_JPORT_DEVS], joysubmodes[MAX_JPORTS][MAX_JPO
 static const int *joyinputs[MAX_JPORTS];
 
 static int input_acquired;
-static int testmode;
+static int testmode, testmode_oneshot;
 struct teststore
 {
        int testmode_type;
@@ -7112,9 +7112,16 @@ int inputdevice_get_compatibility_input (struct uae_prefs *prefs, int index, int
                                if (port - 1 != index)
                                        continue;
                                for (k = 0; axistable[k] >= 0; k += 3) {
-                                       if (evtnum2 == axistable[k] || evtnum2 == axistable[k + 1] || evtnum2 == axistable[k + 2]) {
+                                       if (evtnum2 == axistable[k + 0]) {
                                                for (l = 0; inputlist[l] >= 0; l++) {
-                                                       if (inputlist[l] == axistable[k] || inputlist[l] == axistable[k + 1] || inputlist[l] == axistable[k + 1]) {
+                                                       if (inputlist[l] == axistable[k + 1] || inputlist[l] == axistable[k + 2]) {
+                                                               ignore = true;
+                                                       }
+                                               }
+                                       }
+                                       if (evtnum2 == axistable[k + 1] || evtnum2 == axistable[k + 2]) {
+                                               for (l = 0; inputlist[l] >= 0; l++) {
+                                                       if (inputlist[l] == axistable[k + 0]) {
                                                                ignore = true;
                                                        }
                                                }
@@ -9491,8 +9498,14 @@ static void inputdevice_testrecord_test(int type, int num, int wtype, int wnum,
                testmode = -1;
                return;
        }
-       if (testmode_count >= TESTMODE_MAX)
+
+       if (testmode_count >= TESTMODE_MAX) {
                return;
+       }
+       if (testmode_oneshot && testmode_count > 0) {
+               return;
+       }
+
        if (type == IDTYPE_KEYBOARD) {
                if (wnum >= 0x100) {
                        wnum = 0x100 - wnum;
@@ -9535,6 +9548,7 @@ static void inputdevice_testrecord_test(int type, int num, int wtype, int wnum,
        }
 
        //write_log (_T("%d %d %d %d %d/%d\n"), type, num, wtype, wnum, state, max);
+
        struct teststore *ts = &testmode_data[testmode_count];
        ts->testmode_type = type;
        ts->testmode_num = num;
@@ -9559,10 +9573,11 @@ int inputdevice_istest (void)
 {
        return testmode;
 }
-void inputdevice_settest (int set)
+void inputdevice_settest (bool set, bool singleevent)
 {
-       testmode = set;
+       testmode = set ? 1 : 0;
        testmode_count = 0;
+       testmode_oneshot = singleevent ? 1 : 0;
        testmode_wait[0].testmode_num = -1;
        testmode_wait[1].testmode_num = -1;
 }
index c67a8425ddc892f169c69348be7de95ce92319d5..ee7946e4f8904f9adac30d6b5d382c76e00bbe81 100644 (file)
@@ -18983,7 +18983,7 @@ static void showextramap (HWND hDlg)
        SetWindowText (GetDlgItem (hDlg, IDC_INPUTMAPOUTM), out);
 }
 
-static void input_find (HWND hDlg, HWND mainDlg, int mode, int set, bool oneshot);
+static void input_find(HWND hDlg, HWND mainDlg, int mode, int set, bool oneshot, bool firsteventonly);
 static int rawmode;
 static int inputmap_remap_counter, inputmap_view_offset;
 static int inputmap_remap_event;
@@ -19045,7 +19045,7 @@ static void CALLBACK timerfunc (HWND hDlg, UINT uMsg, UINT_PTR idEvent, DWORD dw
        if (GetWindowInfo (myDlg, &pwi)) {
                // GUI inactive = disable capturing
                if (pwi.dwWindowStatus != WS_ACTIVECAPTION) {
-                       input_find (hDlg, myDlg, 0, false, false);
+                       input_find (hDlg, myDlg, 0, false, false, false);
                        return;
                }
        }
@@ -19054,7 +19054,7 @@ static void CALLBACK timerfunc (HWND hDlg, UINT uMsg, UINT_PTR idEvent, DWORD dw
        int devnum, wtype, state;
        int cnt = inputdevice_testread_count ();
        if (cnt < 0) {
-               input_find (hDlg, myDlg, 0, FALSE, false);
+               input_find (hDlg, myDlg, 0, false, false, false);
                return;
        }
        if (!cnt)
@@ -19062,7 +19062,7 @@ static void CALLBACK timerfunc (HWND hDlg, UINT uMsg, UINT_PTR idEvent, DWORD dw
        int ret = inputdevice_testread (&devnum, &wtype, &state, true);
        if (ret > 0) {
                if (wtype == INPUTMAP_F12) {
-                       input_find (hDlg, myDlg, 0, FALSE, false);
+                       input_find (hDlg, myDlg, 0, false, false, false);
                        return;
                }
                if (input_selected_widget != devnum || input_selected_widget != wtype) {
@@ -19085,7 +19085,7 @@ static void CALLBACK timerfunc (HWND hDlg, UINT uMsg, UINT_PTR idEvent, DWORD dw
                                inputmap_remap_event = 0;
                                inputdevice_generate_jport_custom(&workprefs, inputmap_port);
                                InitializeListView (myDlg);
-                               input_find (hDlg, myDlg, 0, FALSE, false);
+                               input_find (hDlg, myDlg, 0, false, false, false);
                                return;
 
                        } else if (inputmap == 1) { // ports panel / remap
@@ -19184,10 +19184,10 @@ static void CALLBACK timerfunc (HWND hDlg, UINT uMsg, UINT_PTR idEvent, DWORD dw
                                //write_log (_T("%d %d %d %d %d\n"), input_selected_device, input_selected_widget, type, evtnum, type2);
 
                                // if this and previous are same axis and they match (up/down or left/right)
-                               // and not oneshot mode
+                               // and not oneshot mode: merge to single axis
                                if (!inputmap_oneshot && (inputmap_remap_counter & 1) == 1) {
                                        if (type2 == IDEV_WIDGET_BUTTONAXIS && prevtype2 == IDEV_WIDGET_BUTTONAXIS) {
-                                               if (axisevent == prevaxisevent && (axisstate > 0 && prevaxisstate < 0)) {
+                                               if (axisevent == prevaxisevent && ((axisstate > 0 && prevaxisstate < 0) || (axisstate < 0 && prevaxisstate > 0))) {
                                                        if ((type == IDEV_WIDGET_BUTTONAXIS && prevtype == IDEV_WIDGET_BUTTONAXIS) ||
                                                                (type == IDEV_WIDGET_AXIS && prevtype == IDEV_WIDGET_AXIS)) {
                                                                for (int i = 0; i < wcnt; i++) {
@@ -19213,7 +19213,7 @@ static void CALLBACK timerfunc (HWND hDlg, UINT uMsg, UINT_PTR idEvent, DWORD dw
                                InitializeListView (hDlg);
                                inputmap_remap_counter++;
                                if (inputmap_remap_counter >= max || inputmap_oneshot) {
-                                       input_find (hDlg, myDlg, 0, FALSE, false);
+                                       input_find (hDlg, myDlg, 0, false, false, false);
                                        return;
                                }
                                
@@ -19305,7 +19305,7 @@ static void CALLBACK timerfunc (HWND hDlg, UINT uMsg, UINT_PTR idEvent, DWORD dw
                                ListView_SetItemState (list, -1, 0, LVIS_SELECTED | LVIS_FOCUSED);
                                ListView_SetItemState (list, itemindex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
                                if (rawmode == 1) {
-                                       input_find (hDlg, myDlg, 0, FALSE, false);
+                                       input_find (hDlg, myDlg, 0, false, false, false);
                                        if (IsWindowEnabled (GetDlgItem (hDlg, IDC_INPUTAMIGA))) {
                                                setfocus (hDlg, IDC_INPUTAMIGA);
                                                xSendDlgItemMessage (hDlg, IDC_INPUTAMIGA, CB_SHOWDROPDOWN , TRUE, 0L);
@@ -19348,14 +19348,14 @@ static void inputmap_disable (HWND hDlg, bool disable)
        }
 }
 
-static void input_find (HWND hDlg, HWND mainDlg, int mode, int set, bool oneshot)
+static void input_find(HWND hDlg, HWND mainDlg, int mode, int set, bool oneshot, bool firsteventonly)
 {
        static TCHAR tmp[200];
        if (set && !rawmode) {
                rawmode = mode ? 2 : 1;
                inputmap_oneshot = oneshot;
                inputmap_disable (hDlg, true);
-               inputdevice_settest (TRUE);
+               inputdevice_settest(true, firsteventonly);
                inputdevice_acquire (mode ? -1 : -2);
                TCHAR tmp2[MAX_DPATH];
                GetWindowText (guiDlg, tmp, sizeof tmp / sizeof (TCHAR));
@@ -19376,7 +19376,7 @@ static void input_find (HWND hDlg, HWND mainDlg, int mode, int set, bool oneshot
                inputdevice_unacquire ();
                rawinput_release();
                inputmap_disable (hDlg, false);
-               inputdevice_settest (FALSE);
+               inputdevice_settest(false, 0);
                SetWindowText (mainDlg, tmp);
                SetFocus (hDlg);
                rawmode = FALSE;
@@ -19677,7 +19677,7 @@ static INT_PTR CALLBACK InputMapDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA
                break;
        }
        case WM_DESTROY:
-               input_find (hDlg, hDlg, 0, false, false);
+               input_find (hDlg, hDlg, 0, false, false, false);
                pages[INPUTMAP_ID] =  NULL;
                inputmap_port_remap = -1;
                inputmap_remap_counter = -1;
@@ -19695,7 +19695,7 @@ static INT_PTR CALLBACK InputMapDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA
                                                inputmap_selected = lv->iItem;
                                                inputmap_remap_counter = getremapcounter (lv->iItem);
                                                if (JSEM_ISCUSTOM(inputmap_port, 0, &workprefs)) {
-                                                       input_find (hDlg, hDlg, 1, true, true);
+                                                       input_find (hDlg, hDlg, 1, true, true, true);
                                                }
                                                if (inputmapselected_old < 0)
                                                        ew(hDlg, IDC_INPUTMAP_SPECIALS, TRUE);
@@ -19731,7 +19731,7 @@ static INT_PTR CALLBACK InputMapDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA
                        inputmap_port_remap = -1;
                        inputmap_remap_counter = -1;
                        inputmap_view_offset = 0;
-                       input_find (hDlg, hDlg, 0, true, false);
+                       input_find (hDlg, hDlg, 0, true, false, false);
                        break;
                        case IDC_INPUTMAP_CAPTURE:
                        if (inputmap_remap_counter < 0)
@@ -19743,7 +19743,7 @@ static INT_PTR CALLBACK InputMapDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA
                        ListView_EnsureVisible (h, inputmap_remap_counter, FALSE);
                        ListView_SetItemState (h, -1, 0, LVIS_SELECTED | LVIS_FOCUSED);
                        ListView_SetItemState (h, inputmap_remap_counter, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
-                       input_find (hDlg, hDlg, 1, true, false);
+                       input_find (hDlg, hDlg, 1, true, false, false);
                        break;
                        case IDC_INPUTMAP_SPECIALS:
                        input_remapspecials(hDlg);
@@ -19761,7 +19761,7 @@ static INT_PTR CALLBACK InputMapDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA
                                        inputmap_remap_counter = -2;
                                        inputmap_remap_event = i;
                                        inputmap_port_remap = inputmap_port;
-                                       input_find (hDlg, hDlg, 1, true, false);
+                                       input_find (hDlg, hDlg, 1, true, false, true);
                                        break;
                                }
                                i++;
@@ -20181,7 +20181,7 @@ static INT_PTR CALLBACK InputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
                recursive--;
                return TRUE;
        case WM_DESTROY:
-               input_find (hDlg, guiDlg, 0, false, false);
+               input_find(hDlg, guiDlg, 0, false, false, false);
                break;
        case WM_COMMAND:
                if (recursive)
@@ -20191,10 +20191,10 @@ static INT_PTR CALLBACK InputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
                {
                case IDC_INPUTREMAP:
                        input_selected_event = -1;
-                       input_find (hDlg, guiDlg, 0, true, false);
+                       input_find(hDlg, guiDlg, 0, true, false, false);
                        break;
                case IDC_INPUTTEST:
-                       input_find (hDlg, guiDlg, 1, true, false);
+                       input_find(hDlg, guiDlg, 1, true, false, false);
                        break;
                case IDC_INPUTCOPY:
                        input_copy (hDlg);