Use the controller product string instead of hard-coding controller names
authorSam Lantinga <slouken@libsdl.org>
Wed, 11 Dec 2019 17:46:54 -0800
changeset 13330c88765bcf1da
parent 13329 732a469df95c
child 13331 a523954cd529
Use the controller product string instead of hard-coding controller names
src/joystick/hidapi/SDL_hidapi_xbox360.c
src/joystick/hidapi/SDL_hidapi_xboxone.c
src/joystick/hidapi/SDL_hidapijoystick.c
src/joystick/hidapi/SDL_hidapijoystick_c.h
     1.1 --- a/src/joystick/hidapi/SDL_hidapi_xbox360.c	Tue Dec 10 13:09:52 2019 -0800
     1.2 +++ b/src/joystick/hidapi/SDL_hidapi_xbox360.c	Wed Dec 11 17:46:54 2019 -0800
     1.3 @@ -273,7 +273,7 @@
     1.4  static const char *
     1.5  HIDAPI_DriverXbox360_GetDeviceName(Uint16 vendor_id, Uint16 product_id)
     1.6  {
     1.7 -    return HIDAPI_XboxControllerName(vendor_id, product_id);
     1.8 +    return NULL;
     1.9  }
    1.10  
    1.11  static SDL_bool SetSlotLED(hid_device *dev, Uint8 slot)
     2.1 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c	Tue Dec 10 13:09:52 2019 -0800
     2.2 +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c	Wed Dec 11 17:46:54 2019 -0800
     2.3 @@ -247,7 +247,7 @@
     2.4  static const char *
     2.5  HIDAPI_DriverXboxOne_GetDeviceName(Uint16 vendor_id, Uint16 product_id)
     2.6  {
     2.7 -    return HIDAPI_XboxControllerName(vendor_id, product_id);
     2.8 +    return NULL;
     2.9  }
    2.10  
    2.11  static SDL_bool
     3.1 --- a/src/joystick/hidapi/SDL_hidapijoystick.c	Tue Dec 10 13:09:52 2019 -0800
     3.2 +++ b/src/joystick/hidapi/SDL_hidapijoystick.c	Wed Dec 11 17:46:54 2019 -0800
     3.3 @@ -396,193 +396,6 @@
     3.4  #endif
     3.5  }
     3.6  
     3.7 -
     3.8 -const char *
     3.9 -HIDAPI_XboxControllerName(Uint16 vendor_id, Uint16 product_id)
    3.10 -{
    3.11 -    static struct
    3.12 -    {
    3.13 -        Uint32 vidpid;
    3.14 -        const char *name;
    3.15 -    } names[] = {
    3.16 -        { MAKE_VIDPID(0x0079, 0x18d4), "GPD Win 2 X-Box Controller" },
    3.17 -        { MAKE_VIDPID(0x044f, 0xb326), "Thrustmaster Gamepad GP XID" },
    3.18 -        { MAKE_VIDPID(0x045e, 0x028e), "Microsoft X-Box 360 pad" },
    3.19 -        { MAKE_VIDPID(0x045e, 0x028f), "Microsoft X-Box 360 pad v2" },
    3.20 -        { MAKE_VIDPID(0x045e, 0x0291), "Xbox 360 Wireless Receiver (XBOX)" },
    3.21 -        { MAKE_VIDPID(0x045e, 0x02a1), "Microsoft X-Box 360 pad" },
    3.22 -        { MAKE_VIDPID(0x045e, 0x02d1), "Microsoft X-Box One pad" },
    3.23 -        { MAKE_VIDPID(0x045e, 0x02dd), "Microsoft X-Box One pad (Firmware 2015)" },
    3.24 -        { MAKE_VIDPID(0x045e, 0x02e0), "Microsoft X-Box One S pad" },
    3.25 -        { MAKE_VIDPID(0x045e, 0x02e3), "Microsoft X-Box One Elite pad" },
    3.26 -        { MAKE_VIDPID(0x045e, 0x02ea), "Microsoft X-Box One S pad" },
    3.27 -        { MAKE_VIDPID(0x045e, 0x02fd), "Microsoft X-Box One S pad" },
    3.28 -        { MAKE_VIDPID(0x045e, 0x02ff), "Microsoft X-Box One Elite pad" },
    3.29 -        { MAKE_VIDPID(0x045e, 0x0b00), "Microsoft X-Box One Elite Series 2 pad" },
    3.30 -        { MAKE_VIDPID(0x045e, 0x0b05), "Microsoft X-Box One Elite Series 2 pad" },
    3.31 -        { MAKE_VIDPID(0x045e, 0x0719), "Xbox 360 Wireless Receiver" },
    3.32 -        { MAKE_VIDPID(0x046d, 0xc21d), "Logitech Gamepad F310" },
    3.33 -        { MAKE_VIDPID(0x046d, 0xc21e), "Logitech Gamepad F510" },
    3.34 -        { MAKE_VIDPID(0x046d, 0xc21f), "Logitech Gamepad F710" },
    3.35 -        { MAKE_VIDPID(0x046d, 0xc242), "Logitech Chillstream Controller" },
    3.36 -        { MAKE_VIDPID(0x046d, 0xcaa3), "Logitech DriveFx Racing Wheel" },
    3.37 -        { MAKE_VIDPID(0x056e, 0x2004), "Elecom JC-U3613M" },
    3.38 -        { MAKE_VIDPID(0x06a3, 0xf51a), "Saitek P3600" },
    3.39 -        { MAKE_VIDPID(0x0738, 0x4716), "Mad Catz Wired Xbox 360 Controller" },
    3.40 -        { MAKE_VIDPID(0x0738, 0x4718), "Mad Catz Street Fighter IV FightStick SE" },
    3.41 -        { MAKE_VIDPID(0x0738, 0x4726), "Mad Catz Xbox 360 Controller" },
    3.42 -        { MAKE_VIDPID(0x0738, 0x4728), "Mad Catz Street Fighter IV FightPad" },
    3.43 -        { MAKE_VIDPID(0x0738, 0x4736), "Mad Catz MicroCon Gamepad" },
    3.44 -        { MAKE_VIDPID(0x0738, 0x4738), "Mad Catz Wired Xbox 360 Controller (SFIV)" },
    3.45 -        { MAKE_VIDPID(0x0738, 0x4740), "Mad Catz Beat Pad" },
    3.46 -        { MAKE_VIDPID(0x0738, 0x4758), "Mad Catz Arcade Game Stick" },
    3.47 -        { MAKE_VIDPID(0x0738, 0x4a01), "Mad Catz FightStick TE 2" },
    3.48 -        { MAKE_VIDPID(0x0738, 0x9871), "Mad Catz Portable Drum" },
    3.49 -        { MAKE_VIDPID(0x0738, 0xb726), "Mad Catz Xbox controller - MW2" },
    3.50 -        { MAKE_VIDPID(0x0738, 0xb738), "Mad Catz MVC2TE Stick 2" },
    3.51 -        { MAKE_VIDPID(0x0738, 0xbeef), "Mad Catz JOYTECH NEO SE Advanced GamePad" },
    3.52 -        { MAKE_VIDPID(0x0738, 0xcb02), "Saitek Cyborg Rumble Pad - PC/Xbox 360" },
    3.53 -        { MAKE_VIDPID(0x0738, 0xcb03), "Saitek P3200 Rumble Pad - PC/Xbox 360" },
    3.54 -        { MAKE_VIDPID(0x0738, 0xcb29), "Saitek Aviator Stick AV8R02" },
    3.55 -        { MAKE_VIDPID(0x0738, 0xf738), "Super SFIV FightStick TE S" },
    3.56 -        { MAKE_VIDPID(0x07ff, 0xffff), "Mad Catz GamePad" },
    3.57 -        { MAKE_VIDPID(0x0e6f, 0x0105), "HSM3 Xbox360 dancepad" },
    3.58 -        { MAKE_VIDPID(0x0e6f, 0x0113), "Afterglow AX.1 Gamepad for Xbox 360" },
    3.59 -        { MAKE_VIDPID(0x0e6f, 0x011f), "Rock Candy Gamepad Wired Controller" },
    3.60 -        { MAKE_VIDPID(0x0e6f, 0x0131), "PDP EA Sports Controller" },
    3.61 -        { MAKE_VIDPID(0x0e6f, 0x0133), "Xbox 360 Wired Controller" },
    3.62 -        { MAKE_VIDPID(0x0e6f, 0x0139), "Afterglow Prismatic Wired Controller" },
    3.63 -        { MAKE_VIDPID(0x0e6f, 0x013a), "PDP Xbox One Controller" },
    3.64 -        { MAKE_VIDPID(0x0e6f, 0x0146), "Rock Candy Wired Controller for Xbox One" },
    3.65 -        { MAKE_VIDPID(0x0e6f, 0x0147), "PDP Marvel Xbox One Controller" },
    3.66 -        { MAKE_VIDPID(0x0e6f, 0x015c), "PDP Xbox One Arcade Stick" },
    3.67 -        { MAKE_VIDPID(0x0e6f, 0x0161), "PDP Xbox One Controller" },
    3.68 -        { MAKE_VIDPID(0x0e6f, 0x0162), "PDP Xbox One Controller" },
    3.69 -        { MAKE_VIDPID(0x0e6f, 0x0163), "PDP Xbox One Controller" },
    3.70 -        { MAKE_VIDPID(0x0e6f, 0x0164), "PDP Battlefield One" },
    3.71 -        { MAKE_VIDPID(0x0e6f, 0x0165), "PDP Titanfall 2" },
    3.72 -        { MAKE_VIDPID(0x0e6f, 0x0201), "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller" },
    3.73 -        { MAKE_VIDPID(0x0e6f, 0x0213), "Afterglow Gamepad for Xbox 360" },
    3.74 -        { MAKE_VIDPID(0x0e6f, 0x021f), "Rock Candy Gamepad for Xbox 360" },
    3.75 -        { MAKE_VIDPID(0x0e6f, 0x0246), "Rock Candy Gamepad for Xbox One 2015" },
    3.76 -        { MAKE_VIDPID(0x0e6f, 0x02a4), "PDP Wired Controller for Xbox One - Stealth Series" },
    3.77 -        { MAKE_VIDPID(0x0e6f, 0x02a6), "PDP Wired Controller for Xbox One - Camo Series" },
    3.78 -        { MAKE_VIDPID(0x0e6f, 0x02ab), "PDP Controller for Xbox One" },
    3.79 -        { MAKE_VIDPID(0x0e6f, 0x0301), "Logic3 Controller" },
    3.80 -        { MAKE_VIDPID(0x0e6f, 0x0346), "Rock Candy Gamepad for Xbox One 2016" },
    3.81 -        { MAKE_VIDPID(0x0e6f, 0x0401), "Logic3 Controller" },
    3.82 -        { MAKE_VIDPID(0x0e6f, 0x0413), "Afterglow AX.1 Gamepad for Xbox 360" },
    3.83 -        { MAKE_VIDPID(0x0e6f, 0x0501), "PDP Xbox 360 Controller" },
    3.84 -        { MAKE_VIDPID(0x0e6f, 0xf900), "PDP Afterglow AX.1" },
    3.85 -        { MAKE_VIDPID(0x0f0d, 0x000a), "Hori Co. DOA4 FightStick" },
    3.86 -        { MAKE_VIDPID(0x0f0d, 0x000c), "Hori PadEX Turbo" },
    3.87 -        { MAKE_VIDPID(0x0f0d, 0x000d), "Hori Fighting Stick EX2" },
    3.88 -        { MAKE_VIDPID(0x0f0d, 0x0016), "Hori Real Arcade Pro.EX" },
    3.89 -        { MAKE_VIDPID(0x0f0d, 0x001b), "Hori Real Arcade Pro VX" },
    3.90 -        { MAKE_VIDPID(0x0f0d, 0x0063), "Hori Real Arcade Pro Hayabusa (USA) Xbox One" },
    3.91 -        { MAKE_VIDPID(0x0f0d, 0x0067), "HORIPAD ONE" },
    3.92 -        { MAKE_VIDPID(0x0f0d, 0x0078), "Hori Real Arcade Pro V Kai Xbox One" },
    3.93 -        { MAKE_VIDPID(0x0f0d, 0x0084), "HORI Fighting Commander" },
    3.94 -        { MAKE_VIDPID(0x0f0d, 0x0085), "HORI Fighting Commander" },
    3.95 -        { MAKE_VIDPID(0x0f0d, 0x0086), "HORI Fighting Commander" },
    3.96 -        { MAKE_VIDPID(0x1038, 0x1430), "SteelSeries Stratus Duo" },
    3.97 -        { MAKE_VIDPID(0x1038, 0x1431), "SteelSeries Stratus Duo" },
    3.98 -        { MAKE_VIDPID(0x11c9, 0x55f0), "Nacon GC-100XF" },
    3.99 -        { MAKE_VIDPID(0x12ab, 0x0004), "Honey Bee Xbox360 dancepad" },
   3.100 -        { MAKE_VIDPID(0x12ab, 0x0301), "PDP AFTERGLOW AX.1" },
   3.101 -        { MAKE_VIDPID(0x12ab, 0x0303), "Mortal Kombat Klassic FightStick" },
   3.102 -        { MAKE_VIDPID(0x1430, 0x4748), "RedOctane Guitar Hero X-plorer" },
   3.103 -        { MAKE_VIDPID(0x1430, 0xf801), "RedOctane Controller" },
   3.104 -        { MAKE_VIDPID(0x146b, 0x0601), "BigBen Interactive XBOX 360 Controller" },
   3.105 -        { MAKE_VIDPID(0x1532, 0x0037), "Razer Sabertooth" },
   3.106 -        { MAKE_VIDPID(0x1532, 0x0a00), "Razer Atrox Arcade Stick" },
   3.107 -        { MAKE_VIDPID(0x1532, 0x0a03), "Razer Wildcat" },
   3.108 -        { MAKE_VIDPID(0x15e4, 0x3f00), "Power A Mini Pro Elite" },
   3.109 -        { MAKE_VIDPID(0x15e4, 0x3f0a), "Xbox Airflo wired controller" },
   3.110 -        { MAKE_VIDPID(0x15e4, 0x3f10), "Batarang Xbox 360 controller" },
   3.111 -        { MAKE_VIDPID(0x162e, 0xbeef), "Joytech Neo-Se Take2" },
   3.112 -        { MAKE_VIDPID(0x1689, 0xfd00), "Razer Onza Tournament Edition" },
   3.113 -        { MAKE_VIDPID(0x1689, 0xfd01), "Razer Onza Classic Edition" },
   3.114 -        { MAKE_VIDPID(0x1689, 0xfe00), "Razer Sabertooth" },
   3.115 -        { MAKE_VIDPID(0x1bad, 0x0002), "Harmonix Rock Band Guitar" },
   3.116 -        { MAKE_VIDPID(0x1bad, 0x0003), "Harmonix Rock Band Drumkit" },
   3.117 -        { MAKE_VIDPID(0x1bad, 0x0130), "Ion Drum Rocker" },
   3.118 -        { MAKE_VIDPID(0x1bad, 0xf016), "Mad Catz Xbox 360 Controller" },
   3.119 -        { MAKE_VIDPID(0x1bad, 0xf018), "Mad Catz Street Fighter IV SE Fighting Stick" },
   3.120 -        { MAKE_VIDPID(0x1bad, 0xf019), "Mad Catz Brawlstick for Xbox 360" },
   3.121 -        { MAKE_VIDPID(0x1bad, 0xf021), "Mad Cats Ghost Recon FS GamePad" },
   3.122 -        { MAKE_VIDPID(0x1bad, 0xf023), "MLG Pro Circuit Controller (Xbox)" },
   3.123 -        { MAKE_VIDPID(0x1bad, 0xf025), "Mad Catz Call Of Duty" },
   3.124 -        { MAKE_VIDPID(0x1bad, 0xf027), "Mad Catz FPS Pro" },
   3.125 -        { MAKE_VIDPID(0x1bad, 0xf028), "Street Fighter IV FightPad" },
   3.126 -        { MAKE_VIDPID(0x1bad, 0xf02e), "Mad Catz Fightpad" },
   3.127 -        { MAKE_VIDPID(0x1bad, 0xf030), "Mad Catz Xbox 360 MC2 MicroCon Racing Wheel" },
   3.128 -        { MAKE_VIDPID(0x1bad, 0xf036), "Mad Catz MicroCon GamePad Pro" },
   3.129 -        { MAKE_VIDPID(0x1bad, 0xf038), "Street Fighter IV FightStick TE" },
   3.130 -        { MAKE_VIDPID(0x1bad, 0xf039), "Mad Catz MvC2 TE" },
   3.131 -        { MAKE_VIDPID(0x1bad, 0xf03a), "Mad Catz SFxT Fightstick Pro" },
   3.132 -        { MAKE_VIDPID(0x1bad, 0xf03d), "Street Fighter IV Arcade Stick TE - Chun Li" },
   3.133 -        { MAKE_VIDPID(0x1bad, 0xf03e), "Mad Catz MLG FightStick TE" },
   3.134 -        { MAKE_VIDPID(0x1bad, 0xf03f), "Mad Catz FightStick SoulCaliber" },
   3.135 -        { MAKE_VIDPID(0x1bad, 0xf042), "Mad Catz FightStick TES+" },
   3.136 -        { MAKE_VIDPID(0x1bad, 0xf080), "Mad Catz FightStick TE2" },
   3.137 -        { MAKE_VIDPID(0x1bad, 0xf501), "HoriPad EX2 Turbo" },
   3.138 -        { MAKE_VIDPID(0x1bad, 0xf502), "Hori Real Arcade Pro.VX SA" },
   3.139 -        { MAKE_VIDPID(0x1bad, 0xf503), "Hori Fighting Stick VX" },
   3.140 -        { MAKE_VIDPID(0x1bad, 0xf504), "Hori Real Arcade Pro. EX" },
   3.141 -        { MAKE_VIDPID(0x1bad, 0xf505), "Hori Fighting Stick EX2B" },
   3.142 -        { MAKE_VIDPID(0x1bad, 0xf506), "Hori Real Arcade Pro.EX Premium VLX" },
   3.143 -        { MAKE_VIDPID(0x1bad, 0xf900), "Harmonix Xbox 360 Controller" },
   3.144 -        { MAKE_VIDPID(0x1bad, 0xf901), "Gamestop Xbox 360 Controller" },
   3.145 -        { MAKE_VIDPID(0x1bad, 0xf903), "Tron Xbox 360 controller" },
   3.146 -        { MAKE_VIDPID(0x1bad, 0xf904), "PDP Versus Fighting Pad" },
   3.147 -        { MAKE_VIDPID(0x1bad, 0xf906), "MortalKombat FightStick" },
   3.148 -        { MAKE_VIDPID(0x1bad, 0xfa01), "MadCatz GamePad" },
   3.149 -        { MAKE_VIDPID(0x1bad, 0xfd00), "Razer Onza TE" },
   3.150 -        { MAKE_VIDPID(0x1bad, 0xfd01), "Razer Onza" },
   3.151 -        { MAKE_VIDPID(0x24c6, 0x5000), "Razer Atrox Arcade Stick" },
   3.152 -        { MAKE_VIDPID(0x24c6, 0x5300), "PowerA MINI PROEX Controller" },
   3.153 -        { MAKE_VIDPID(0x24c6, 0x5303), "Xbox Airflo wired controller" },
   3.154 -        { MAKE_VIDPID(0x24c6, 0x530a), "Xbox 360 Pro EX Controller" },
   3.155 -        { MAKE_VIDPID(0x24c6, 0x531a), "PowerA Pro Ex" },
   3.156 -        { MAKE_VIDPID(0x24c6, 0x5397), "FUS1ON Tournament Controller" },
   3.157 -        { MAKE_VIDPID(0x24c6, 0x541a), "PowerA Xbox One Mini Wired Controller" },
   3.158 -        { MAKE_VIDPID(0x24c6, 0x542a), "Xbox ONE spectra" },
   3.159 -        { MAKE_VIDPID(0x24c6, 0x543a), "PowerA Xbox One wired controller" },
   3.160 -        { MAKE_VIDPID(0x24c6, 0x5500), "Hori XBOX 360 EX 2 with Turbo" },
   3.161 -        { MAKE_VIDPID(0x24c6, 0x5501), "Hori Real Arcade Pro VX-SA" },
   3.162 -        { MAKE_VIDPID(0x24c6, 0x5502), "Hori Fighting Stick VX Alt" },
   3.163 -        { MAKE_VIDPID(0x24c6, 0x5503), "Hori Fighting Edge" },
   3.164 -        { MAKE_VIDPID(0x24c6, 0x5506), "Hori SOULCALIBUR V Stick" },
   3.165 -        { MAKE_VIDPID(0x24c6, 0x550d), "Hori GEM Xbox controller" },
   3.166 -        { MAKE_VIDPID(0x24c6, 0x550e), "Hori Real Arcade Pro V Kai 360" },
   3.167 -        { MAKE_VIDPID(0x24c6, 0x5510), "Hori Fighting Commander ONE" },
   3.168 -        { MAKE_VIDPID(0x24c6, 0x551a), "PowerA FUSION Pro Controller" },
   3.169 -        { MAKE_VIDPID(0x24c6, 0x561a), "PowerA FUSION Controller" },
   3.170 -        { MAKE_VIDPID(0x24c6, 0x591a), "PowerA FUSION Pro Controller" },
   3.171 -        { MAKE_VIDPID(0x24c6, 0x5b00), "ThrustMaster Ferrari 458 Racing Wheel" },
   3.172 -        { MAKE_VIDPID(0x24c6, 0x5b02), "Thrustmaster, Inc. GPX Controller" },
   3.173 -        { MAKE_VIDPID(0x24c6, 0x5b03), "Thrustmaster Ferrari 458 Racing Wheel" },
   3.174 -        { MAKE_VIDPID(0x24c6, 0x5d04), "Razer Sabertooth" },
   3.175 -        { MAKE_VIDPID(0x24c6, 0x791a), "PowerA Fusion Fight Pad" },
   3.176 -        { MAKE_VIDPID(0x24c6, 0xfafa), "Aplay Controller" },
   3.177 -        { MAKE_VIDPID(0x24c6, 0xfafb), "Aplay Controller" },
   3.178 -        { MAKE_VIDPID(0x24c6, 0xfafc), "Afterglow Gamepad 1" },
   3.179 -        { MAKE_VIDPID(0x24c6, 0xfafd), "Afterglow Gamepad 3" },
   3.180 -        { MAKE_VIDPID(0x24c6, 0xfafe), "Rock Candy Gamepad for Xbox 360" },
   3.181 -        { MAKE_VIDPID(0x2e24, 0x1688), "Hyperkin X91" },
   3.182 -    };
   3.183 -    int i;
   3.184 -    Uint32 vidpid = MAKE_VIDPID(vendor_id, product_id);
   3.185 -
   3.186 -    for (i = 0; i < SDL_arraysize(names); ++i) {
   3.187 -        if (vidpid == names[i].vidpid) {
   3.188 -            return names[i].name;
   3.189 -        }
   3.190 -    }
   3.191 -    return NULL;
   3.192 -}
   3.193 -
   3.194  static SDL_bool
   3.195  HIDAPI_IsDeviceSupported(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name)
   3.196  {
     4.1 --- a/src/joystick/hidapi/SDL_hidapijoystick_c.h	Tue Dec 10 13:09:52 2019 -0800
     4.2 +++ b/src/joystick/hidapi/SDL_hidapijoystick_c.h	Wed Dec 11 17:46:54 2019 -0800
     4.3 @@ -66,9 +66,6 @@
     4.4  /* Return true if a HID device is present and supported as a joystick */
     4.5  extern SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name);
     4.6  
     4.7 -/* Return the name of an Xbox 360 or Xbox One controller */
     4.8 -extern const char *HIDAPI_XboxControllerName(Uint16 vendor_id, Uint16 product_id);
     4.9 -
    4.10  #endif /* SDL_JOYSTICK_HIDAPI_H */
    4.11  
    4.12  /* vi: set ts=4 sw=4 expandtab: */