SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 58c946f249a50064f7761d307b12f5b0ed21bcc4 parent 0b57886491831988c6ffc61a0169a3c8e48986fc Author: Lior Halphon <LIJI32@gmail.com> Date: Sun, 27 Jul 2025 03:10:17 +0300 Fix accelerometer auto-rotating on iOS 16 and newer Diffstat:
| M | iOS/GBViewController.m | 11 | ++++++++++- |
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/iOS/GBViewController.m b/iOS/GBViewController.m @@ -903,6 +903,11 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp) _romLoaded = GB_load_rom(&_gb, romManager.romFile.fileSystemRepresentation) == 0; } needsStateLoad = true; + if (@available(iOS 16.0, *)) { + dispatch_async(dispatch_get_main_queue(), ^{ + [super setNeedsUpdateOfSupportedInterfaceOrientations]; + }); + } } else if (access(romManager.romFile.fileSystemRepresentation, R_OK)) { _romLoaded = false; @@ -1157,9 +1162,9 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp) - (void)setNeedsUpdateOfSupportedInterfaceOrientations { /* Hack. Some view controllers dismiss without calling the method above. */ - [super setNeedsUpdateOfSupportedInterfaceOrientations]; dispatch_async(dispatch_get_main_queue(), ^{ [self start]; + [super setNeedsUpdateOfSupportedInterfaceOrientations]; }); } @@ -1191,6 +1196,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp) - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration { + if (_orientation != UIInterfaceOrientationUnknown && !((1 << orientation) & self.supportedInterfaceOrientations)) return; GBLayout *layout = nil; _orientation = orientation; switch (orientation) { @@ -1249,6 +1255,9 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp) - (UIInterfaceOrientationMask)supportedInterfaceOrientations { + if (!self.shouldAutorotate && _orientation != UIInterfaceOrientationUnknown) { + return 1 << _orientation; + } if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) { return UIInterfaceOrientationMaskAll; }
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.