Skip to content

Commit

Permalink
Add an option to enable single-touch A+B combo in iOS, closes #587
Browse files Browse the repository at this point in the history
  • Loading branch information
LIJI32 committed Apr 6, 2024
1 parent 3f799f2 commit a791f7e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions iOS/GBBackgroundView.m
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ - (void)touchesChanged
else if (CGPointSquaredDistance(point, _layout.selectLocation) <= buttonRadiusSquared) {
mask |= GB_KEY_SELECT_MASK;
}
else if ([[NSUserDefaults standardUserDefaults] boolForKey:@"GBEnableABCombo"] &&
CGPointSquaredDistance(point, _layout.abComboLocation) <= buttonRadiusSquared) {
mask |= GB_KEY_A_MASK | GB_KEY_B_MASK;
}
else if (!dpadHandled &&
fabs(point.x - _layout.dpadLocation.x) <= dpadRadius &&
fabs(point.y - _layout.dpadLocation.y) <= dpadRadius) {
Expand Down
3 changes: 3 additions & 0 deletions iOS/GBHorizontalLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ - (instancetype)init
self.bLocation = (CGPoint){self.bLocation.x + self.cutout, self.bLocation.y};
self.startLocation = (CGPoint){self.startLocation.x + self.cutout, self.startLocation.y};
self.selectLocation = (CGPoint){self.selectLocation.x + self.cutout, self.selectLocation.y};
self.abComboLocation = (CGPoint){(self.aLocation.x + self.bLocation.x) / 2,
(self.aLocation.y + self.bLocation.y) / 2};


UIGraphicsBeginImageContextWithOptions(resolution, true, 1);
[self drawBackground];
Expand Down
2 changes: 2 additions & 0 deletions iOS/GBLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@property (readonly) CGPoint dpadLocation;
@property (readonly) CGPoint aLocation;
@property (readonly) CGPoint bLocation;
@property (readonly) CGPoint abComboLocation;
@property (readonly) CGPoint startLocation;
@property (readonly) CGPoint selectLocation;
- (CGRect)viewRectForOrientation:(UIInterfaceOrientation)orientation;
Expand All @@ -19,6 +20,7 @@
@property CGPoint dpadLocation;
@property CGPoint aLocation;
@property CGPoint bLocation;
@property CGPoint abComboLocation;
@property CGPoint startLocation;
@property CGPoint selectLocation;
@property (readonly) CGSize resolution;
Expand Down
6 changes: 6 additions & 0 deletions iOS/GBSettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ + (UIImage *)previewImageForTheme:(NSString *)theme
return @"Directional input is determined by the touch position.";
},
},
@{
@"items": @[
@{@"type": typeCheck, @"pref": @"GBEnableABCombo", @"title": @"Single-Touch A+B"},
],
@"footer": @"Enable this option to allow pressing A+B by touching the space between the two buttons",
},
@{
@"header": @"Horizontal Swipe Behavior",
@"items": @[
Expand Down
2 changes: 2 additions & 0 deletions iOS/GBVerticalLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ - (instancetype)init
round(buttonsCenter.y + buttonsDelta.height / 2)
};

self.abComboLocation = buttonsCenter;

double controlsTop = self.dpadLocation.y - 80 * self.factor;
double middleSpace = self.bLocation.x - buttonRadius - (self.dpadLocation.x + 80 * self.factor);

Expand Down

0 comments on commit a791f7e

Please sign in to comment.