Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
8a8592e3
Commit
8a8592e3
authored
Mar 27, 2011
by
Ryan C. Gordon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iOS: Report both landscape and portrait orientation as display modes.
parent
f731db9d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
9 deletions
+70
-9
SDL_uikitvideo.m
src/video/uikit/SDL_uikitvideo.m
+51
-5
SDL_uikitwindow.m
src/video/uikit/SDL_uikitwindow.m
+19
-4
No files found.
src/video/uikit/SDL_uikitvideo.m
View file @
8a8592e3
...
...
@@ -119,6 +119,32 @@ The main screen should list a AxB mode for portrait orientation, and then
*/
static
CGSize
UIKit_ForcePortrait
(
const
CGSize
size
)
{
CGSize
retval
;
if
(
size
.
width
<
size
.
height
)
{
// portrait
retval
=
size
;
}
else
{
// landscape
retval
.
width
=
size
.
height
;
retval
.
height
=
size
.
width
;
}
return
retval
;
}
static
CGSize
UIKit_ForceLandscape
(
const
CGSize
size
)
{
CGSize
retval
;
if
(
size
.
width
>
size
.
height
)
{
// landscape
retval
=
size
;
}
else
{
// portrait
retval
.
width
=
size
.
height
;
retval
.
height
=
size
.
width
;
}
return
retval
;
}
static
void
UIKit_GetDisplayModes
(
_THIS
,
SDL_VideoDisplay
*
display
)
{
...
...
@@ -136,22 +162,42 @@ UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
mode
.
refresh_rate
=
0
;
mode
.
driverdata
=
NULL
;
SDL_AddDisplayMode
(
display
,
&
mode
);
mode
.
w
=
(
int
)
rect
.
size
.
height
;
// swap the orientation, add again.
mode
.
h
=
(
int
)
rect
.
size
.
width
;
SDL_AddDisplayMode
(
display
,
&
mode
);
return
;
}
const
int
ismain
=
(
uiscreen
==
[
UIScreen
mainScreen
]);
const
NSArray
*
modes
=
[
uiscreen
availableModes
];
const
NSUInteger
mode_count
=
[
modes
count
];
NSUInteger
i
;
for
(
i
=
0
;
i
<
mode_count
;
i
++
)
{
UIScreenMode
*
uimode
=
(
UIScreenMode
*
)
[
modes
objectAtIndex
:
i
];
const
CGSize
size
=
[
uimode
size
];
CGSize
size
=
[
uimode
size
];
mode
.
format
=
SDL_PIXELFORMAT_ABGR8888
;
mode
.
w
=
(
int
)
size
.
width
;
mode
.
h
=
(
int
)
size
.
height
;
mode
.
refresh_rate
=
0
;
mode
.
driverdata
=
uimode
;
mode
.
w
=
(
int
)
size
.
width
;
mode
.
h
=
(
int
)
size
.
height
;
if
(
SDL_AddDisplayMode
(
display
,
&
mode
))
[
uimode
retain
];
SDL_AddDisplayMode
(
display
,
&
mode
);
if
(
ismain
)
{
// Add the mode twice, flipped to portrait and landscape.
// SDL_AddDisplayMode() will ignore duplicates.
size
=
UIKit_ForcePortrait
([
uimode
size
]);
mode
.
w
=
(
int
)
size
.
width
;
mode
.
h
=
(
int
)
size
.
height
;
if
(
SDL_AddDisplayMode
(
display
,
&
mode
))
[
uimode
retain
];
size
=
UIKit_ForceLandscape
(
size
);
mode
.
w
=
(
int
)
size
.
width
;
mode
.
h
=
(
int
)
size
.
height
;
if
(
SDL_AddDisplayMode
(
display
,
&
mode
))
[
uimode
retain
];
}
}
}
...
...
src/video/uikit/SDL_uikitwindow.m
View file @
8a8592e3
...
...
@@ -63,20 +63,35 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
window->driverdata = data;
window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizeable */
window->flags |= SDL_WINDOW_FULLSCREEN; /* window is always fullscreen */
window->flags |= SDL_WINDOW_SHOWN; /* only one window on iPod touch, always shown */
window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */
// SDL_WINDOW_BORDERLESS controls whether status bar is hidden.
// This is only set if the window is on the main screen. Other screens
// just force the window to have the borderless flag.
if ([UIScreen mainScreen] == uiscreen) {
if ([UIScreen mainScreen] != uiscreen) {
window->flags &= ~SDL_WINDOW_RESIZABLE; // window is NEVER resizeable
window->flags &= ~SDL_WINDOW_INPUT_FOCUS; // never has input focus
} else {
window->flags |= SDL_WINDOW_INPUT_FOCUS; // always has input focus
if (window->flags & SDL_WINDOW_BORDERLESS) {
[UIApplication sharedApplication].statusBarHidden = YES;
} else {
[UIApplication sharedApplication].statusBarHidden = NO;
}
// Rotate the view if we have to, but only on the main screen
// (presumably, an external display doesn't report orientation).
const CGSize uisize = [[uiscreen currentMode] size];
if ( ((window->w > window->h) && (uisize.width < uisize.height)) ||
((window->w < window->h) && (uisize.width > uisize.height)) ) {
// !!! FIXME: flip orientation.
}
if (window->flags & SDL_WINDOW_RESIZABLE) {
// !!! FIXME: register for orientation change alerts.
}
}
return 0;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment