mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2025-01-26 12:59:18 +01:00
Added support for the Xbox Series X controller on iOS and tvOS
This commit is contained in:
parent
297ce148e6
commit
947ad6e13a
@ -864,6 +864,7 @@ static const char *s_ControllerMappings [] =
|
|||||||
"05000000ac0500000300000043006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,",
|
"05000000ac0500000300000043006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,",
|
||||||
"050000005e040000050b0000df070001,Xbox Elite Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b10,paddle2:b12,paddle3:b11,paddle4:b13,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,",
|
"050000005e040000050b0000df070001,Xbox Elite Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b10,paddle2:b12,paddle3:b11,paddle4:b13,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,",
|
||||||
"050000005e040000050b0000ff070001,Xbox Elite Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b13,paddle3:b12,paddle4:b14,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,",
|
"050000005e040000050b0000ff070001,Xbox Elite Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b13,paddle3:b12,paddle4:b14,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,",
|
||||||
|
"050000005e040000130b0000ff870001,Xbox Series X Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,misc1:b11,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,",
|
||||||
"050000005e040000e0020000df070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,",
|
"050000005e040000e0020000df070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,",
|
||||||
"050000005e040000e0020000ff070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,",
|
"050000005e040000e0020000ff070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,",
|
||||||
#endif
|
#endif
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
|
|
||||||
static id connectObserver = nil;
|
static id connectObserver = nil;
|
||||||
static id disconnectObserver = nil;
|
static id disconnectObserver = nil;
|
||||||
|
static NSString *GCInputXboxShareButton = @"Button Share";
|
||||||
|
|
||||||
#include <Availability.h>
|
#include <Availability.h>
|
||||||
#include <objc/message.h>
|
#include <objc/message.h>
|
||||||
@ -228,6 +229,11 @@ IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *controlle
|
|||||||
device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_PADDLE4);
|
device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_PADDLE4);
|
||||||
++nbuttons;
|
++nbuttons;
|
||||||
}
|
}
|
||||||
|
if (controller.physicalInputProfile.buttons[GCInputXboxShareButton] != nil) {
|
||||||
|
device->has_xbox_share_button = SDL_TRUE;
|
||||||
|
device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_MISC1);
|
||||||
|
++nbuttons;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
@ -238,6 +244,10 @@ IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *controlle
|
|||||||
/* Assume Xbox One Elite Series 2 Controller unless/until GCController flows VID/PID */
|
/* Assume Xbox One Elite Series 2 Controller unless/until GCController flows VID/PID */
|
||||||
product = USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH;
|
product = USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH;
|
||||||
subtype = 1;
|
subtype = 1;
|
||||||
|
} else if (device->has_xbox_share_button) {
|
||||||
|
/* Assume Xbox Series X Controller unless/until GCController flows VID/PID */
|
||||||
|
product = USB_PRODUCT_XBOX_SERIES_X_BLUETOOTH;
|
||||||
|
subtype = 1;
|
||||||
} else {
|
} else {
|
||||||
/* Assume Xbox One S BLE Controller unless/until GCController flows VID/PID */
|
/* Assume Xbox One S BLE Controller unless/until GCController flows VID/PID */
|
||||||
product = USB_PRODUCT_XBOX_ONE_S_REV1_BLUETOOTH;
|
product = USB_PRODUCT_XBOX_ONE_S_REV1_BLUETOOTH;
|
||||||
@ -255,7 +265,7 @@ IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *controlle
|
|||||||
} else if (is_ps5) {
|
} else if (is_ps5) {
|
||||||
vendor = USB_VENDOR_SONY;
|
vendor = USB_VENDOR_SONY;
|
||||||
product = USB_PRODUCT_SONY_DS5;
|
product = USB_PRODUCT_SONY_DS5;
|
||||||
subtype = 0;
|
subtype = 0;
|
||||||
} else {
|
} else {
|
||||||
vendor = USB_VENDOR_APPLE;
|
vendor = USB_VENDOR_APPLE;
|
||||||
product = 1;
|
product = 1;
|
||||||
@ -665,12 +675,12 @@ IOS_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
|||||||
#ifdef ENABLE_MFI_SYSTEM_GESTURE_STATE
|
#ifdef ENABLE_MFI_SYSTEM_GESTURE_STATE
|
||||||
if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
|
if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
|
||||||
GCController *controller = joystick->hwdata->controller;
|
GCController *controller = joystick->hwdata->controller;
|
||||||
if (controller.extendedGamepad) {
|
for (id key in controller.physicalInputProfile.buttons) {
|
||||||
GCExtendedGamepad *gamepad = controller.extendedGamepad;
|
GCControllerButtonInput *button = controller.physicalInputProfile.buttons[key];
|
||||||
if ([gamepad.buttonOptions isBoundToSystemGesture]) {
|
if ([button isBoundToSystemGesture]) {
|
||||||
gamepad.buttonOptions.preferredSystemGestureState = GCSystemGestureStateDisabled;
|
button.preferredSystemGestureState = GCSystemGestureStateDisabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_MFI_SYSTEM_GESTURE_STATE */
|
#endif /* ENABLE_MFI_SYSTEM_GESTURE_STATE */
|
||||||
|
|
||||||
@ -857,6 +867,10 @@ IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
|||||||
controller.physicalInputProfile.buttons[GCInputXboxPaddleFour].isPressed);
|
controller.physicalInputProfile.buttons[GCInputXboxPaddleFour].isPressed);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (joystick->hwdata->has_xbox_share_button) {
|
||||||
|
buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputXboxShareButton].isPressed;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
@ -1359,9 +1373,11 @@ IOS_JoystickClose(SDL_Joystick *joystick)
|
|||||||
#ifdef ENABLE_MFI_SYSTEM_GESTURE_STATE
|
#ifdef ENABLE_MFI_SYSTEM_GESTURE_STATE
|
||||||
if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
|
if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
|
||||||
GCController *controller = joystick->hwdata->controller;
|
GCController *controller = joystick->hwdata->controller;
|
||||||
if (controller.extendedGamepad) {
|
for (id key in controller.physicalInputProfile.buttons) {
|
||||||
GCExtendedGamepad *gamepad = controller.extendedGamepad;
|
GCControllerButtonInput *button = controller.physicalInputProfile.buttons[key];
|
||||||
gamepad.buttonOptions.preferredSystemGestureState = GCSystemGestureStateEnabled;
|
if ([button isBoundToSystemGesture]) {
|
||||||
|
button.preferredSystemGestureState = GCSystemGestureStateEnabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_MFI_SYSTEM_GESTURE_STATE */
|
#endif /* ENABLE_MFI_SYSTEM_GESTURE_STATE */
|
||||||
|
@ -50,6 +50,7 @@ typedef struct joystick_hwdata
|
|||||||
Uint32 button_mask;
|
Uint32 button_mask;
|
||||||
SDL_bool has_dualshock_touchpad;
|
SDL_bool has_dualshock_touchpad;
|
||||||
SDL_bool has_xbox_paddles;
|
SDL_bool has_xbox_paddles;
|
||||||
|
SDL_bool has_xbox_share_button;
|
||||||
|
|
||||||
struct joystick_hwdata *next;
|
struct joystick_hwdata *next;
|
||||||
} joystick_hwdata;
|
} joystick_hwdata;
|
||||||
|
Loading…
Reference in New Issue
Block a user