Added support for the NVIDIA Shield controller guide button

This commit is contained in:
Sam Lantinga 2022-07-12 17:53:03 -07:00
parent c92ddddde6
commit e24b971a34
3 changed files with 5 additions and 10 deletions

View File

@ -635,7 +635,7 @@ static ControllerMapping_t *SDL_CreateMappingForHIDAPIController(SDL_JoystickGUI
SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string)); SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string));
break; break;
case SDL_CONTROLLER_TYPE_NVIDIA_SHIELD: case SDL_CONTROLLER_TYPE_NVIDIA_SHIELD:
/* The NVIDIA SHIELD controller has a home button between back and start buttons */ /* The NVIDIA SHIELD controller has a share button between back and start buttons */
SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string)); SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string));
break; break;
default: default:

View File

@ -50,12 +50,6 @@
/* Reports that are too small are dropped over Bluetooth */ /* Reports that are too small are dropped over Bluetooth */
#define HID_REPORT_SIZE 33 #define HID_REPORT_SIZE 33
enum
{
SDL_CONTROLLER_BUTTON_SHIELD_HOME = 15,
SDL_CONTROLLER_NUM_SHIELD_BUTTONS,
};
typedef struct { typedef struct {
Uint8 seq_num; Uint8 seq_num;
@ -150,7 +144,7 @@ HIDAPI_DriverShield_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joysti
device->context = ctx; device->context = ctx;
/* Initialize the joystick capabilities */ /* Initialize the joystick capabilities */
joystick->nbuttons = SDL_CONTROLLER_NUM_SHIELD_BUTTONS; joystick->nbuttons = 16;
joystick->naxes = SDL_CONTROLLER_AXIS_MAX; joystick->naxes = SDL_CONTROLLER_AXIS_MAX;
joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN; joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
@ -317,8 +311,9 @@ HIDAPI_DriverShield_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverShield_C
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, SDL_SwapLE16(*(Sint16*)&data[21]) - 0x8000); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, SDL_SwapLE16(*(Sint16*)&data[21]) - 0x8000);
if (ctx->last_state[17] != data[17]) { if (ctx->last_state[17] != data[17]) {
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_SHIELD_HOME, (data[17] & 0x01) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data[17] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_BACK, (data[17] & 0x02) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_BACK, (data[17] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[17] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
} }
SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));

View File

@ -39,7 +39,6 @@
#define USB_VENDOR_SONY 0x054c #define USB_VENDOR_SONY 0x054c
#define USB_VENDOR_VALVE 0x28de #define USB_VENDOR_VALVE 0x28de
#define USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER 0x7214
#define USB_PRODUCT_AMAZON_LUNA_CONTROLLER 0x0419 #define USB_PRODUCT_AMAZON_LUNA_CONTROLLER 0x0419
#define USB_PRODUCT_GOOGLE_STADIA_CONTROLLER 0x9400 #define USB_PRODUCT_GOOGLE_STADIA_CONTROLLER 0x9400
#define USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER 0x1846 #define USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER 0x1846
@ -51,6 +50,7 @@
#define USB_PRODUCT_NINTENDO_N64_CONTROLLER 0x2019 #define USB_PRODUCT_NINTENDO_N64_CONTROLLER 0x2019
#define USB_PRODUCT_NINTENDO_SEGA_GENESIS_CONTROLLER 0x201e #define USB_PRODUCT_NINTENDO_SEGA_GENESIS_CONTROLLER 0x201e
#define USB_PRODUCT_NINTENDO_SNES_CONTROLLER 0x2017 #define USB_PRODUCT_NINTENDO_SNES_CONTROLLER 0x2017
#define USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER 0x7214
#define USB_PRODUCT_RAZER_PANTHERA 0x0401 #define USB_PRODUCT_RAZER_PANTHERA 0x0401
#define USB_PRODUCT_RAZER_PANTHERA_EVO 0x1008 #define USB_PRODUCT_RAZER_PANTHERA_EVO 0x1008
#define USB_PRODUCT_RAZER_ATROX 0x0a00 #define USB_PRODUCT_RAZER_ATROX 0x0a00