Add an option to enable single-touch A+B combo in iOS, closes #587

This commit is contained in:
Lior Halphon
2024-04-06 15:16:41 +03:00
parent 3f799f21ff
commit a791f7e621
5 changed files with 17 additions and 0 deletions

View File

@@ -332,6 +332,10 @@ static GB_key_mask_t angleToKeyMask(double angle)
else if (CGPointSquaredDistance(point, _layout.selectLocation) <= buttonRadiusSquared) { else if (CGPointSquaredDistance(point, _layout.selectLocation) <= buttonRadiusSquared) {
mask |= GB_KEY_SELECT_MASK; 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 && else if (!dpadHandled &&
fabs(point.x - _layout.dpadLocation.x) <= dpadRadius && fabs(point.x - _layout.dpadLocation.x) <= dpadRadius &&
fabs(point.y - _layout.dpadLocation.y) <= dpadRadius) { fabs(point.y - _layout.dpadLocation.y) <= dpadRadius) {

View File

@@ -85,6 +85,9 @@
self.bLocation = (CGPoint){self.bLocation.x + self.cutout, self.bLocation.y}; self.bLocation = (CGPoint){self.bLocation.x + self.cutout, self.bLocation.y};
self.startLocation = (CGPoint){self.startLocation.x + self.cutout, self.startLocation.y}; self.startLocation = (CGPoint){self.startLocation.x + self.cutout, self.startLocation.y};
self.selectLocation = (CGPoint){self.selectLocation.x + self.cutout, self.selectLocation.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); UIGraphicsBeginImageContextWithOptions(resolution, true, 1);
[self drawBackground]; [self drawBackground];

View File

@@ -6,6 +6,7 @@
@property (readonly) CGPoint dpadLocation; @property (readonly) CGPoint dpadLocation;
@property (readonly) CGPoint aLocation; @property (readonly) CGPoint aLocation;
@property (readonly) CGPoint bLocation; @property (readonly) CGPoint bLocation;
@property (readonly) CGPoint abComboLocation;
@property (readonly) CGPoint startLocation; @property (readonly) CGPoint startLocation;
@property (readonly) CGPoint selectLocation; @property (readonly) CGPoint selectLocation;
- (CGRect)viewRectForOrientation:(UIInterfaceOrientation)orientation; - (CGRect)viewRectForOrientation:(UIInterfaceOrientation)orientation;
@@ -19,6 +20,7 @@
@property CGPoint dpadLocation; @property CGPoint dpadLocation;
@property CGPoint aLocation; @property CGPoint aLocation;
@property CGPoint bLocation; @property CGPoint bLocation;
@property CGPoint abComboLocation;
@property CGPoint startLocation; @property CGPoint startLocation;
@property CGPoint selectLocation; @property CGPoint selectLocation;
@property (readonly) CGSize resolution; @property (readonly) CGSize resolution;

View File

@@ -321,6 +321,12 @@ static NSString const *typeLightTemp = @"typeLightTemp";
return @"Directional input is determined by the touch position."; 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", @"header": @"Horizontal Swipe Behavior",
@"items": @[ @"items": @[

View File

@@ -54,6 +54,8 @@
round(buttonsCenter.y + buttonsDelta.height / 2) round(buttonsCenter.y + buttonsDelta.height / 2)
}; };
self.abComboLocation = buttonsCenter;
double controlsTop = self.dpadLocation.y - 80 * self.factor; double controlsTop = self.dpadLocation.y - 80 * self.factor;
double middleSpace = self.bLocation.x - buttonRadius - (self.dpadLocation.x + 80 * self.factor); double middleSpace = self.bLocation.x - buttonRadius - (self.dpadLocation.x + 80 * self.factor);