mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-22 05:51:59 +00:00
gameinput: only add the share button for known Xbox Series X controllers
The HID descriptor for the latest firmware always includes the share button, and GameInput will report it as always available, so double check against our list of classic Xbox One controllers and don't include the button on controllers that don't have it.
This commit is contained in:
parent
a95ce7e734
commit
aeacf42e06
1 changed files with 12 additions and 3 deletions
|
|
@ -49,6 +49,8 @@ typedef struct GAMEINPUT_InternalDevice
|
|||
SDL_GUID guid; // generated by SDL
|
||||
SDL_JoystickID device_instance; // generated by SDL
|
||||
const GameInputDeviceInfo *info;
|
||||
Uint16 vendor;
|
||||
Uint16 product;
|
||||
int raw_type;
|
||||
int steam_virtual_gamepad_slot;
|
||||
bool isAdded;
|
||||
|
|
@ -279,6 +281,8 @@ static bool GAMEINPUT_InternalAddOrFind(IGameInputDevice *pDevice)
|
|||
elem->guid = SDL_CreateJoystickGUID(bus, vendor, product, version, NULL, product_string, driver_signature, subtype);
|
||||
elem->device_instance = SDL_GetNextObjectID();
|
||||
elem->info = info;
|
||||
elem->vendor = vendor;
|
||||
elem->product = product;
|
||||
elem->raw_type = raw_type;
|
||||
#if GAMEINPUT_API_VERSION >= 1
|
||||
elem->steam_virtual_gamepad_slot = GetSteamVirtualGamepadSlot(info->pnpPath);
|
||||
|
|
@ -609,11 +613,15 @@ static bool GAMEINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
|||
|
||||
#if GAMEINPUT_API_VERSION >= 1
|
||||
if (info->supportedSystemButtons != GameInputSystemButtonNone) {
|
||||
if (info->supportedSystemButtons & GameInputSystemButtonShare) {
|
||||
GameInputSystemButtons buttons = GameInputSystemButtonGuide;
|
||||
|
||||
if (SDL_IsJoystickXboxSeriesX(elem->vendor, elem->product) &&
|
||||
(info->supportedSystemButtons & GameInputSystemButtonShare)) {
|
||||
++joystick->nbuttons;
|
||||
buttons |= GameInputSystemButtonShare;
|
||||
}
|
||||
|
||||
g_pGameInput->RegisterSystemButtonCallback(elem->device, (GameInputSystemButtonGuide | GameInputSystemButtonShare), joystick, GAMEINPUT_InternalSystemButtonCallback, &hwdata->system_button_callback_token);
|
||||
g_pGameInput->RegisterSystemButtonCallback(elem->device, buttons, joystick, GAMEINPUT_InternalSystemButtonCallback, &hwdata->system_button_callback_token);
|
||||
}
|
||||
#endif // GAMEINPUT_API_VERSION >= 1
|
||||
} else {
|
||||
|
|
@ -990,7 +998,8 @@ static bool GAMEINPUT_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap
|
|||
out->guide.target = SDL_GAMEPAD_BUTTON_GUIDE;
|
||||
}
|
||||
|
||||
if (elem->info->supportedSystemButtons & GameInputSystemButtonShare) {
|
||||
if (SDL_IsJoystickXboxSeriesX(elem->vendor, elem->product) &&
|
||||
(elem->info->supportedSystemButtons & GameInputSystemButtonShare)) {
|
||||
out->misc1.kind = EMappingKind_Button;
|
||||
out->misc1.target = SDL_GAMEPAD_BUTTON_GAMEINPUT_SHARE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue