Skip to content

Commit

Permalink
iOS: Pass through touches near the task switcher only in-game. Makes …
Browse files Browse the repository at this point in the history
…the UI better behaved.
  • Loading branch information
hrydgard committed May 26, 2024
1 parent f42f7ac commit e799b4b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
1 change: 1 addition & 0 deletions Common/System/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ enum class SystemNotification {
TEST_JAVA_EXCEPTION,
KEEP_SCREEN_AWAKE,
ACTIVITY,
UI_STATE_CHANGED,
};

// I guess it's not super great architecturally to centralize this, since it's not general - but same with a lot of
Expand Down
17 changes: 16 additions & 1 deletion ios/ViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,22 @@ - (void)controllerDidDisconnect:(NSNotification *)note
// Enables tapping for edge area.
-(UIRectEdge)preferredScreenEdgesDeferringSystemGestures
{
return UIRectEdgeAll;
if (GetUIState() == UISTATE_INGAME) {
// In-game, we need all the control we can get. Though, we could possibly
// allow the top edge?
INFO_LOG(SYSTEM, "Defer system gestures on all edges");
return UIRectEdgeAll;
} else {
INFO_LOG(SYSTEM, "Allow system gestures on the bottom");
// Allow task switching gestures to take precedence, without causing
// scroll events in the UI.
return UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeRight;
}
}

- (void)uiStateChanged
{
[self setNeedsUpdateOfScreenEdgesDeferringSystemGestures];
}

- (UIView *)getView {
Expand Down
2 changes: 2 additions & 0 deletions ios/ViewControllerCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
- (void)didBecomeActive;
- (void)willResignActive;

- (void)uiStateChanged;

@end

extern id <PPSSPPViewController> sharedViewController;
Expand Down
17 changes: 16 additions & 1 deletion ios/ViewControllerMetal.mm
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,22 @@ - (void)viewSafeAreaInsetsDidChange {
// Enables tapping for edge area.
-(UIRectEdge)preferredScreenEdgesDeferringSystemGestures
{
return UIRectEdgeAll;
if (GetUIState() == UISTATE_INGAME) {
// In-game, we need all the control we can get. Though, we could possibly
// allow the top edge?
INFO_LOG(SYSTEM, "Defer system gestures on all edges");
return UIRectEdgeAll;
} else {
INFO_LOG(SYSTEM, "Allow system gestures on the bottom");
// Allow task switching gestures to take precedence, without causing
// scroll events in the UI.
return UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeRight;
}
}

- (void)uiStateChanged
{
[self setNeedsUpdateOfScreenEdgesDeferringSystemGestures];
}

- (void)bindDefaultFBO
Expand Down
10 changes: 9 additions & 1 deletion ios/main.mm
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,15 @@ bool System_GetPropertyBool(SystemProperty prop) {

void System_Notify(SystemNotification notification) {
switch (notification) {
default: break;
case SystemNotification::UI_STATE_CHANGED:
dispatch_async(dispatch_get_main_queue(), ^{
if (sharedViewController) {
[sharedViewController uiStateChanged];
}
});
break;
default:
break;
}
}

Expand Down

0 comments on commit e799b4b

Please sign in to comment.