git.y1.nz

SameBoy

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

commit e0b77d3821ccaa83f07549df0621a661dd040e97
parent 2530370f90cac434fe46301da12f365bc19acb87
Author: Lior Halphon <LIJI32@gmail.com>
Date:   Fri, 20 Jan 2023 00:58:47 +0200

Can't permanently disable the Home Bar, so the Safe Area must be followed :(

Diffstat:
MiOS/GBHorizontalLayout.m8++++----
MiOS/GBLayout.h1+
MiOS/GBLayout.m4++++
MiOS/GBViewController.m14++++++++++----
4 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/iOS/GBHorizontalLayout.m b/iOS/GBHorizontalLayout.m @@ -11,13 +11,13 @@ CGSize resolution = {self.resolution.height - self.cutout, self.resolution.width}; CGRect screenRect = {0,}; - screenRect.size.height = self.hasFractionalPixels? resolution.height : floor(resolution.height / 144) * 144; + screenRect.size.height = self.hasFractionalPixels? resolution.height : floor((resolution.height - self.homeBar) / 144) * 144; screenRect.size.width = screenRect.size.height / 144 * 160; double horizontalMargin, verticalMargin; while (true) { horizontalMargin = (resolution.width - screenRect.size.width) / 2; - verticalMargin = (resolution.height - screenRect.size.height) / 2; + verticalMargin = (resolution.height - self.homeBar - screenRect.size.height) / 2; if (horizontalMargin / self.factor < 164) { if (self.hasFractionalPixels) { screenRect.size.width = resolution.width - 164 * self.factor * 2; @@ -37,10 +37,10 @@ bool drawSameBoyLogo = false; if (verticalMargin * 2 > screenBorderWidth * 7) { drawSameBoyLogo = true; - screenRect.origin.y = (resolution.height - screenRect.size.height - screenBorderWidth * 5) / 2; + screenRect.origin.y = (resolution.height - self.homeBar - screenRect.size.height - screenBorderWidth * 5) / 2; } else { - screenRect.origin.y = (resolution.height - screenRect.size.height) / 2; + screenRect.origin.y = (resolution.height - self.homeBar - screenRect.size.height) / 2; } self.screenRect = screenRect; diff --git a/iOS/GBLayout.h b/iOS/GBLayout.h @@ -24,6 +24,7 @@ @property (readonly) CGSize resolution; @property (readonly) unsigned factor; @property (readonly) unsigned minY; +@property (readonly) unsigned homeBar; @property (readonly) unsigned cutout; @property (readonly) bool hasFractionalPixels; diff --git a/iOS/GBLayout.m b/iOS/GBLayout.m @@ -21,6 +21,10 @@ ignoreHidden:true] * _factor; _cutout = _minY <= 24 * _factor? 0 : _minY; + if ([UIApplication sharedApplication].windows[0].safeAreaInsets.bottom) { + _homeBar = 21 * _factor; + } + // The Plus series will scale things lossily anyway, so no need to bother with integer scale things // This also "catches" zoomed display modes _hasFractionalPixels = _factor != [UIScreen mainScreen].nativeScale; diff --git a/iOS/GBViewController.m b/iOS/GBViewController.m @@ -271,10 +271,16 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp) - (BOOL)prefersHomeIndicatorAutoHidden { - UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; - if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) { - return false; - } + return true; +} + +- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures +{ + return UIRectEdgeTop; +} + +- (BOOL)prefersStatusBarHidden +{ return true; }

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