From: Toni Wilen Date: Sun, 6 Jun 2010 17:47:27 +0000 (+0300) Subject: gameports remap updates X-Git-Tag: 2200~13 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=f8eb797b130ee37fdc3070cb55e0cf4c7ad860f3;p=francis%2Fwinuae.git gameports remap updates --- diff --git a/include/inputdevice.h b/include/inputdevice.h index e9a3b437..c57505b1 100644 --- a/include/inputdevice.h +++ b/include/inputdevice.h @@ -71,7 +71,8 @@ struct inputevent { #define ID_AXIS_TOTAL 32 extern int inputdevice_iterate (int devnum, int num, TCHAR *name, int *af); -extern int inputdevice_set_mapping (int devnum, int num, TCHAR *name, TCHAR *custom, int flags, int port, int sub); +extern bool inputdevice_set_gameports_mapping (struct uae_prefs *prefs, int devnum, int num, const TCHAR *name, int port); +extern int inputdevice_set_mapping (int devnum, int num, const TCHAR *name, TCHAR *custom, int flags, int port, int sub); extern int inputdevice_get_mapped_name (int devnum, int num, int *pflags, int *port, TCHAR *name, TCHAR *custom, int sub); extern void inputdevice_copyconfig (const struct uae_prefs *src, struct uae_prefs *dst); extern void inputdevice_copy_single_config (struct uae_prefs *p, int src, int dst, int devnum); diff --git a/inputdevice.cpp b/inputdevice.cpp index 8e116dfa..7ffacfca 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -3755,6 +3755,7 @@ static void cleardevkbrgp (struct uae_input_device *uid, int num, bool nocustom, } } +// remove all gameports mappings mapped to port 'index' static void remove_custom_config (struct uae_prefs *prefs, bool nocustom, int index) { for (int l = 0; l < MAX_INPUT_DEVICES; l++) { @@ -4274,6 +4275,31 @@ static void matchdevices_all (struct uae_prefs *prefs) } } +bool inputdevice_set_gameports_mapping (struct uae_prefs *prefs, int devnum, int num, const TCHAR *name, int port) +{ + joysticks = prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS]; + mice = prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS]; + keyboards = prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS]; + + int sub = 0; + if (inputdevice_get_widget_type (devnum, num, NULL) != IDEV_WIDGET_KEY) { + for (sub = 0; sub < MAX_INPUT_SUB_EVENT; sub++) { + if (!inputdevice_get_mapped_name (devnum, num, NULL, NULL, NULL, NULL, sub)) + break; + } + } + if (sub >= MAX_INPUT_SUB_EVENT) + sub = MAX_INPUT_SUB_EVENT - 1; + inputdevice_set_mapping (devnum, num, name, NULL, IDEV_MAPPED_GAMEPORTSCUSTOM, port + 1, sub); + + joysticks = prefs->joystick_settings[prefs->input_selected_setting]; + mice = prefs->mouse_settings[prefs->input_selected_setting]; + keyboards = prefs->keyboard_settings[prefs->input_selected_setting]; + if (prefs->input_selected_setting != GAMEPORT_INPUT_SETTINGS) + inputdevice_set_mapping (devnum, num, name, NULL, IDEV_MAPPED_GAMEPORTSCUSTOM, port + 1, 0); + return true; +} + void inputdevice_updateconfig (struct uae_prefs *prefs) { int i; @@ -4893,7 +4919,7 @@ int inputdevice_get_mapped_name (int devnum, int num, int *pflags, int *pport, T } // set event name/custom/flags to devnum/num/sub -int inputdevice_set_mapping (int devnum, int num, TCHAR *name, TCHAR *custom, int flags, int port, int sub) +int inputdevice_set_mapping (int devnum, int num, const TCHAR *name, TCHAR *custom, int flags, int port, int sub) { const struct inputdevice_functions *idf = getidf (devnum); const struct uae_input_device *uid = get_uid (idf, inputdevice_get_device_index (devnum)); diff --git a/od-win32/dinput.cpp b/od-win32/dinput.cpp index 8f99d82c..54846f97 100644 --- a/od-win32/dinput.cpp +++ b/od-win32/dinput.cpp @@ -219,9 +219,12 @@ static int register_rawinput (int flags) rid[num].usUsage = 6; if (!rawkb) { rid[num].dwFlags = RIDEV_REMOVE; - } else if (hMainWnd) { - rid[num].dwFlags = RIDEV_INPUTSINK | RIDEV_NOHOTKEYS; - rid[num].hwndTarget = hMainWnd; + } else { + if (hMainWnd) { + rid[num].dwFlags = RIDEV_INPUTSINK; + rid[num].hwndTarget = hMainWnd; + } + rid[num].dwFlags |= RIDEV_NOHOTKEYS; } num++; } diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index 9e917e49..3a6a2b9c 100644 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -1028,7 +1028,7 @@ IDD_INPUTMAP DIALOGEX 0, 0, 300, 240 STYLE DS_LOCALEDIT | DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - CONTROL "",IDC_INPUTMAPLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,0,1,299,215 + CONTROL "",IDC_INPUTMAPLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,0,1,299,215 EDITTEXT IDC_INPUTMAPOUT,0,222,299,14,ES_AUTOHSCROLL | WS_DISABLED END diff --git a/od-win32/win32.h b/od-win32/win32.h index 47973b7f..99f6e12f 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -19,7 +19,7 @@ #define LANG_DLL 1 #define WINUAEBETA L"7" -#define WINUAEDATE MAKEBD(2010, 6, 5) +#define WINUAEDATE MAKEBD(2010, 6, 6) #define WINUAEEXTRA L"" #define WINUAEREV L"" diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index b39a7d2f..95e4052b 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -3164,14 +3164,15 @@ static void update_listview_input (HWND hDlg) static int inputmap_port = -1, inputmap_port_remap = -1; static int inputmap_handle (HWND list, int currentdevnum, int currentwidgetnum, int *inputmap_portp, int *inputmap_indexp, int state) { - int cnt, portnum; + int cntitem, cntgroup, portnum; int mode, *events, *axistable; bool found2 = false; for (portnum = 0; portnum < 4; portnum++) { if (list) portnum = inputmap_port; - cnt = 1; + cntitem = 1; + cntgroup = 1; if (inputdevice_get_compatibility_input (&workprefs, portnum, &mode, &events, &axistable)) { int evtnum; for (int i = 0; (evtnum = events[i]) >= 0; i++) { @@ -3184,16 +3185,19 @@ static int inputmap_handle (HWND list, int currentdevnum, int currentwidgetnum, int atpidx; int item; bool found = false; - TCHAR target[MAX_DPATH]; - target[0] = 0; if (list) { - lvstruct.mask = LVIF_TEXT | LVIF_PARAM; - lvstruct.pszText = (TCHAR*)evt->name; + LVGROUP group; + group.cbSize = sizeof(LVGROUP); + group.mask = LVGF_HEADER | LVGF_GROUPID; + group.pszHeader = (TCHAR*)evt->name; + group.iGroupId = cntgroup; + ListView_InsertGroup (list, -1, &group); + + lvstruct.mask = LVIF_TEXT | LVIF_PARAM | LVIF_GROUPID; lvstruct.lParam = 0; - lvstruct.iItem = cnt; lvstruct.iSubItem = 0; - item = ListView_InsertItem (list, &lvstruct); + lvstruct.iGroupId = cntgroup; } atpidx = 0; @@ -3212,7 +3216,7 @@ static int inputmap_handle (HWND list, int currentdevnum, int currentwidgetnum, while (atpidx >= 0) { devnum = 0; while ((status = inputdevice_get_device_status (devnum)) >= 0) { - if ((1 || status) && !found) { + if ((1 || status)) { for (int j = 0; j < inputdevice_get_widget_num (devnum); j++) { for (int sub = 0; sub < MAX_INPUT_SUB_EVENT; sub++) { int port; @@ -3221,24 +3225,25 @@ static int inputmap_handle (HWND list, int currentdevnum, int currentwidgetnum, continue; inputdevice_get_widget_type (devnum, j, name); if (list) { - if (_tcslen (target) < MAX_DPATH / 2) { - if (target[0]) - _tcscat (target, L" "); - _tcscat (target, name); - _tcscat (target, L","); - _tcscat (target, inputdevice_get_device_name2 (devnum)); - } - found = true; + TCHAR target[MAX_DPATH]; + _tcscpy (target, name); + _tcscat (target, L", "); + _tcscat (target, inputdevice_get_device_name2 (devnum)); + lvstruct.pszText = target; + lvstruct.iItem = cntgroup * 256 + cntitem; + item = ListView_InsertItem (list, &lvstruct); } else if (currentdevnum == devnum) { if (currentwidgetnum == j) { *inputmap_portp = portnum; - *inputmap_indexp = cnt - 1; + *inputmap_indexp = cntitem - 1; found2 = true; if (state < 0) return 1; state = -1; } } + cntitem++; + found = true; } } } @@ -3248,9 +3253,15 @@ static int inputmap_handle (HWND list, int currentdevnum, int currentwidgetnum, evtnum = *atp++; atpidx--; } - if (found) - ListView_SetItemText (list, item, 1, target); - cnt++; + if (!found) { + if (list) { + lvstruct.pszText = L""; + lvstruct.iItem = cntgroup * 256 + cntitem; + item = ListView_InsertItem (list, &lvstruct); + } + cntitem++; + } + cntgroup++; } } if (list) @@ -3263,6 +3274,9 @@ static int inputmap_handle (HWND list, int currentdevnum, int currentwidgetnum, static void update_listview_inputmap (HWND hDlg) { HWND list = GetDlgItem (hDlg, IDC_INPUTMAPLIST); + + ListView_EnableGroupView (list, TRUE); + inputmap_handle (list, -1, -1, NULL, NULL, 0); } @@ -3273,7 +3287,7 @@ static int clicked_entry = -1; #define HARDDISK_COLUMNS 8 #define DISK_COLUMNS 3 #define MISC2_COLUMNS 2 -#define INPUTMAP_COLUMNS 2 +#define INPUTMAP_COLUMNS 1 #define MAX_COLUMN_HEADING_WIDTH 20 #define LV_LOADSAVE 1 @@ -3344,8 +3358,7 @@ void InitializeListView (HWND hDlg) listview_num_columns = INPUTMAP_COLUMNS; lv_type = LV_INPUTMAP; - WIN32GUI_LoadUIString (IDS_INPUTAMIGAEVENT, column_heading[0], MAX_COLUMN_HEADING_WIDTH); - WIN32GUI_LoadUIString (IDS_INPUTHOSTWIDGET, column_heading[1], MAX_COLUMN_HEADING_WIDTH); + column_heading[0][0] = NULL; list = GetDlgItem (hDlg, IDC_INPUTMAPLIST); } else if (hDlg == pages[MISC2_ID]) { @@ -3426,8 +3439,7 @@ void InitializeListView (HWND hDlg) } else if (lv_type == LV_INPUTMAP) { - listview_column_width[0] = 200; - listview_column_width[1] = 200; + listview_column_width[0] = 400; update_listview_inputmap (hDlg); } else if (lv_type == LV_DISK) { @@ -11162,16 +11174,7 @@ static void CALLBACK timerfunc (HWND hDlg, UINT uMsg, UINT_PTR idEvent, DWORD dw TCHAR name[256]; inputdevice_get_eventname (ie, name); //write_log (L"%d %d %d %s\n", input_selected_device, input_selected_widget, evtnum, name); - int sub = 0; - if (inputdevice_get_widget_type (input_selected_device, input_selected_widget, NULL) != IDEV_WIDGET_KEY) { - for (sub = 0; sub < MAX_INPUT_SUB_EVENT; sub++) { - if (!inputdevice_get_mapped_name (input_selected_device, input_selected_widget, NULL, NULL, NULL, NULL, sub)) - break; - } - } - if (sub >= MAX_INPUT_SUB_EVENT) - sub = MAX_INPUT_SUB_EVENT - 1; - inputdevice_set_mapping (input_selected_device, input_selected_widget, name, NULL, IDEV_MAPPED_GAMEPORTSCUSTOM, inputmap_port + 1, sub); + inputdevice_set_gameports_mapping (&workprefs, input_selected_device, input_selected_widget, name, inputmap_port); InitializeListView (hDlg); inputmap_remap_counter += cntadd; ListView_EnsureVisible (h, inputmap_remap_counter, FALSE);