git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

commit ddce507f4a3da96ed2b3371fc25713c151ff6615
parent 3ea8dd5908066738ea3406e9b835d95b8292fdc1
Author: Lior Halphon <LIJI32@gmail.com>
Date:   Sat, 28 Feb 2026 02:23:42 +0200

Add a second UI hiding mode, closes #739

Diffstat:
MiOS/GBBackgroundView.h3++-
MiOS/GBBackgroundView.m12++++++------
MiOS/GBSettingsViewController.h6++++++
MiOS/GBSettingsViewController.m6++++--
MiOS/GBViewController.m12+++++-------
MiOS/main.m3++-
6 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/iOS/GBBackgroundView.h b/iOS/GBBackgroundView.h @@ -1,6 +1,7 @@ #import <UIKit/UIKit.h> #import "GBLayout.h" #import "GBView.h" +#import "GBSettingsViewController.h" @interface GBBackgroundView : UIImageView - (instancetype)initWithLayout:(GBLayout *)layout; @@ -8,7 +9,7 @@ @property (readonly) GBView *gbView; @property (nonatomic) GBLayout *layout; @property (nonatomic) bool usesSwipePad; -@property (nonatomic) bool fullScreenMode; +@property (nonatomic) GBControllerFocus fullScreenMode; - (void)enterPreviewMode:(bool)showLabel; - (void)reloadThemeImages; diff --git a/iOS/GBBackgroundView.m b/iOS/GBBackgroundView.m @@ -105,7 +105,7 @@ static GB_key_mask_t angleToKeyMask(double angle) NSTimer *_fadeTimer; GB_key_mask_t _lastMask; - bool _fullScreenMode; + GBControllerFocus _fullScreenMode; } - (void)reloadThemeImages @@ -198,7 +198,7 @@ static GB_key_mask_t angleToKeyMask(double angle) { if (_previewMode) return; if (_fullScreenMode) { - self.fullScreenMode = false; + self.fullScreenMode = GBControllerFocusOff; return; } static const double dpadRadius = 75; @@ -487,7 +487,7 @@ static GB_key_mask_t angleToKeyMask(double angle) screenFrame.size.width /= [UIScreen mainScreen].scale; screenFrame.size.height /= [UIScreen mainScreen].scale; - if (_fullScreenMode) { + if (_fullScreenMode == GBControllerFocusOn) { CGRect fullScreenFrame = layout.fullScreenRect; fullScreenFrame.origin.x /= [UIScreen mainScreen].scale; fullScreenFrame.origin.y /= [UIScreen mainScreen].scale; @@ -626,18 +626,18 @@ static GB_key_mask_t angleToKeyMask(double angle) _previewMode = true; } -- (bool)fullScreenMode +- (GBControllerFocus)fullScreenMode { return _fullScreenMode; } -- (void)setFullScreenMode:(bool)fullScreenMode +- (void)setFullScreenMode:(GBControllerFocus)fullScreenMode { if (fullScreenMode == _fullScreenMode) return; _fullScreenMode = fullScreenMode; [UIView animateWithDuration:1.0/3 animations:^{ // Animating alpha has some weird quirks for some reason - _fadeView.backgroundColor = [UIColor colorWithWhite:0 alpha:fullScreenMode]; + _fadeView.backgroundColor = [UIColor colorWithWhite:0 alpha:fullScreenMode? 1 : 0]; [self setLayout:_layout]; }]; [self.window.rootViewController setNeedsStatusBarAppearanceUpdate]; diff --git a/iOS/GBSettingsViewController.h b/iOS/GBSettingsViewController.h @@ -24,6 +24,12 @@ typedef enum { GBUnusedButton = 0xFF, } GBButton; +typedef enum { + GBControllerFocusOff, + GBControllerFocusOn, + GBControllerFocusDoNotCenter, +} GBControllerFocus; + @interface GBSettingsViewController : UITableViewController + (UIViewController *)settingsViewControllerWithLeftButton:(UIBarButtonItem *)button; + (GBButton)controller:(GCController *)controller convertUsageToButton:(GBControllerUsage)usage; diff --git a/iOS/GBSettingsViewController.m b/iOS/GBSettingsViewController.m @@ -386,10 +386,12 @@ static NSString const *typeTurboSlider = @"turboSlider"; ], }, @{ + @"header": @"While Using a Controller…", @"items": @[ - @{@"type": typeCheck, @"pref": @"GBControllersHideInterface", @"title": @"Hide UI While Using a Controller"}, + @{@"type": typeRadio, @"pref": @"GBControllersHideInterface", @"title": @"Keep the UI Visible", @"value": @(GBControllerFocusOff)}, + @{@"type": typeRadio, @"pref": @"GBControllersHideInterface", @"title": @"Hide the UI", @"value": @(GBControllerFocusDoNotCenter)}, + @{@"type": typeRadio, @"pref": @"GBControllersHideInterface", @"title": @"Hide the UI and Center the Screen", @"value": @(GBControllerFocusOn)}, ], - @"footer": @"When enabled, the on-screen user interface will be hidden while a game controller is being used." }, @{ @"header": @"Controller Joystick Behavior", diff --git a/iOS/GBViewController.m b/iOS/GBViewController.m @@ -638,7 +638,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp) - (void)controllerDisconnected:(NSNotification *)notification { if (notification.object == _lastController) { - _backgroundView.fullScreenMode = false; + _backgroundView.fullScreenMode = GBControllerFocusOff; } } @@ -685,9 +685,8 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp) - (void)controller:(GCController *)controller buttonChanged:(GCControllerButtonInput *)button usage:(GBControllerUsage)usage { [self updateLastController:controller]; - if (_running && button.value > 0.25 && - [[NSUserDefaults standardUserDefaults] boolForKey:@"GBControllersHideInterface"]) { - _backgroundView.fullScreenMode = true; + if (_running && button.value > 0.25) { + _backgroundView.fullScreenMode = [[NSUserDefaults standardUserDefaults] integerForKey:@"GBControllersHideInterface"]; } GBButton gbButton = [GBSettingsViewController controller:controller convertUsageToButton:usage]; @@ -813,9 +812,8 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp) if (!hasUnmappedChild) return; - if (_running && (left || right || up || down ) && - [[NSUserDefaults standardUserDefaults] boolForKey:@"GBControllersHideInterface"]) { - _backgroundView.fullScreenMode = true; + if (_running && (left || right || up || down)) { + _backgroundView.fullScreenMode = [[NSUserDefaults standardUserDefaults] integerForKey:@"GBControllersHideInterface"]; } if ([[NSUserDefaults standardUserDefaults] boolForKey:@"GBFauxAnalogInputs"]) { diff --git a/iOS/main.m b/iOS/main.m @@ -2,6 +2,7 @@ #import <Core/gb.h> #import "GBViewController.h" #import "GBView.h" +#import "GBSettingsViewController.h" static double MigrateTurboSpeed(void) { @@ -36,7 +37,7 @@ int main(int argc, char * argv[]) @"GBRumbleStrength": @1, @"GBInterfaceTheme": @"SameBoy", - @"GBControllersHideInterface": @YES, + @"GBControllersHideInterface": @(GBControllerFocusOn), @"GBCurrentTheme": @"Lime (Game Boy)", // Default themes

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.