mirror of
https://github.com/encounter/SDL.git
synced 2025-12-18 09:25:29 +00:00
Added SDL_GetDisplayOrientation() to get the display orientation, and added a new event SDL_DISPLAYEVENT to notify the application when the orientation changes.
Documented the values returned by the accelerometer and gyroscope sensors
This commit is contained in:
@@ -119,8 +119,8 @@ struct SDL_Window
|
||||
!((W)->flags & SDL_WINDOW_MINIMIZED))
|
||||
|
||||
/*
|
||||
* Define the SDL display structure This corresponds to physical monitors
|
||||
* attached to the system.
|
||||
* Define the SDL display structure.
|
||||
* This corresponds to physical monitors attached to the system.
|
||||
*/
|
||||
struct SDL_VideoDisplay
|
||||
{
|
||||
@@ -130,6 +130,7 @@ struct SDL_VideoDisplay
|
||||
SDL_DisplayMode *display_modes;
|
||||
SDL_DisplayMode desktop_mode;
|
||||
SDL_DisplayMode current_mode;
|
||||
SDL_DisplayOrientation orientation;
|
||||
|
||||
SDL_Window *fullscreen_window;
|
||||
|
||||
@@ -180,16 +181,16 @@ struct SDL_VideoDevice
|
||||
*/
|
||||
int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
|
||||
|
||||
/*
|
||||
* Get the dots/pixels-per-inch of a display
|
||||
*/
|
||||
int (*GetDisplayDPI) (_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi);
|
||||
|
||||
/*
|
||||
* Get the usable bounds of a display (bounds minus menubar or whatever)
|
||||
*/
|
||||
int (*GetDisplayUsableBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
|
||||
|
||||
/*
|
||||
* Get the dots/pixels-per-inch of a display
|
||||
*/
|
||||
int (*GetDisplayDPI) (_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi);
|
||||
|
||||
/*
|
||||
* Get a list of the available display modes for a display.
|
||||
*/
|
||||
@@ -426,6 +427,8 @@ extern SDL_VideoDevice *SDL_GetVideoDevice(void);
|
||||
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
|
||||
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
|
||||
extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
|
||||
extern int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display);
|
||||
extern SDL_VideoDisplay *SDL_GetDisplay(int displayIndex);
|
||||
extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window);
|
||||
extern void *SDL_GetDisplayDriverData( int displayIndex );
|
||||
|
||||
|
||||
@@ -641,7 +641,7 @@ SDL_GetNumVideoDisplays(void)
|
||||
return _this->num_displays;
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
SDL_GetIndexOfDisplay(SDL_VideoDisplay *display)
|
||||
{
|
||||
int displayIndex;
|
||||
@@ -739,6 +739,17 @@ SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_DisplayOrientation
|
||||
SDL_GetDisplayOrientation(int displayIndex)
|
||||
{
|
||||
SDL_VideoDisplay *display;
|
||||
|
||||
CHECK_DISPLAY_INDEX(displayIndex, SDL_ORIENTATION_UNKNOWN);
|
||||
|
||||
display = &_this->displays[displayIndex];
|
||||
return display->orientation;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_AddDisplayMode(SDL_VideoDisplay * display, const SDL_DisplayMode * mode)
|
||||
{
|
||||
@@ -1009,6 +1020,14 @@ SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode *
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_VideoDisplay *
|
||||
SDL_GetDisplay(int displayIndex)
|
||||
{
|
||||
CHECK_DISPLAY_INDEX(displayIndex, NULL);
|
||||
|
||||
return &_this->displays[displayIndex];
|
||||
}
|
||||
|
||||
int
|
||||
SDL_GetWindowDisplayIndex(SDL_Window * window)
|
||||
{
|
||||
|
||||
@@ -451,6 +451,7 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
|
||||
if (_this && _this->num_displays > 0) {
|
||||
SDL_DisplayMode *desktopmode = &_this->displays[0].desktop_mode;
|
||||
SDL_DisplayMode *currentmode = &_this->displays[0].current_mode;
|
||||
SDL_DisplayOrientation orientation = SDL_ORIENTATION_UNKNOWN;
|
||||
|
||||
/* The desktop display mode should be kept in sync with the screen
|
||||
* orientation so that updating a window's fullscreen state to
|
||||
@@ -468,6 +469,26 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
|
||||
currentmode->w = currentmode->h;
|
||||
currentmode->h = height;
|
||||
}
|
||||
|
||||
switch (application.statusBarOrientation) {
|
||||
case UIInterfaceOrientationPortrait:
|
||||
orientation = SDL_ORIENTATION_PORTRAIT;
|
||||
break;
|
||||
case UIInterfaceOrientationPortraitUpsideDown:
|
||||
orientation = SDL_ORIENTATION_PORTRAIT_FLIPPED;
|
||||
break;
|
||||
case UIInterfaceOrientationLandscapeLeft:
|
||||
/* Bug: UIInterfaceOrientationLandscapeLeft/Right are reversed - http://openradar.appspot.com/7216046 */
|
||||
orientation = SDL_ORIENTATION_LANDSCAPE_FLIPPED;
|
||||
break;
|
||||
case UIInterfaceOrientationLandscapeRight:
|
||||
/* Bug: UIInterfaceOrientationLandscapeLeft/Right are reversed - http://openradar.appspot.com/7216046 */
|
||||
orientation = SDL_ORIENTATION_LANDSCAPE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
SDL_SendDisplayEvent(&_this->displays[0], SDL_DISPLAYEVENT_ORIENTATION, orientation);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user