Skip to content

Commit 9b17353

Browse files
endriftflibitijibibo
authored andcommitted
Switch 2: Add Pro Controller
1 parent db29f89 commit 9b17353

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

src/hidapi/SDL_hidapi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,7 @@ static const struct {
900900
Uint16 product;
901901
} SDL_libusb_whitelist[] = {
902902
{ USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_GAMECUBE_ADAPTER },
903+
{ USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH2_PRO },
903904
{ USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH2_GAMECUBE_CONTROLLER },
904905
};
905906

src/hidapi/libusb/hid.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,12 @@ static void init_xboxone(libusb_device_handle *device_handle, unsigned short idV
13101310
static bool is_ns2(unsigned short idVendor, unsigned short idProduct)
13111311
{
13121312
if (idVendor == 0x057e) {
1313-
return (idProduct == 0x2073);
1313+
if (idProduct == 0x2069) {
1314+
return true;
1315+
}
1316+
if (idProduct == 0x2073) {
1317+
return true;
1318+
}
13141319
}
13151320
return false;
13161321
}

src/joystick/SDL_gamepad.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,9 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid)
719719
(product == USB_PRODUCT_NINTENDO_SWITCH2_GAMECUBE_CONTROLLER)) {
720720
// Switch 2 GameCube has additional buttons for ZL and C
721721
SDL_strlcat(mapping_string, "a:b1,b:b3,dpdown:b8,dpleft:b10,dpright:b9,dpup:b11,guide:b16,leftshoulder:b13,lefttrigger:a4,leftx:a0,lefty:a1~,misc1:b17,misc2:b20,rightshoulder:b5,righttrigger:a5,rightx:a2,righty:a3~,start:b6,x:b0,y:b2,hint:!SDL_GAMECONTROLLER_USE_GAMECUBE_LABELS:=1,", sizeof(mapping_string));
722+
} else if (vendor == USB_VENDOR_NINTENDO &&
723+
(product == USB_PRODUCT_NINTENDO_SWITCH2_PRO)) {
724+
SDL_strlcat(mapping_string, "a:b1,b:b0,dpdown:b8,dpleft:b10,dpright:b9,dpup:b11,guide:b16,leftshoulder:b12,lefttrigger:b13,leftx:a0,lefty:a1~,misc1:b17,misc2:b20,rightshoulder:b4,righttrigger:b5,rightx:a2,righty:a3~,start:b6,back:b14,x:b3,y:b2,leftstick:b15,rightstick:b7,paddle1:b18,paddle2:b19,", sizeof(mapping_string));
722725
} else if (vendor == USB_VENDOR_NINTENDO &&
723726
(guid.data[15] == k_eSwitchDeviceInfoControllerType_HVCLeft ||
724727
guid.data[15] == k_eSwitchDeviceInfoControllerType_HVCRight ||

src/joystick/hidapi/SDL_hidapi_switch2.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ static bool HIDAPI_DriverSwitch2_IsEnabled(void)
5151
static bool HIDAPI_DriverSwitch2_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
5252
{
5353
if (vendor_id == USB_VENDOR_NINTENDO) {
54+
if (product_id == USB_PRODUCT_NINTENDO_SWITCH2_PRO) {
55+
return true;
56+
}
5457
if (product_id == USB_PRODUCT_NINTENDO_SWITCH2_GAMECUBE_CONTROLLER) {
5558
return true;
5659
}

src/joystick/usb_ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
#define USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR 0x2008 // Used by joycond
102102
#define USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT 0x2007
103103
#define USB_PRODUCT_NINTENDO_SWITCH_PRO 0x2009
104+
#define USB_PRODUCT_NINTENDO_SWITCH2_PRO 0x2069
104105
#define USB_PRODUCT_NINTENDO_SWITCH2_GAMECUBE_CONTROLLER 0x2073
105106
#define USB_PRODUCT_NINTENDO_WII_REMOTE 0x0306
106107
#define USB_PRODUCT_NINTENDO_WII_REMOTE2 0x0330

0 commit comments

Comments
 (0)