mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 03:18:13 +00:00
Use the standard gamepad type for Switch Pro controllers using the GameCube form factor
This commit is contained in:
@@ -798,31 +798,23 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_JoystickGUID guid
|
|||||||
/* The original SHIELD controller has a touchpad as well */
|
/* The original SHIELD controller has a touchpad as well */
|
||||||
SDL_strlcat(mapping_string, "touchpad:b16,", sizeof(mapping_string));
|
SDL_strlcat(mapping_string, "touchpad:b16,", sizeof(mapping_string));
|
||||||
}
|
}
|
||||||
} else {
|
} else if (SDL_IsJoystickPS4(vendor, product)) {
|
||||||
switch (SDL_GetGamepadTypeFromGUID(guid, NULL)) {
|
/* PS4 controllers have an additional touchpad button */
|
||||||
case SDL_GAMEPAD_TYPE_PS4:
|
SDL_strlcat(mapping_string, "touchpad:b15,", sizeof(mapping_string));
|
||||||
/* PS4 controllers have an additional touchpad button */
|
} else if (SDL_IsJoystickPS5(vendor, product)) {
|
||||||
SDL_strlcat(mapping_string, "touchpad:b15,", sizeof(mapping_string));
|
/* PS5 controllers have a microphone button and an additional touchpad button */
|
||||||
break;
|
SDL_strlcat(mapping_string, "touchpad:b15,misc1:b16,", sizeof(mapping_string));
|
||||||
case SDL_GAMEPAD_TYPE_PS5:
|
/* DualSense Edge controllers have paddles */
|
||||||
/* PS5 controllers have a microphone button and an additional touchpad button */
|
if (SDL_IsJoystickDualSenseEdge(vendor, product)) {
|
||||||
SDL_strlcat(mapping_string, "touchpad:b15,misc1:b16,", sizeof(mapping_string));
|
SDL_strlcat(mapping_string, "paddle1:b20,paddle2:b19,paddle3:b18,paddle4:b17,", sizeof(mapping_string));
|
||||||
/* DualSense Edge controllers have paddles */
|
|
||||||
if (SDL_IsJoystickDualSenseEdge(vendor, product)) {
|
|
||||||
SDL_strlcat(mapping_string, "paddle1:b20,paddle2:b19,paddle3:b18,paddle4:b17,", sizeof(mapping_string));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO:
|
|
||||||
/* Nintendo Switch Pro controllers have a screenshot button */
|
|
||||||
SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (vendor == 0 && product == 0) {
|
|
||||||
/* This is a Bluetooth Nintendo Switch Pro controller */
|
|
||||||
SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
} else if (SDL_IsJoystickNintendoSwitchPro(vendor, product) ||
|
||||||
|
SDL_IsJoystickNintendoSwitchProInputOnly(vendor, product)) {
|
||||||
|
/* Nintendo Switch Pro controllers have a screenshot button */
|
||||||
|
SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string));
|
||||||
|
} else if (vendor == 0 && product == 0) {
|
||||||
|
/* This is a Bluetooth Nintendo Switch Pro controller */
|
||||||
|
SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2368,6 +2368,10 @@ SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, cons
|
|||||||
} else if (vendor == USB_VENDOR_NINTENDO && product == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR) {
|
} else if (vendor == USB_VENDOR_NINTENDO && product == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR) {
|
||||||
type = SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR;
|
type = SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR;
|
||||||
|
|
||||||
|
} else if (forUI && SDL_IsJoystickGameCube(vendor, product)) {
|
||||||
|
/* We don't have a type for the Nintendo GameCube controller */
|
||||||
|
type = SDL_GAMEPAD_TYPE_STANDARD;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
switch (GuessControllerType(vendor, product)) {
|
switch (GuessControllerType(vendor, product)) {
|
||||||
case k_eControllerType_XBox360Controller:
|
case k_eControllerType_XBox360Controller:
|
||||||
@@ -2595,6 +2599,23 @@ SDL_bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 product
|
|||||||
return vendor_id == USB_VENDOR_NINTENDO && product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR;
|
return vendor_id == USB_VENDOR_NINTENDO && product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_bool SDL_IsJoystickGameCube(Uint16 vendor_id, Uint16 product_id)
|
||||||
|
{
|
||||||
|
static Uint32 gamecube_formfactor[] = {
|
||||||
|
MAKE_VIDPID(0x0e6f, 0x0185), /* PDP Wired Fight Pad Pro for Nintendo Switch */
|
||||||
|
MAKE_VIDPID(0x20d6, 0xa711), /* PowerA Wired Controller Nintendo GameCube Style */
|
||||||
|
};
|
||||||
|
Uint32 id = MAKE_VIDPID(vendor_id, product_id);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < SDL_arraysize(gamecube_formfactor); ++i) {
|
||||||
|
if (id == gamecube_formfactor[i]) {
|
||||||
|
return SDL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_bool SDL_IsJoystickAmazonLunaController(Uint16 vendor_id, Uint16 product_id)
|
SDL_bool SDL_IsJoystickAmazonLunaController(Uint16 vendor_id, Uint16 product_id)
|
||||||
{
|
{
|
||||||
return ((vendor_id == USB_VENDOR_AMAZON && product_id == USB_PRODUCT_AMAZON_LUNA_CONTROLLER) ||
|
return ((vendor_id == USB_VENDOR_AMAZON && product_id == USB_PRODUCT_AMAZON_LUNA_CONTROLLER) ||
|
||||||
|
@@ -108,6 +108,9 @@ extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConRight(Uint16 vendor_id, Uint16
|
|||||||
extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConGrip(Uint16 vendor_id, Uint16 product_id);
|
extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConGrip(Uint16 vendor_id, Uint16 product_id);
|
||||||
extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 product_id);
|
extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 product_id);
|
||||||
|
|
||||||
|
/* Function to return whether a joystick is a Nintendo GameCube style controller */
|
||||||
|
extern SDL_bool SDL_IsJoystickGameCube(Uint16 vendor_id, Uint16 product_id);
|
||||||
|
|
||||||
/* Function to return whether a joystick is an Amazon Luna controller */
|
/* Function to return whether a joystick is an Amazon Luna controller */
|
||||||
extern SDL_bool SDL_IsJoystickAmazonLunaController(Uint16 vendor_id, Uint16 product_id);
|
extern SDL_bool SDL_IsJoystickAmazonLunaController(Uint16 vendor_id, Uint16 product_id);
|
||||||
|
|
||||||
|
@@ -567,7 +567,7 @@ static const ControllerDescription_t arrControllers[] = {
|
|||||||
// The first two, at least, shouldn't have their buttons remapped, and since we
|
// The first two, at least, shouldn't have their buttons remapped, and since we
|
||||||
// can't tell which model we're actually using, we won't do any button remapping
|
// can't tell which model we're actually using, we won't do any button remapping
|
||||||
// for any of them.
|
// for any of them.
|
||||||
{ MAKE_CONTROLLER_ID( 0x0f0d, 0x00dc ), k_eControllerType_XInputSwitchController, NULL }, // HORIPAD S - Looks like a Switch controller but uses the Xbox 360 controller protocol
|
{ MAKE_CONTROLLER_ID( 0x0f0d, 0x00dc ), k_eControllerType_XInputSwitchController, NULL }, // HORIPAD S - Looks like a Switch controller but uses the Xbox 360 controller protocol, there is also a version of this that looks like a GameCube controller
|
||||||
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0180 ), k_eControllerType_SwitchInputOnlyController, NULL }, // PDP Faceoff Wired Pro Controller for Nintendo Switch
|
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0180 ), k_eControllerType_SwitchInputOnlyController, NULL }, // PDP Faceoff Wired Pro Controller for Nintendo Switch
|
||||||
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0181 ), k_eControllerType_SwitchInputOnlyController, NULL }, // PDP Faceoff Deluxe Wired Pro Controller for Nintendo Switch
|
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0181 ), k_eControllerType_SwitchInputOnlyController, NULL }, // PDP Faceoff Deluxe Wired Pro Controller for Nintendo Switch
|
||||||
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0184 ), k_eControllerType_SwitchInputOnlyController, NULL }, // PDP Faceoff Wired Deluxe+ Audio Controller
|
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0184 ), k_eControllerType_SwitchInputOnlyController, NULL }, // PDP Faceoff Wired Deluxe+ Audio Controller
|
||||||
|
@@ -263,7 +263,6 @@ typedef struct
|
|||||||
SDL_HIDAPI_Device *device;
|
SDL_HIDAPI_Device *device;
|
||||||
SDL_Joystick *joystick;
|
SDL_Joystick *joystick;
|
||||||
SDL_bool m_bInputOnly;
|
SDL_bool m_bInputOnly;
|
||||||
SDL_bool m_bIsGameCube;
|
|
||||||
SDL_bool m_bUseButtonLabels;
|
SDL_bool m_bUseButtonLabels;
|
||||||
SDL_bool m_bPlayerLights;
|
SDL_bool m_bPlayerLights;
|
||||||
int m_nPlayerIndex;
|
int m_nPlayerIndex;
|
||||||
@@ -909,8 +908,7 @@ static Sint16 ApplyStickCalibration(SDL_DriverSwitch_Context *ctx, int nStick, i
|
|||||||
ctx->m_StickExtents[nStick].axis[nAxis].sMin = sRawValue;
|
ctx->m_StickExtents[nStick].axis[nAxis].sMin = sRawValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Sint16)HIDAPI_RemapVal(sRawValue, ctx->m_StickExtents[nStick].axis[nAxis].sMin, ctx->m_StickExtents[nStick].axis[nAxis].sMax,
|
return (Sint16)HIDAPI_RemapVal(sRawValue, ctx->m_StickExtents[nStick].axis[nAxis].sMin, ctx->m_StickExtents[nStick].axis[nAxis].sMax, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||||
SDL_MIN_SINT16, SDL_MAX_SINT16);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Sint16 ApplySimpleStickCalibration(SDL_DriverSwitch_Context *ctx, int nStick, int nAxis, Sint16 sRawValue)
|
static Sint16 ApplySimpleStickCalibration(SDL_DriverSwitch_Context *ctx, int nStick, int nAxis, Sint16 sRawValue)
|
||||||
@@ -927,8 +925,7 @@ static Sint16 ApplySimpleStickCalibration(SDL_DriverSwitch_Context *ctx, int nSt
|
|||||||
ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMin = sRawValue;
|
ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMin = sRawValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Sint16)HIDAPI_RemapVal(sRawValue, ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMin, ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMax,
|
return (Sint16)HIDAPI_RemapVal(sRawValue, ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMin, ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMax, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||||
SDL_MIN_SINT16, SDL_MAX_SINT16);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Uint8 RemapButton(SDL_DriverSwitch_Context *ctx, Uint8 button)
|
static Uint8 RemapButton(SDL_DriverSwitch_Context *ctx, Uint8 button)
|
||||||
@@ -1034,7 +1031,10 @@ static SDL_bool HasHomeLED(SDL_DriverSwitch_Context *ctx)
|
|||||||
|
|
||||||
static SDL_bool AlwaysUsesLabels(int vendor_id, int product_id, ESwitchDeviceInfoControllerType eControllerType)
|
static SDL_bool AlwaysUsesLabels(int vendor_id, int product_id, ESwitchDeviceInfoControllerType eControllerType)
|
||||||
{
|
{
|
||||||
/* These controllers don't have a diamond button configuration, so always use labels */
|
/* Some controllers don't have a diamond button configuration, so should always use labels */
|
||||||
|
if (SDL_IsJoystickGameCube(vendor_id, product_id)) {
|
||||||
|
return SDL_TRUE;
|
||||||
|
}
|
||||||
switch (eControllerType) {
|
switch (eControllerType) {
|
||||||
case k_eSwitchDeviceInfoControllerType_HVCLeft:
|
case k_eSwitchDeviceInfoControllerType_HVCLeft:
|
||||||
case k_eSwitchDeviceInfoControllerType_HVCRight:
|
case k_eSwitchDeviceInfoControllerType_HVCRight:
|
||||||
@@ -1048,25 +1048,6 @@ static SDL_bool AlwaysUsesLabels(int vendor_id, int product_id, ESwitchDeviceInf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool IsGameCubeFormFactor(int vendor_id, int product_id)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
static Uint32 gamecube_formfactor[] = {
|
|
||||||
MAKE_VIDPID(0x0e6f, 0x0185), /* PDP Wired Fight Pad Pro for Nintendo Switch */
|
|
||||||
MAKE_VIDPID(0x20d6, 0xa711), /* Core (Plus) Wired Controller */
|
|
||||||
};
|
|
||||||
Uint32 id = MAKE_VIDPID(vendor_id, product_id);
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < SDL_arraysize(gamecube_formfactor); ++i) {
|
|
||||||
if (id == gamecube_formfactor[i]) {
|
|
||||||
return SDL_TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return SDL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void HIDAPI_DriverNintendoClassic_RegisterHints(SDL_HintCallback callback, void *userdata)
|
static void HIDAPI_DriverNintendoClassic_RegisterHints(SDL_HintCallback callback, void *userdata)
|
||||||
{
|
{
|
||||||
SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_NINTENDO_CLASSIC, callback, userdata);
|
SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_NINTENDO_CLASSIC, callback, userdata);
|
||||||
@@ -1183,73 +1164,80 @@ static SDL_bool HIDAPI_DriverSwitch_IsSupportedDevice(SDL_HIDAPI_Device *device,
|
|||||||
static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
|
static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
|
||||||
{
|
{
|
||||||
SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context;
|
SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context;
|
||||||
char serial[18];
|
|
||||||
|
|
||||||
switch (ctx->m_eControllerType) {
|
if (ctx->m_bInputOnly) {
|
||||||
case k_eSwitchDeviceInfoControllerType_JoyConLeft:
|
if (SDL_IsJoystickGameCube(device->vendor_id, device->product_id)) {
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo Switch Joy-Con (L)");
|
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
||||||
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT);
|
}
|
||||||
device->type = SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT;
|
} else {
|
||||||
break;
|
char serial[18];
|
||||||
case k_eSwitchDeviceInfoControllerType_JoyConRight:
|
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo Switch Joy-Con (R)");
|
switch (ctx->m_eControllerType) {
|
||||||
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT);
|
case k_eSwitchDeviceInfoControllerType_JoyConLeft:
|
||||||
device->type = SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT;
|
HIDAPI_SetDeviceName(device, "Nintendo Switch Joy-Con (L)");
|
||||||
break;
|
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT);
|
||||||
case k_eSwitchDeviceInfoControllerType_ProController:
|
device->type = SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT;
|
||||||
case k_eSwitchDeviceInfoControllerType_LicProController:
|
break;
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo Switch Pro Controller");
|
case k_eSwitchDeviceInfoControllerType_JoyConRight:
|
||||||
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_PRO);
|
HIDAPI_SetDeviceName(device, "Nintendo Switch Joy-Con (R)");
|
||||||
device->type = SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO;
|
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT);
|
||||||
break;
|
device->type = SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT;
|
||||||
case k_eSwitchDeviceInfoControllerType_HVCLeft:
|
break;
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo HVC Controller (1)");
|
case k_eSwitchDeviceInfoControllerType_ProController:
|
||||||
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
case k_eSwitchDeviceInfoControllerType_LicProController:
|
||||||
break;
|
HIDAPI_SetDeviceName(device, "Nintendo Switch Pro Controller");
|
||||||
case k_eSwitchDeviceInfoControllerType_HVCRight:
|
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_PRO);
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo HVC Controller (2)");
|
device->type = SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO;
|
||||||
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
break;
|
||||||
break;
|
case k_eSwitchDeviceInfoControllerType_HVCLeft:
|
||||||
case k_eSwitchDeviceInfoControllerType_NESLeft:
|
HIDAPI_SetDeviceName(device, "Nintendo HVC Controller (1)");
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo NES Controller (L)");
|
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
||||||
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
break;
|
||||||
break;
|
case k_eSwitchDeviceInfoControllerType_HVCRight:
|
||||||
case k_eSwitchDeviceInfoControllerType_NESRight:
|
HIDAPI_SetDeviceName(device, "Nintendo HVC Controller (2)");
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo NES Controller (R)");
|
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
||||||
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
break;
|
||||||
break;
|
case k_eSwitchDeviceInfoControllerType_NESLeft:
|
||||||
case k_eSwitchDeviceInfoControllerType_SNES:
|
HIDAPI_SetDeviceName(device, "Nintendo NES Controller (L)");
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo SNES Controller");
|
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
||||||
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SNES_CONTROLLER);
|
break;
|
||||||
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
case k_eSwitchDeviceInfoControllerType_NESRight:
|
||||||
break;
|
HIDAPI_SetDeviceName(device, "Nintendo NES Controller (R)");
|
||||||
case k_eSwitchDeviceInfoControllerType_N64:
|
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo N64 Controller");
|
break;
|
||||||
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_N64_CONTROLLER);
|
case k_eSwitchDeviceInfoControllerType_SNES:
|
||||||
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
HIDAPI_SetDeviceName(device, "Nintendo SNES Controller");
|
||||||
break;
|
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SNES_CONTROLLER);
|
||||||
case k_eSwitchDeviceInfoControllerType_SEGA_Genesis:
|
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
||||||
HIDAPI_SetDeviceName(device, "Nintendo SEGA Genesis Controller");
|
break;
|
||||||
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SEGA_GENESIS_CONTROLLER);
|
case k_eSwitchDeviceInfoControllerType_N64:
|
||||||
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
HIDAPI_SetDeviceName(device, "Nintendo N64 Controller");
|
||||||
break;
|
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_N64_CONTROLLER);
|
||||||
case k_eSwitchDeviceInfoControllerType_Unknown:
|
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
||||||
/* We couldn't read the device info for this controller, might not be fully compliant */
|
break;
|
||||||
return;
|
case k_eSwitchDeviceInfoControllerType_SEGA_Genesis:
|
||||||
default:
|
HIDAPI_SetDeviceName(device, "Nintendo SEGA Genesis Controller");
|
||||||
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
HIDAPI_SetDeviceProduct(device, USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SEGA_GENESIS_CONTROLLER);
|
||||||
break;
|
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
||||||
|
break;
|
||||||
|
case k_eSwitchDeviceInfoControllerType_Unknown:
|
||||||
|
/* We couldn't read the device info for this controller, might not be fully compliant */
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
device->type = SDL_GAMEPAD_TYPE_STANDARD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
device->guid.data[15] = ctx->m_eControllerType;
|
||||||
|
|
||||||
|
(void)SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
||||||
|
ctx->m_rgucMACAddress[0],
|
||||||
|
ctx->m_rgucMACAddress[1],
|
||||||
|
ctx->m_rgucMACAddress[2],
|
||||||
|
ctx->m_rgucMACAddress[3],
|
||||||
|
ctx->m_rgucMACAddress[4],
|
||||||
|
ctx->m_rgucMACAddress[5]);
|
||||||
|
HIDAPI_SetDeviceSerial(device, serial);
|
||||||
}
|
}
|
||||||
device->guid.data[15] = ctx->m_eControllerType;
|
|
||||||
|
|
||||||
(void)SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
|
|
||||||
ctx->m_rgucMACAddress[0],
|
|
||||||
ctx->m_rgucMACAddress[1],
|
|
||||||
ctx->m_rgucMACAddress[2],
|
|
||||||
ctx->m_rgucMACAddress[3],
|
|
||||||
ctx->m_rgucMACAddress[4],
|
|
||||||
ctx->m_rgucMACAddress[5]);
|
|
||||||
HIDAPI_SetDeviceSerial(device, serial);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device)
|
static SDL_bool HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device)
|
||||||
@@ -1267,11 +1255,6 @@ static SDL_bool HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device)
|
|||||||
ctx->m_nMaxWriteAttempts = GetMaxWriteAttempts(device);
|
ctx->m_nMaxWriteAttempts = GetMaxWriteAttempts(device);
|
||||||
ctx->m_bSyncWrite = SDL_TRUE;
|
ctx->m_bSyncWrite = SDL_TRUE;
|
||||||
|
|
||||||
if (IsGameCubeFormFactor(device->vendor_id, device->product_id)) {
|
|
||||||
/* This is a controller shaped like a GameCube controller, with a large central A button */
|
|
||||||
ctx->m_bIsGameCube = SDL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find out whether or not we can send output reports */
|
/* Find out whether or not we can send output reports */
|
||||||
ctx->m_bInputOnly = SDL_IsJoystickNintendoSwitchProInputOnly(device->vendor_id, device->product_id);
|
ctx->m_bInputOnly = SDL_IsJoystickNintendoSwitchProInputOnly(device->vendor_id, device->product_id);
|
||||||
if (!ctx->m_bInputOnly) {
|
if (!ctx->m_bInputOnly) {
|
||||||
@@ -1280,8 +1263,8 @@ static SDL_bool HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device)
|
|||||||
SetNeutralRumble(&ctx->m_RumblePacket.rumbleData[1]);
|
SetNeutralRumble(&ctx->m_RumblePacket.rumbleData[1]);
|
||||||
|
|
||||||
BReadDeviceInfo(ctx);
|
BReadDeviceInfo(ctx);
|
||||||
UpdateDeviceIdentity(device);
|
|
||||||
}
|
}
|
||||||
|
UpdateDeviceIdentity(device);
|
||||||
|
|
||||||
/* Prefer the USB device over the Bluetooth device */
|
/* Prefer the USB device over the Bluetooth device */
|
||||||
if (device->is_bluetooth) {
|
if (device->is_bluetooth) {
|
||||||
|
Reference in New Issue
Block a user