Added support for the Nintendo Online Famicom controllers
parent
10fc3b3db7
commit
baa9c57581
|
@ -584,7 +584,9 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_JoystickGUID guid
|
|||
/* 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 ||
|
||||
|
@ -594,6 +596,11 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_JoystickGUID guid
|
|||
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));
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -1053,6 +1053,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:
|
||||
|
@ -1099,7 +1101,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;
|
||||
}
|
||||
}
|
||||
|
@ -1214,6 +1217,14 @@ static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
|
|||
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_PRO);
|
||||
device->type = SDL_GAMEPAD_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_GAMEPAD_TYPE_UNKNOWN;
|
||||
|
@ -1241,6 +1252,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;
|
||||
|
@ -1342,7 +1354,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 &&
|
||||
|
|
Loading…
Reference in New Issue