21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_UIKIT 28 #include "../../events/SDL_events_c.h" 49 if (uiscreenmode != nil) {
59 mode->
driverdata = (
void *) CFBridgingRetain(data);
74 UIKit_GetDisplayModeRefreshRate(UIScreen *uiscreen)
77 if ([uiscreen respondsToSelector:
@selector(maximumFramesPerSecond)]) {
78 return uiscreen.maximumFramesPerSecond;
86 UIScreen * uiscreen, UIScreenMode * uiscreenmode)
91 if (UIKit_AllocateDisplayModeData(&mode, uiscreenmode) < 0) {
96 mode.
refresh_rate = (int) UIKit_GetDisplayModeRefreshRate(uiscreen);
103 UIKit_FreeDisplayModeData(&mode);
109 UIKit_AddDisplayMode(
SDL_VideoDisplay * display,
int w,
int h, UIScreen * uiscreen,
110 UIScreenMode * uiscreenmode,
SDL_bool addRotation)
112 if (UIKit_AddSingleDisplayMode(display, w, h, uiscreen, uiscreenmode) < 0) {
118 if (UIKit_AddSingleDisplayMode(display, h, w, uiscreen, uiscreenmode) < 0) {
127 UIKit_AddDisplay(UIScreen *uiscreen)
129 UIScreenMode *uiscreenmode = uiscreen.currentMode;
130 CGSize
size = uiscreen.bounds.size;
137 CGFloat
height = size.width;
138 size.width = size.height;
143 mode.
refresh_rate = (int) UIKit_GetDisplayModeRefreshRate(uiscreen);
144 mode.
w = (int) size.width;
145 mode.
h = (
int) size.height;
147 if (UIKit_AllocateDisplayModeData(&mode, uiscreenmode) < 0) {
164 display.
driverdata = (
void *) CFBridgingRetain(data);
174 if (uiscreen == [UIScreen mainScreen]) {
175 return UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
179 CGSize size = uiscreen.bounds.size;
180 return (size.width > size.height);
188 for (UIScreen *uiscreen
in [UIScreen screens]) {
189 if (UIKit_AddDisplay(uiscreen) < 0) {
210 NSArray *availableModes = nil;
214 availableModes = @[data.uiscreen.currentMode];
216 availableModes = data.
uiscreen.availableModes;
222 if ([data.
uiscreen respondsToSelector:
@selector(nativeScale)]) {
227 for (UIScreenMode *uimode
in availableModes) {
230 int w = (int)(uimode.size.width / scale);
231 int h = (int)(uimode.size.height / scale);
234 if (isLandscape != (w > h)) {
240 UIKit_AddDisplayMode(display, w, h, data.
uiscreen, uimode, addRotation);
253 [data.uiscreen setCurrentMode:modedata.uiscreenmode];
256 if (data.
uiscreen == [UIScreen mainScreen]) {
260 if (mode->
w > mode->
h) {
262 return SDL_SetError(
"Screen orientation does not match display mode size");
264 }
else if (mode->
w < mode->
h) {
266 return SDL_SetError(
"Screen orientation does not match display mode size");
289 #if !TARGET_OS_TV && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0 291 frame = [data.uiscreen applicationFrame];
297 rect->
w =
frame.size.width;
298 rect->
h =
frame.size.height;
316 UIKit_FreeDisplayModeData(mode);
330 BOOL isLandscape = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
342 if (isLandscape != (desktopmode->
w > desktopmode->
h)) {
344 desktopmode->
w = desktopmode->
h;
349 if (isLandscape != (currentmode->
w > currentmode->
h)) {
351 currentmode->
w = currentmode->
h;
355 switch ([UIApplication sharedApplication].statusBarOrientation) {
356 case UIInterfaceOrientationPortrait:
359 case UIInterfaceOrientationPortraitUpsideDown:
362 case UIInterfaceOrientationLandscapeLeft:
366 case UIInterfaceOrientationLandscapeRight:
int UIKit_InitModes(_THIS)
GLenum GLenum GLenum GLenum GLenum scale
SDL_bool UIKit_IsSystemVersionAtLeast(double version)
void UIKit_QuitModes(_THIS)
GLint GLint GLint GLint GLint x
SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen)
GLfloat GLfloat GLfloat GLfloat h
The structure that defines a display mode.
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
void UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display)
static SDL_VideoDevice * _this
SDL_VideoDisplay * SDL_GetDisplay(int displayIndex)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
SDL_DisplayMode * display_modes
SDL_DisplayMode current_mode
GLubyte GLubyte GLubyte GLubyte w
SDL_VideoDisplay * displays
#define SDL_GetDisplayBounds
GLint GLint GLint GLint GLint GLint y
int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data1)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
int UIKit_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
#define SDL_OutOfMemory()
SDL_DisplayMode desktop_mode
GLint GLint GLsizei GLsizei height
UIScreenMode * uiscreenmode
SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
void SDL_OnApplicationDidChangeStatusBarOrientation(void)
A rectangle, with the origin at the upper left.
int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)