Skip to content

Commit

Permalink
iOS: ensure webserver notice can be dismissed (libretro#17356)
Browse files Browse the repository at this point in the history
  • Loading branch information
warmenhoven authored and JoeMatt committed Feb 15, 2025
1 parent c811b43 commit 5233843
Showing 1 changed file with 51 additions and 52 deletions.
103 changes: 51 additions & 52 deletions ui/drivers/cocoa/cocoa_common.m
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ - (id)init
*/
self.controllerUserInteractionEnabled = YES;
#endif

#if TARGET_OS_IOS
self.shouldLockCurrentInterfaceOrientation = NO;
#endif
Expand Down Expand Up @@ -228,50 +228,50 @@ - (bool)didMicroGamepadPress:(UIPressType)type
bool foundSiri = false;
bool nonSiriPress = false;
for (GCController *controller in controllers) {
if ([self isSiri:controller])
{
foundSiri = true;
if (type == UIPressTypeSelect)
return controller.microGamepad.buttonA.pressed;
else if (type == UIPressTypePlayPause)
return controller.microGamepad.buttonX.pressed;
}
else if (controller.extendedGamepad)
{
if (type == UIPressTypeUpArrow)
nonSiriPress |= controller.extendedGamepad.dpad.up.pressed
|| controller.extendedGamepad.leftThumbstick.up.pressed
|| controller.extendedGamepad.rightThumbstick.up.pressed;
else if (type == UIPressTypeDownArrow)
nonSiriPress |= controller.extendedGamepad.dpad.down.pressed
|| controller.extendedGamepad.leftThumbstick.down.pressed
|| controller.extendedGamepad.rightThumbstick.down.pressed;
else if (type == UIPressTypeLeftArrow)
nonSiriPress |= controller.extendedGamepad.dpad.left.pressed
|| controller.extendedGamepad.leftShoulder.pressed
|| controller.extendedGamepad.leftTrigger.pressed
|| controller.extendedGamepad.leftThumbstick.left.pressed
|| controller.extendedGamepad.rightThumbstick.left.pressed;
else if (type == UIPressTypeRightArrow)
nonSiriPress |= controller.extendedGamepad.dpad.right.pressed
|| controller.extendedGamepad.rightShoulder.pressed
|| controller.extendedGamepad.rightTrigger.pressed
|| controller.extendedGamepad.leftThumbstick.right.pressed
|| controller.extendedGamepad.rightThumbstick.right.pressed;
else if (type == UIPressTypeSelect)
nonSiriPress |= controller.extendedGamepad.buttonA.pressed;
else if (type == UIPressTypeMenu)
nonSiriPress |= controller.extendedGamepad.buttonB.pressed;
else if (type == UIPressTypePlayPause)
nonSiriPress |= controller.extendedGamepad.buttonX.pressed;
}
else
{
/* we have a remote that is not extended. some of these remotes send
* spurious presses. the only way to get them to work properly is to
* make the siri remote work improperly. */
nonSiriPress = true;
}
if ([self isSiri:controller])
{
foundSiri = true;
if (type == UIPressTypeSelect)
return controller.microGamepad.buttonA.pressed;
else if (type == UIPressTypePlayPause)
return controller.microGamepad.buttonX.pressed;
}
else if (controller.extendedGamepad)
{
if (type == UIPressTypeUpArrow)
nonSiriPress |= controller.extendedGamepad.dpad.up.pressed
|| controller.extendedGamepad.leftThumbstick.up.pressed
|| controller.extendedGamepad.rightThumbstick.up.pressed;
else if (type == UIPressTypeDownArrow)
nonSiriPress |= controller.extendedGamepad.dpad.down.pressed
|| controller.extendedGamepad.leftThumbstick.down.pressed
|| controller.extendedGamepad.rightThumbstick.down.pressed;
else if (type == UIPressTypeLeftArrow)
nonSiriPress |= controller.extendedGamepad.dpad.left.pressed
|| controller.extendedGamepad.leftShoulder.pressed
|| controller.extendedGamepad.leftTrigger.pressed
|| controller.extendedGamepad.leftThumbstick.left.pressed
|| controller.extendedGamepad.rightThumbstick.left.pressed;
else if (type == UIPressTypeRightArrow)
nonSiriPress |= controller.extendedGamepad.dpad.right.pressed
|| controller.extendedGamepad.rightShoulder.pressed
|| controller.extendedGamepad.rightTrigger.pressed
|| controller.extendedGamepad.leftThumbstick.right.pressed
|| controller.extendedGamepad.rightThumbstick.right.pressed;
else if (type == UIPressTypeSelect)
nonSiriPress |= controller.extendedGamepad.buttonA.pressed;
else if (type == UIPressTypeMenu)
nonSiriPress |= controller.extendedGamepad.buttonB.pressed;
else if (type == UIPressTypePlayPause)
nonSiriPress |= controller.extendedGamepad.buttonX.pressed;
}
else
{
/* we have a remote that is not extended. some of these remotes send
* spurious presses. the only way to get them to work properly is to
* make the siri remote work improperly. */
nonSiriPress = true;
}
}

if (!foundSiri || [controllers count] == 1)
Expand Down Expand Up @@ -333,12 +333,12 @@ - (void)pressesBegan:(NSSet<UIPress *> *)presses
-(void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
{
for (UIPress *press in presses) {
if (press.type == UIPressTypeSelect || press.type == UIPressTypePlayPause)
[self sendKeyForPress:press.type down:false];
else
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
if (press.type == UIPressTypeSelect || press.type == UIPressTypePlayPause)
[self sendKeyForPress:press.type down:false];
else
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
[[CocoaView get] sendKeyForPress:press.type down:false];
});
});
}
}

Expand Down Expand Up @@ -770,7 +770,6 @@ - (void)webServerDidCompleteBonjourRegistration:(GCDWebServer*)server
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Welcome to RetroArch" message:[NSString stringWithFormat:@"To transfer files from your computer, go to one of these addresses on your web browser:\n\n%@",servers] preferredStyle:UIAlertControllerStyleAlert];
#if TARGET_OS_TV
[alert addAction:[UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
rarch_start_draw_observer();
Expand All @@ -780,7 +779,7 @@ - (void)webServerDidCompleteBonjourRegistration:(GCDWebServer*)server
rarch_start_draw_observer();
configuration_set_bool(settings, settings->bools.gcdwebserver_alert, false);
}]];
#elif TARGET_OS_IOS
#if TARGET_OS_IOS
[alert addAction:[UIAlertAction actionWithTitle:@"Stop Server" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[[WebServer sharedInstance] webUploader].delegate = nil;
[[WebServer sharedInstance] stopUploader];
Expand Down

0 comments on commit 5233843

Please sign in to comment.