diff --git a/src/common/input/InputManager.h b/src/common/input/InputManager.h index e3db17fea..b8638728d 100644 --- a/src/common/input/InputManager.h +++ b/src/common/input/InputManager.h @@ -39,6 +39,17 @@ extern int dev_num_buttons[to_underlying(XBOX_INPUT_DEVICE::DEVICE_MAX)]; +typedef struct _input_controller { + XBOX_INPUT_DEVICE type; + const char* name; +} input_controller; + +static input_controller input_support_list[] = { + { XBOX_INPUT_DEVICE::DEVICE_INVALID, "None" }, + { XBOX_INPUT_DEVICE::MS_CONTROLLER_DUKE, "MS Controller Duke" }, + { XBOX_INPUT_DEVICE::MS_CONTROLLER_S, "MS Controller S" }, +}; + #pragma pack(1) // xpad in/out buffers stripped of the first two bytes diff --git a/src/gui/DlgInputConfig.cpp b/src/gui/DlgInputConfig.cpp index 83e437ee1..0301298f6 100644 --- a/src/gui/DlgInputConfig.cpp +++ b/src/gui/DlgInputConfig.cpp @@ -114,11 +114,11 @@ INT_PTR CALLBACK DlgInputConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPAR for (int i = 0, j = 0; i != 4; i++) { HWND hHandle = GetDlgItem(hWndDlg, IDC_DEVICE_PORT1 + i); - for (auto str : { "None", "MS Controller Duke", "MS Controller S" }) { - LRESULT index = SendMessage(hHandle, CB_ADDSTRING, 0, reinterpret_cast(str)); + for (auto input : input_support_list) { + LRESULT index = SendMessage(hHandle, CB_ADDSTRING, 0, reinterpret_cast(input.name)); SendMessage(hHandle, CB_SETITEMDATA, index, - to_underlying(XBOX_INPUT_DEVICE::DEVICE_INVALID) + j); - if (g_Settings->m_input_port[i].Type == to_underlying(XBOX_INPUT_DEVICE::DEVICE_INVALID) + j) { + to_underlying(input.type)); + if (g_Settings->m_input_port[i].Type == to_underlying(input.type)) { SendMessage(hHandle, CB_SETCURSEL, index, 0); if (g_Settings->m_input_port[i].Type == to_underlying(XBOX_INPUT_DEVICE::DEVICE_INVALID)) { EnableWindow(GetDlgItem(hWndDlg, IDC_CONFIGURE_PORT1 + i), FALSE);