mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-19 07:00:57 +00:00
Cleanup controller support code using the iOS 13 SDK directly
This commit is contained in:
@@ -213,7 +213,10 @@
|
|||||||
if (controller != NULL) {
|
if (controller != NULL) {
|
||||||
// On iOS 13, we want to use the new buttonMenu property which lets users hold down Start.
|
// On iOS 13, we want to use the new buttonMenu property which lets users hold down Start.
|
||||||
// On prior versions, we must use the controllerPausedHandler.
|
// On prior versions, we must use the controllerPausedHandler.
|
||||||
if (![controller.extendedGamepad respondsToSelector:@selector(buttonMenu)]) {
|
if (@available(iOS 13.0, tvOS 13.0, *)) {
|
||||||
|
// Nothing - buttonMenu is already handled in valueChangedHandler
|
||||||
|
}
|
||||||
|
else {
|
||||||
controller.controllerPausedHandler = ^(GCController *controller) {
|
controller.controllerPausedHandler = ^(GCController *controller) {
|
||||||
Controller* limeController = [self->_controllers objectForKey:[NSNumber numberWithInteger:controller.playerIndex]];
|
Controller* limeController = [self->_controllers objectForKey:[NSNumber numberWithInteger:controller.playerIndex]];
|
||||||
|
|
||||||
@@ -261,22 +264,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Until the iOS 13 SDK is released, we must use performSelector: and respondsToSelector:
|
|
||||||
// to exercise the new buttonMenu and buttonOptions properties.
|
|
||||||
if (@available(iOS 13.0, tvOS 13.0, *)) {
|
if (@available(iOS 13.0, tvOS 13.0, *)) {
|
||||||
if ([gamepad respondsToSelector:@selector(buttonMenu)]) {
|
|
||||||
GCControllerButtonInput* menuButton = [gamepad performSelector:@selector(buttonMenu)];
|
|
||||||
|
|
||||||
// Menu button is mandatory, so no need to check for nil
|
// Menu button is mandatory, so no need to check for nil
|
||||||
UPDATE_BUTTON_FLAG(limeController, PLAY_FLAG, menuButton.pressed);
|
UPDATE_BUTTON_FLAG(limeController, PLAY_FLAG, gamepad.buttonMenu.pressed);
|
||||||
}
|
|
||||||
if ([gamepad respondsToSelector:@selector(buttonOptions)]) {
|
|
||||||
GCControllerButtonInput* optionsButton = [gamepad performSelector:@selector(buttonOptions)];
|
|
||||||
|
|
||||||
// Options button is optional (only present on Xbox One S and PS4 gamepads)
|
// Options button is optional (only present on Xbox One S and PS4 gamepads)
|
||||||
if (optionsButton != nil) {
|
if (gamepad.buttonOptions != nil) {
|
||||||
UPDATE_BUTTON_FLAG(limeController, BACK_FLAG, optionsButton.pressed);
|
UPDATE_BUTTON_FLAG(limeController, BACK_FLAG, gamepad.buttonOptions.pressed);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,22 +333,12 @@
|
|||||||
if (@available(iOS 12.1, tvOS 12.1, *)) {
|
if (@available(iOS 12.1, tvOS 12.1, *)) {
|
||||||
if (controller.extendedGamepad.leftThumbstickButton != nil &&
|
if (controller.extendedGamepad.leftThumbstickButton != nil &&
|
||||||
controller.extendedGamepad.rightThumbstickButton != nil) {
|
controller.extendedGamepad.rightThumbstickButton != nil) {
|
||||||
GCControllerButtonInput* optionsButton = nil;
|
level = OnScreenControlsLevelAutoGCExtendedGamepadWithStickButtons;
|
||||||
|
|
||||||
if (@available(iOS 13.0, tvOS 13.0, *)) {
|
if (@available(iOS 13.0, tvOS 13.0, *)) {
|
||||||
// TODO: Update when iOS 13 SDK is officially released
|
if (controller.extendedGamepad.buttonOptions != nil) {
|
||||||
if ([controller.extendedGamepad respondsToSelector:@selector(buttonOptions)]) {
|
|
||||||
optionsButton = [controller.extendedGamepad performSelector:@selector(buttonOptions)];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (optionsButton != nil) {
|
|
||||||
// Has L3/R3 and Select, so we can show nothing :)
|
// Has L3/R3 and Select, so we can show nothing :)
|
||||||
level = OnScreenControlsLevelOff;
|
level = OnScreenControlsLevelOff;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// Has L3/R3 but no Select button
|
|
||||||
level = OnScreenControlsLevelAutoGCExtendedGamepadWithStickButtons;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user