21 #include "../../SDL_internal.h"
23 #if SDL_VIDEO_DRIVER_UIKIT
29 #include "../../events/SDL_events_c.h"
31 #import <sys/utsname.h>
35 - (instancetype)initWithScreen:(UIScreen*)screen
37 if (
self = [super
init]) {
142 struct utsname systemInfo;
144 NSString* deviceName =
145 [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
146 id foundDPI =
devices[deviceName];
148 self.screenDPI = (float)[foundDPI integerValue];
154 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000
160 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
162 }
else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
167 self.screenDPI =
scale * defaultDPI;
173 @synthesize uiscreen;
174 @synthesize screenDPI;
201 mode->driverdata = (
void *) CFBridgingRetain(
data);
210 CFRelease(
mode->driverdata);
216 UIKit_GetDisplayModeRefreshRate(UIScreen *uiscreen)
219 if ([uiscreen respondsToSelector:
@selector(maximumFramesPerSecond)]) {
220 return uiscreen.maximumFramesPerSecond;
238 mode.refresh_rate = (int) UIKit_GetDisplayModeRefreshRate(uiscreen);
245 UIKit_FreeDisplayModeData(&
mode);
254 if (UIKit_AddSingleDisplayMode(display,
w,
h, uiscreen,
uiscreenmode) < 0) {
260 if (UIKit_AddSingleDisplayMode(display,
h,
w, uiscreen,
uiscreenmode) < 0) {
269 UIKit_AddDisplay(UIScreen *uiscreen)
272 CGSize
size = uiscreen.bounds.size;
285 mode.refresh_rate = (int) UIKit_GetDisplayModeRefreshRate(uiscreen);
314 if (uiscreen == [UIScreen mainScreen]) {
315 return UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
319 CGSize
size = uiscreen.bounds.size;
328 for (UIScreen *uiscreen
in [UIScreen screens]) {
329 if (UIKit_AddDisplay(uiscreen) < 0) {
348 SDL_bool addRotation = (
data.uiscreen == [UIScreen mainScreen]);
350 NSArray *availableModes = nil;
354 availableModes = @[data.uiscreen.currentMode];
356 availableModes =
data.uiscreen.availableModes;
359 for (UIScreenMode *uimode
in availableModes) {
371 int w = (int)(uimode.size.width /
scale);
372 int h = (int)(uimode.size.height /
scale);
375 if (isLandscape != (
w >
h)) {
381 UIKit_AddDisplayMode(display,
w,
h,
data.uiscreen, uimode, addRotation);
391 float dpi =
data.screenDPI;
415 [data.uiscreen setCurrentMode:modedata.uiscreenmode];
418 if (
data.uiscreen == [UIScreen mainScreen]) {
424 return SDL_SetError(
"Screen orientation does not match display mode size");
428 return SDL_SetError(
"Screen orientation does not match display mode size");
451 #if !TARGET_OS_TV && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
453 frame = [data.uiscreen applicationFrame];
478 UIKit_FreeDisplayModeData(
mode);
492 BOOL isLandscape = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
504 if (isLandscape != (desktopmode->
w > desktopmode->
h)) {
506 desktopmode->
w = desktopmode->
h;
511 if (isLandscape != (currentmode->
w > currentmode->
h)) {
513 currentmode->
w = currentmode->
h;
517 switch ([UIApplication sharedApplication].statusBarOrientation) {
518 case UIInterfaceOrientationPortrait:
521 case UIInterfaceOrientationPortraitUpsideDown:
524 case UIInterfaceOrientationLandscapeLeft:
528 case UIInterfaceOrientationLandscapeRight: