Added support for the Nintendo Online Famicom controllers (cherry picked from commit baa9c57581490bd9cdefabb213e7cb6d0c30b296) (cherry picked from commit 0f940cb6ce350631b53c77360adffe276cad4660)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c
index 2b35221..e807004 100644
--- a/src/joystick/SDL_gamecontroller.c
+++ b/src/joystick/SDL_gamecontroller.c
@@ -572,7 +572,9 @@ static ControllerMapping_t *SDL_CreateMappingForHIDAPIController(SDL_JoystickGUI
/* GameCube driver has 12 buttons and 6 axes */
SDL_strlcat(mapping_string, "a:b0,b:b1,dpdown:b6,dpleft:b4,dpright:b5,dpup:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,righttrigger:a5,rightx:a2,righty:a3,start:b8,x:b2,y:b3,", sizeof(mapping_string));
} else if (vendor == USB_VENDOR_NINTENDO &&
- (guid.data[15] == k_eSwitchDeviceInfoControllerType_NESLeft ||
+ (guid.data[15] == k_eSwitchDeviceInfoControllerType_HVCLeft ||
+ guid.data[15] == k_eSwitchDeviceInfoControllerType_HVCRight ||
+ guid.data[15] == k_eSwitchDeviceInfoControllerType_NESLeft ||
guid.data[15] == k_eSwitchDeviceInfoControllerType_NESRight ||
guid.data[15] == k_eSwitchDeviceInfoControllerType_SNES ||
guid.data[15] == k_eSwitchDeviceInfoControllerType_N64 ||
@@ -582,6 +584,11 @@ static ControllerMapping_t *SDL_CreateMappingForHIDAPIController(SDL_JoystickGUI
guid.data[15] == k_eSwitchDeviceInfoControllerType_JoyConLeft ||
guid.data[15] == k_eSwitchDeviceInfoControllerType_JoyConRight)) {
switch (guid.data[15]) {
+ case k_eSwitchDeviceInfoControllerType_HVCLeft:
+ SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,rightshoulder:b10,start:b6,", sizeof(mapping_string));
+ case k_eSwitchDeviceInfoControllerType_HVCRight:
+ SDL_strlcat(mapping_string, "a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,rightshoulder:b10,", sizeof(mapping_string));
+ break;
case k_eSwitchDeviceInfoControllerType_NESLeft:
case k_eSwitchDeviceInfoControllerType_NESRight:
SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,rightshoulder:b10,start:b6,", sizeof(mapping_string));
diff --git a/src/joystick/hidapi/SDL_hidapi_nintendo.h b/src/joystick/hidapi/SDL_hidapi_nintendo.h
index f0edf97..9b9a667 100644
--- a/src/joystick/hidapi/SDL_hidapi_nintendo.h
+++ b/src/joystick/hidapi/SDL_hidapi_nintendo.h
@@ -29,6 +29,8 @@ typedef enum
k_eSwitchDeviceInfoControllerType_JoyConRight = 2,
k_eSwitchDeviceInfoControllerType_ProController = 3,
k_eSwitchDeviceInfoControllerType_LicProController = 6,
+ k_eSwitchDeviceInfoControllerType_HVCLeft = 7,
+ k_eSwitchDeviceInfoControllerType_HVCRight = 8,
k_eSwitchDeviceInfoControllerType_NESLeft = 9,
k_eSwitchDeviceInfoControllerType_NESRight = 10,
k_eSwitchDeviceInfoControllerType_SNES = 11,
diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c
index 3637ddb..e7efc1c 100644
--- a/src/joystick/hidapi/SDL_hidapi_switch.c
+++ b/src/joystick/hidapi/SDL_hidapi_switch.c
@@ -1059,6 +1059,8 @@ static SDL_bool AlwaysUsesLabels(int vendor_id, int product_id, ESwitchDeviceInf
{
/* These controllers don't have a diamond button configuration, so always use labels */
switch (eControllerType) {
+ case k_eSwitchDeviceInfoControllerType_HVCLeft:
+ case k_eSwitchDeviceInfoControllerType_HVCRight:
case k_eSwitchDeviceInfoControllerType_NESLeft:
case k_eSwitchDeviceInfoControllerType_NESRight:
case k_eSwitchDeviceInfoControllerType_N64:
@@ -1105,7 +1107,8 @@ static SDL_bool HIDAPI_DriverNintendoClassic_IsSupportedDevice(SDL_HIDAPI_Device
{
if (vendor_id == USB_VENDOR_NINTENDO) {
if (product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT) {
- if (SDL_strncmp(name, "NES Controller", 14) == 0) {
+ if (SDL_strncmp(name, "NES Controller", 14) == 0 ||
+ SDL_strncmp(name, "HVC Controller", 14) == 0) {
return SDL_TRUE;
}
}
@@ -1220,6 +1223,14 @@ static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_PRO);
device->type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO;
break;
+ case k_eSwitchDeviceInfoControllerType_HVCLeft:
+ HIDAPI_SetDeviceName(device, "Nintendo HVC Controller (1)");
+ device->type = SDL_GAMEPAD_TYPE_UNKNOWN;
+ break;
+ case k_eSwitchDeviceInfoControllerType_HVCRight:
+ HIDAPI_SetDeviceName(device, "Nintendo HVC Controller (2)");
+ device->type = SDL_GAMEPAD_TYPE_UNKNOWN;
+ break;
case k_eSwitchDeviceInfoControllerType_NESLeft:
HIDAPI_SetDeviceName(device, "Nintendo NES Controller (L)");
device->type = SDL_CONTROLLER_TYPE_UNKNOWN;
@@ -1247,6 +1258,7 @@ static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
/* We couldn't read the device info for this controller, might not be fully compliant */
return;
default:
+ device->type = SDL_GAMEPAD_TYPE_UNKNOWN;
break;
}
device->guid.data[15] = ctx->m_eControllerType;
@@ -1348,7 +1360,9 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_
return SDL_FALSE;
}
- if (ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_NESLeft &&
+ if (ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_HVCLeft &&
+ ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_HVCRight &&
+ ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_NESLeft &&
ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_NESRight &&
ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_SNES &&
ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_N64 &&