From 8b50dcb21bd0fd0ea33c43dfd3691a907efe86dd Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 11 Dec 2019 17:46:54 -0800 Subject: [PATCH] Use the controller product string instead of hard-coding controller names --- src/joystick/hidapi/SDL_hidapi_xbox360.c | 2 +- src/joystick/hidapi/SDL_hidapi_xboxone.c | 2 +- src/joystick/hidapi/SDL_hidapijoystick.c | 187 --------------------- src/joystick/hidapi/SDL_hidapijoystick_c.h | 3 - 4 files changed, 2 insertions(+), 192 deletions(-) diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360.c b/src/joystick/hidapi/SDL_hidapi_xbox360.c index c39cd97f3..b1b26ebdc 100644 --- a/src/joystick/hidapi/SDL_hidapi_xbox360.c +++ b/src/joystick/hidapi/SDL_hidapi_xbox360.c @@ -273,7 +273,7 @@ HIDAPI_DriverXbox360_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint static const char * HIDAPI_DriverXbox360_GetDeviceName(Uint16 vendor_id, Uint16 product_id) { - return HIDAPI_XboxControllerName(vendor_id, product_id); + return NULL; } static SDL_bool SetSlotLED(hid_device *dev, Uint8 slot) diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c index 11bbbc6c9..f5060c030 100644 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -247,7 +247,7 @@ HIDAPI_DriverXboxOne_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint static const char * HIDAPI_DriverXboxOne_GetDeviceName(Uint16 vendor_id, Uint16 product_id) { - return HIDAPI_XboxControllerName(vendor_id, product_id); + return NULL; } static SDL_bool diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index 1cca125c6..39542bb32 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -396,193 +396,6 @@ HIDAPI_ShutdownDiscovery() #endif } - -const char * -HIDAPI_XboxControllerName(Uint16 vendor_id, Uint16 product_id) -{ - static struct - { - Uint32 vidpid; - const char *name; - } names[] = { - { MAKE_VIDPID(0x0079, 0x18d4), "GPD Win 2 X-Box Controller" }, - { MAKE_VIDPID(0x044f, 0xb326), "Thrustmaster Gamepad GP XID" }, - { MAKE_VIDPID(0x045e, 0x028e), "Microsoft X-Box 360 pad" }, - { MAKE_VIDPID(0x045e, 0x028f), "Microsoft X-Box 360 pad v2" }, - { MAKE_VIDPID(0x045e, 0x0291), "Xbox 360 Wireless Receiver (XBOX)" }, - { MAKE_VIDPID(0x045e, 0x02a1), "Microsoft X-Box 360 pad" }, - { MAKE_VIDPID(0x045e, 0x02d1), "Microsoft X-Box One pad" }, - { MAKE_VIDPID(0x045e, 0x02dd), "Microsoft X-Box One pad (Firmware 2015)" }, - { MAKE_VIDPID(0x045e, 0x02e0), "Microsoft X-Box One S pad" }, - { MAKE_VIDPID(0x045e, 0x02e3), "Microsoft X-Box One Elite pad" }, - { MAKE_VIDPID(0x045e, 0x02ea), "Microsoft X-Box One S pad" }, - { MAKE_VIDPID(0x045e, 0x02fd), "Microsoft X-Box One S pad" }, - { MAKE_VIDPID(0x045e, 0x02ff), "Microsoft X-Box One Elite pad" }, - { MAKE_VIDPID(0x045e, 0x0b00), "Microsoft X-Box One Elite Series 2 pad" }, - { MAKE_VIDPID(0x045e, 0x0b05), "Microsoft X-Box One Elite Series 2 pad" }, - { MAKE_VIDPID(0x045e, 0x0719), "Xbox 360 Wireless Receiver" }, - { MAKE_VIDPID(0x046d, 0xc21d), "Logitech Gamepad F310" }, - { MAKE_VIDPID(0x046d, 0xc21e), "Logitech Gamepad F510" }, - { MAKE_VIDPID(0x046d, 0xc21f), "Logitech Gamepad F710" }, - { MAKE_VIDPID(0x046d, 0xc242), "Logitech Chillstream Controller" }, - { MAKE_VIDPID(0x046d, 0xcaa3), "Logitech DriveFx Racing Wheel" }, - { MAKE_VIDPID(0x056e, 0x2004), "Elecom JC-U3613M" }, - { MAKE_VIDPID(0x06a3, 0xf51a), "Saitek P3600" }, - { MAKE_VIDPID(0x0738, 0x4716), "Mad Catz Wired Xbox 360 Controller" }, - { MAKE_VIDPID(0x0738, 0x4718), "Mad Catz Street Fighter IV FightStick SE" }, - { MAKE_VIDPID(0x0738, 0x4726), "Mad Catz Xbox 360 Controller" }, - { MAKE_VIDPID(0x0738, 0x4728), "Mad Catz Street Fighter IV FightPad" }, - { MAKE_VIDPID(0x0738, 0x4736), "Mad Catz MicroCon Gamepad" }, - { MAKE_VIDPID(0x0738, 0x4738), "Mad Catz Wired Xbox 360 Controller (SFIV)" }, - { MAKE_VIDPID(0x0738, 0x4740), "Mad Catz Beat Pad" }, - { MAKE_VIDPID(0x0738, 0x4758), "Mad Catz Arcade Game Stick" }, - { MAKE_VIDPID(0x0738, 0x4a01), "Mad Catz FightStick TE 2" }, - { MAKE_VIDPID(0x0738, 0x9871), "Mad Catz Portable Drum" }, - { MAKE_VIDPID(0x0738, 0xb726), "Mad Catz Xbox controller - MW2" }, - { MAKE_VIDPID(0x0738, 0xb738), "Mad Catz MVC2TE Stick 2" }, - { MAKE_VIDPID(0x0738, 0xbeef), "Mad Catz JOYTECH NEO SE Advanced GamePad" }, - { MAKE_VIDPID(0x0738, 0xcb02), "Saitek Cyborg Rumble Pad - PC/Xbox 360" }, - { MAKE_VIDPID(0x0738, 0xcb03), "Saitek P3200 Rumble Pad - PC/Xbox 360" }, - { MAKE_VIDPID(0x0738, 0xcb29), "Saitek Aviator Stick AV8R02" }, - { MAKE_VIDPID(0x0738, 0xf738), "Super SFIV FightStick TE S" }, - { MAKE_VIDPID(0x07ff, 0xffff), "Mad Catz GamePad" }, - { MAKE_VIDPID(0x0e6f, 0x0105), "HSM3 Xbox360 dancepad" }, - { MAKE_VIDPID(0x0e6f, 0x0113), "Afterglow AX.1 Gamepad for Xbox 360" }, - { MAKE_VIDPID(0x0e6f, 0x011f), "Rock Candy Gamepad Wired Controller" }, - { MAKE_VIDPID(0x0e6f, 0x0131), "PDP EA Sports Controller" }, - { MAKE_VIDPID(0x0e6f, 0x0133), "Xbox 360 Wired Controller" }, - { MAKE_VIDPID(0x0e6f, 0x0139), "Afterglow Prismatic Wired Controller" }, - { MAKE_VIDPID(0x0e6f, 0x013a), "PDP Xbox One Controller" }, - { MAKE_VIDPID(0x0e6f, 0x0146), "Rock Candy Wired Controller for Xbox One" }, - { MAKE_VIDPID(0x0e6f, 0x0147), "PDP Marvel Xbox One Controller" }, - { MAKE_VIDPID(0x0e6f, 0x015c), "PDP Xbox One Arcade Stick" }, - { MAKE_VIDPID(0x0e6f, 0x0161), "PDP Xbox One Controller" }, - { MAKE_VIDPID(0x0e6f, 0x0162), "PDP Xbox One Controller" }, - { MAKE_VIDPID(0x0e6f, 0x0163), "PDP Xbox One Controller" }, - { MAKE_VIDPID(0x0e6f, 0x0164), "PDP Battlefield One" }, - { MAKE_VIDPID(0x0e6f, 0x0165), "PDP Titanfall 2" }, - { MAKE_VIDPID(0x0e6f, 0x0201), "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller" }, - { MAKE_VIDPID(0x0e6f, 0x0213), "Afterglow Gamepad for Xbox 360" }, - { MAKE_VIDPID(0x0e6f, 0x021f), "Rock Candy Gamepad for Xbox 360" }, - { MAKE_VIDPID(0x0e6f, 0x0246), "Rock Candy Gamepad for Xbox One 2015" }, - { MAKE_VIDPID(0x0e6f, 0x02a4), "PDP Wired Controller for Xbox One - Stealth Series" }, - { MAKE_VIDPID(0x0e6f, 0x02a6), "PDP Wired Controller for Xbox One - Camo Series" }, - { MAKE_VIDPID(0x0e6f, 0x02ab), "PDP Controller for Xbox One" }, - { MAKE_VIDPID(0x0e6f, 0x0301), "Logic3 Controller" }, - { MAKE_VIDPID(0x0e6f, 0x0346), "Rock Candy Gamepad for Xbox One 2016" }, - { MAKE_VIDPID(0x0e6f, 0x0401), "Logic3 Controller" }, - { MAKE_VIDPID(0x0e6f, 0x0413), "Afterglow AX.1 Gamepad for Xbox 360" }, - { MAKE_VIDPID(0x0e6f, 0x0501), "PDP Xbox 360 Controller" }, - { MAKE_VIDPID(0x0e6f, 0xf900), "PDP Afterglow AX.1" }, - { MAKE_VIDPID(0x0f0d, 0x000a), "Hori Co. DOA4 FightStick" }, - { MAKE_VIDPID(0x0f0d, 0x000c), "Hori PadEX Turbo" }, - { MAKE_VIDPID(0x0f0d, 0x000d), "Hori Fighting Stick EX2" }, - { MAKE_VIDPID(0x0f0d, 0x0016), "Hori Real Arcade Pro.EX" }, - { MAKE_VIDPID(0x0f0d, 0x001b), "Hori Real Arcade Pro VX" }, - { MAKE_VIDPID(0x0f0d, 0x0063), "Hori Real Arcade Pro Hayabusa (USA) Xbox One" }, - { MAKE_VIDPID(0x0f0d, 0x0067), "HORIPAD ONE" }, - { MAKE_VIDPID(0x0f0d, 0x0078), "Hori Real Arcade Pro V Kai Xbox One" }, - { MAKE_VIDPID(0x0f0d, 0x0084), "HORI Fighting Commander" }, - { MAKE_VIDPID(0x0f0d, 0x0085), "HORI Fighting Commander" }, - { MAKE_VIDPID(0x0f0d, 0x0086), "HORI Fighting Commander" }, - { MAKE_VIDPID(0x1038, 0x1430), "SteelSeries Stratus Duo" }, - { MAKE_VIDPID(0x1038, 0x1431), "SteelSeries Stratus Duo" }, - { MAKE_VIDPID(0x11c9, 0x55f0), "Nacon GC-100XF" }, - { MAKE_VIDPID(0x12ab, 0x0004), "Honey Bee Xbox360 dancepad" }, - { MAKE_VIDPID(0x12ab, 0x0301), "PDP AFTERGLOW AX.1" }, - { MAKE_VIDPID(0x12ab, 0x0303), "Mortal Kombat Klassic FightStick" }, - { MAKE_VIDPID(0x1430, 0x4748), "RedOctane Guitar Hero X-plorer" }, - { MAKE_VIDPID(0x1430, 0xf801), "RedOctane Controller" }, - { MAKE_VIDPID(0x146b, 0x0601), "BigBen Interactive XBOX 360 Controller" }, - { MAKE_VIDPID(0x1532, 0x0037), "Razer Sabertooth" }, - { MAKE_VIDPID(0x1532, 0x0a00), "Razer Atrox Arcade Stick" }, - { MAKE_VIDPID(0x1532, 0x0a03), "Razer Wildcat" }, - { MAKE_VIDPID(0x15e4, 0x3f00), "Power A Mini Pro Elite" }, - { MAKE_VIDPID(0x15e4, 0x3f0a), "Xbox Airflo wired controller" }, - { MAKE_VIDPID(0x15e4, 0x3f10), "Batarang Xbox 360 controller" }, - { MAKE_VIDPID(0x162e, 0xbeef), "Joytech Neo-Se Take2" }, - { MAKE_VIDPID(0x1689, 0xfd00), "Razer Onza Tournament Edition" }, - { MAKE_VIDPID(0x1689, 0xfd01), "Razer Onza Classic Edition" }, - { MAKE_VIDPID(0x1689, 0xfe00), "Razer Sabertooth" }, - { MAKE_VIDPID(0x1bad, 0x0002), "Harmonix Rock Band Guitar" }, - { MAKE_VIDPID(0x1bad, 0x0003), "Harmonix Rock Band Drumkit" }, - { MAKE_VIDPID(0x1bad, 0x0130), "Ion Drum Rocker" }, - { MAKE_VIDPID(0x1bad, 0xf016), "Mad Catz Xbox 360 Controller" }, - { MAKE_VIDPID(0x1bad, 0xf018), "Mad Catz Street Fighter IV SE Fighting Stick" }, - { MAKE_VIDPID(0x1bad, 0xf019), "Mad Catz Brawlstick for Xbox 360" }, - { MAKE_VIDPID(0x1bad, 0xf021), "Mad Cats Ghost Recon FS GamePad" }, - { MAKE_VIDPID(0x1bad, 0xf023), "MLG Pro Circuit Controller (Xbox)" }, - { MAKE_VIDPID(0x1bad, 0xf025), "Mad Catz Call Of Duty" }, - { MAKE_VIDPID(0x1bad, 0xf027), "Mad Catz FPS Pro" }, - { MAKE_VIDPID(0x1bad, 0xf028), "Street Fighter IV FightPad" }, - { MAKE_VIDPID(0x1bad, 0xf02e), "Mad Catz Fightpad" }, - { MAKE_VIDPID(0x1bad, 0xf030), "Mad Catz Xbox 360 MC2 MicroCon Racing Wheel" }, - { MAKE_VIDPID(0x1bad, 0xf036), "Mad Catz MicroCon GamePad Pro" }, - { MAKE_VIDPID(0x1bad, 0xf038), "Street Fighter IV FightStick TE" }, - { MAKE_VIDPID(0x1bad, 0xf039), "Mad Catz MvC2 TE" }, - { MAKE_VIDPID(0x1bad, 0xf03a), "Mad Catz SFxT Fightstick Pro" }, - { MAKE_VIDPID(0x1bad, 0xf03d), "Street Fighter IV Arcade Stick TE - Chun Li" }, - { MAKE_VIDPID(0x1bad, 0xf03e), "Mad Catz MLG FightStick TE" }, - { MAKE_VIDPID(0x1bad, 0xf03f), "Mad Catz FightStick SoulCaliber" }, - { MAKE_VIDPID(0x1bad, 0xf042), "Mad Catz FightStick TES+" }, - { MAKE_VIDPID(0x1bad, 0xf080), "Mad Catz FightStick TE2" }, - { MAKE_VIDPID(0x1bad, 0xf501), "HoriPad EX2 Turbo" }, - { MAKE_VIDPID(0x1bad, 0xf502), "Hori Real Arcade Pro.VX SA" }, - { MAKE_VIDPID(0x1bad, 0xf503), "Hori Fighting Stick VX" }, - { MAKE_VIDPID(0x1bad, 0xf504), "Hori Real Arcade Pro. EX" }, - { MAKE_VIDPID(0x1bad, 0xf505), "Hori Fighting Stick EX2B" }, - { MAKE_VIDPID(0x1bad, 0xf506), "Hori Real Arcade Pro.EX Premium VLX" }, - { MAKE_VIDPID(0x1bad, 0xf900), "Harmonix Xbox 360 Controller" }, - { MAKE_VIDPID(0x1bad, 0xf901), "Gamestop Xbox 360 Controller" }, - { MAKE_VIDPID(0x1bad, 0xf903), "Tron Xbox 360 controller" }, - { MAKE_VIDPID(0x1bad, 0xf904), "PDP Versus Fighting Pad" }, - { MAKE_VIDPID(0x1bad, 0xf906), "MortalKombat FightStick" }, - { MAKE_VIDPID(0x1bad, 0xfa01), "MadCatz GamePad" }, - { MAKE_VIDPID(0x1bad, 0xfd00), "Razer Onza TE" }, - { MAKE_VIDPID(0x1bad, 0xfd01), "Razer Onza" }, - { MAKE_VIDPID(0x24c6, 0x5000), "Razer Atrox Arcade Stick" }, - { MAKE_VIDPID(0x24c6, 0x5300), "PowerA MINI PROEX Controller" }, - { MAKE_VIDPID(0x24c6, 0x5303), "Xbox Airflo wired controller" }, - { MAKE_VIDPID(0x24c6, 0x530a), "Xbox 360 Pro EX Controller" }, - { MAKE_VIDPID(0x24c6, 0x531a), "PowerA Pro Ex" }, - { MAKE_VIDPID(0x24c6, 0x5397), "FUS1ON Tournament Controller" }, - { MAKE_VIDPID(0x24c6, 0x541a), "PowerA Xbox One Mini Wired Controller" }, - { MAKE_VIDPID(0x24c6, 0x542a), "Xbox ONE spectra" }, - { MAKE_VIDPID(0x24c6, 0x543a), "PowerA Xbox One wired controller" }, - { MAKE_VIDPID(0x24c6, 0x5500), "Hori XBOX 360 EX 2 with Turbo" }, - { MAKE_VIDPID(0x24c6, 0x5501), "Hori Real Arcade Pro VX-SA" }, - { MAKE_VIDPID(0x24c6, 0x5502), "Hori Fighting Stick VX Alt" }, - { MAKE_VIDPID(0x24c6, 0x5503), "Hori Fighting Edge" }, - { MAKE_VIDPID(0x24c6, 0x5506), "Hori SOULCALIBUR V Stick" }, - { MAKE_VIDPID(0x24c6, 0x550d), "Hori GEM Xbox controller" }, - { MAKE_VIDPID(0x24c6, 0x550e), "Hori Real Arcade Pro V Kai 360" }, - { MAKE_VIDPID(0x24c6, 0x5510), "Hori Fighting Commander ONE" }, - { MAKE_VIDPID(0x24c6, 0x551a), "PowerA FUSION Pro Controller" }, - { MAKE_VIDPID(0x24c6, 0x561a), "PowerA FUSION Controller" }, - { MAKE_VIDPID(0x24c6, 0x591a), "PowerA FUSION Pro Controller" }, - { MAKE_VIDPID(0x24c6, 0x5b00), "ThrustMaster Ferrari 458 Racing Wheel" }, - { MAKE_VIDPID(0x24c6, 0x5b02), "Thrustmaster, Inc. GPX Controller" }, - { MAKE_VIDPID(0x24c6, 0x5b03), "Thrustmaster Ferrari 458 Racing Wheel" }, - { MAKE_VIDPID(0x24c6, 0x5d04), "Razer Sabertooth" }, - { MAKE_VIDPID(0x24c6, 0x791a), "PowerA Fusion Fight Pad" }, - { MAKE_VIDPID(0x24c6, 0xfafa), "Aplay Controller" }, - { MAKE_VIDPID(0x24c6, 0xfafb), "Aplay Controller" }, - { MAKE_VIDPID(0x24c6, 0xfafc), "Afterglow Gamepad 1" }, - { MAKE_VIDPID(0x24c6, 0xfafd), "Afterglow Gamepad 3" }, - { MAKE_VIDPID(0x24c6, 0xfafe), "Rock Candy Gamepad for Xbox 360" }, - { MAKE_VIDPID(0x2e24, 0x1688), "Hyperkin X91" }, - }; - int i; - Uint32 vidpid = MAKE_VIDPID(vendor_id, product_id); - - for (i = 0; i < SDL_arraysize(names); ++i) { - if (vidpid == names[i].vidpid) { - return names[i].name; - } - } - return NULL; -} - static SDL_bool HIDAPI_IsDeviceSupported(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { diff --git a/src/joystick/hidapi/SDL_hidapijoystick_c.h b/src/joystick/hidapi/SDL_hidapijoystick_c.h index 72fad9c9d..0b141aacc 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick_c.h +++ b/src/joystick/hidapi/SDL_hidapijoystick_c.h @@ -66,9 +66,6 @@ extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne; /* Return true if a HID device is present and supported as a joystick */ extern SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name); -/* Return the name of an Xbox 360 or Xbox One controller */ -extern const char *HIDAPI_XboxControllerName(Uint16 vendor_id, Uint16 product_id); - #endif /* SDL_JOYSTICK_HIDAPI_H */ /* vi: set ts=4 sw=4 expandtab: */