From 6bed0cfa659271a80b286ed47db0f1dafb977dc6 Mon Sep 17 00:00:00 2001 From: pinumbernumber <1337rz@gmail.com> Date: Tue, 27 Aug 2013 14:38:20 +0100 Subject: [PATCH] More small adjustments to joypad drivers --- input/dinput.c | 12 ++++++++---- input/winxinput_joypad.c | 14 ++++++++------ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/input/dinput.c b/input/dinput.c index 487a179e5a..f71d690ae0 100644 --- a/input/dinput.c +++ b/input/dinput.c @@ -394,8 +394,11 @@ static BOOL CALLBACK enum_axes_cb(const DIDEVICEOBJECTINSTANCE *inst, void *p) return DIENUM_CONTINUE; } -// Is there a better way of detecting dual XInput/DInput pads? This is going to get -// outdated, for example when the Xbox One controller becomes available. +// TODO: Use a better way of detecting dual XInput/DInput pads. This current method +// will not work correctly for third-party controllers or future MS pads (Xbox One?). +// An example of this is provided in the DX SDK, which advises "Enum each PNP device +// using WMI and check each device ID to see if it contains "IG_"". Unfortunately the +// example code is a horrible unsightly mess. static const char* const XINPUT_PAD_NAMES[] = { "Controller (Gamepad for Xbox 360)", @@ -452,6 +455,8 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p) if (last_xbox_pad_index < 4) g_xbox_pad_indexes[g_joypad_cnt] = last_xbox_pad_index; ++last_xbox_pad_index; + + goto enum_iteration_done; } #endif @@ -472,9 +477,8 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p) input_config_autoconfigure_joypad(g_joypad_cnt, dinput_joypad_name(g_joypad_cnt), dinput_joypad.ident); } - +enum_iteration_done: g_joypad_cnt++; - return DIENUM_CONTINUE; } diff --git a/input/winxinput_joypad.c b/input/winxinput_joypad.c index 2f0956bb3f..48b8e8dceb 100644 --- a/input/winxinput_joypad.c +++ b/input/winxinput_joypad.c @@ -108,12 +108,14 @@ static int pad_index_to_xplayer_index(unsigned pad) return g_xbox_pad_indexes[pad]; } +// Generic "XInput" instead of "Xbox 360", because there are +// some other non-xbox third party PC controllers. static const char* const XBOX_CONTROLLER_NAMES[4] = { - "Xbox 360 Controller (Player 1)", - "Xbox 360 Controller (Player 2)", - "Xbox 360 Controller (Player 3)", - "Xbox 360 Controller (Player 4)" + "XInput Controller (Player 1)", + "XInput Controller (Player 2)", + "XInput Controller (Player 3)", + "XInput Controller (Player 4)" }; const char* winxinput_joypad_name (unsigned pad) @@ -169,8 +171,8 @@ static bool winxinput_joypad_init(void) if (!g_XInputGetStateEx) { - // no ordinal 100. (Old version of x360ce perhaps?) Load the ordinary XInputGetState, - // at the cost of losing guide button support. + // no ordinal 100. (Presumably a wrapper.) Load the ordinary + // XInputGetState, at the cost of losing guide button support. g_winxinput_guide_button_supported = false; g_XInputGetStateEx = (XInputGetStateEx_t) GetProcAddress(g_winxinput_dll, "XInputGetState"); if (!g_XInputGetStateEx)