SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 1ad8bad18ca02947c351b686179473704cab42e7 parent 9577cbce85bd8233bbd422855e9e60bd0d6f73ba Author: Lior Halphon <LIJI32@gmail.com> Date: Sun, 8 Jun 2025 19:28:42 +0300 Add iOS rapid buttons, closes #702 Diffstat:
| M | iOS/GBSettingsViewController.h | 5 | ++--- |
| M | iOS/GBSettingsViewController.m | 2 | ++ |
| M | iOS/GBViewController.m | 19 | +++++++++++++++++++ |
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/iOS/GBSettingsViewController.h b/iOS/GBSettingsViewController.h @@ -15,11 +15,10 @@ typedef enum { GBTurbo, GBRewind, GBUnderclock, + GBRapidA, + GBRapidB, // GBHotkey1, // Todo // GBHotkey2, // Todo - GBTotalButtonCount, - GBKeyboardButtonCount = GBUnderclock + 1, - GBPerPlayerButtonCount = GBStart + 1, GBUnusedButton = 0xFF, } GBButton; diff --git a/iOS/GBSettingsViewController.m b/iOS/GBSettingsViewController.m @@ -569,6 +569,8 @@ static NSString *LocalizedNameForElement(GCControllerElement *element, GBControl @{@"type": typeRadio, @"getter": getter, @"setter": setter, @"title": @"B", @"value": @(GBB)}, @{@"type": typeRadio, @"getter": getter, @"setter": setter, @"title": @"Select", @"value": @(GBSelect)}, @{@"type": typeRadio, @"getter": getter, @"setter": setter, @"title": @"Start", @"value": @(GBStart)}, + @{@"type": typeRadio, @"getter": getter, @"setter": setter, @"title": @"Rapid A", @"value": @(GBRapidA)}, + @{@"type": typeRadio, @"getter": getter, @"setter": setter, @"title": @"Rapid B", @"value": @(GBRapidB)}, @{@"type": typeRadio, @"getter": getter, @"setter": setter, @"title": @"Turbo", @"value": @(GBTurbo)}, @{@"type": typeRadio, @"getter": getter, @"setter": setter, @"title": @"Rewind", @"value": @(GBRewind)}, @{@"type": typeRadio, @"getter": getter, @"setter": setter, @"title": @"Slow-motion", @"value": @(GBUnderclock)}, diff --git a/iOS/GBViewController.m b/iOS/GBViewController.m @@ -35,6 +35,9 @@ bool _swappingROM; bool _skipAutoLoad; + bool _rapidA, _rapidB; + uint8_t _rapidACount, _rapidBCount; + UIInterfaceOrientation _orientation; GBHorizontalLayout *_horizontalLayoutLeft; GBHorizontalLayout *_horizontalLayoutRight; @@ -526,6 +529,14 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp) case GBStart: GB_set_key_state(&_gb, (GB_key_t)gbButton, button.value > 0.25); break; + case GBRapidA: + _rapidA = button.value > 0.25; + _rapidACount = 0; + break; + case GBRapidB: + _rapidB = button.value > 0.25; + _rapidBCount = 0; + break; case GBTurbo: if (button.value > analogThreshold) { [self setRunMode:GBRunModeTurbo ignoreDynamicSpeed:!button.isAnalog]; @@ -1331,6 +1342,14 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response [_gbView flip]; GB_set_pixels_output(&_gb, _gbView.pixels); } + if (_rapidA) { + _rapidACount++; + GB_set_key_state(&_gb, GB_KEY_A, !(_rapidACount & 2)); + } + if (_rapidB) { + _rapidBCount++; + GB_set_key_state(&_gb, GB_KEY_B, !(_rapidBCount & 2)); + } _rewind = _runMode == GBRunModeRewind; }
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.