SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit a791f7e621e34a0f0bdafbc18fa108a5e4ad228e parent 3f799f21ffb5a7e055d3890b50819d9f3709aa5f Author: Lior Halphon <LIJI32@gmail.com> Date: Sat, 6 Apr 2024 15:16:41 +0300 Add an option to enable single-touch A+B combo in iOS, closes #587 Diffstat:
| M | iOS/GBBackgroundView.m | 4 | ++++ |
| M | iOS/GBHorizontalLayout.m | 3 | +++ |
| M | iOS/GBLayout.h | 2 | ++ |
| M | iOS/GBSettingsViewController.m | 6 | ++++++ |
| M | iOS/GBVerticalLayout.m | 2 | ++ |
5 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/iOS/GBBackgroundView.m b/iOS/GBBackgroundView.m @@ -332,6 +332,10 @@ static GB_key_mask_t angleToKeyMask(double angle) 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) { diff --git a/iOS/GBHorizontalLayout.m b/iOS/GBHorizontalLayout.m @@ -85,6 +85,9 @@ 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]; diff --git a/iOS/GBLayout.h b/iOS/GBLayout.h @@ -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; @@ -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; diff --git a/iOS/GBSettingsViewController.m b/iOS/GBSettingsViewController.m @@ -322,6 +322,12 @@ static NSString const *typeLightTemp = @"typeLightTemp"; }, }, @{ + @"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": @[ @{@"type": typeCheck, @"pref": @"GBDynamicSpeed", @"title": @"Dynamically Control Speed"}, diff --git a/iOS/GBVerticalLayout.m b/iOS/GBVerticalLayout.m @@ -54,6 +54,8 @@ 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);
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.