mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-13 14:58:14 +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:
@@ -1048,6 +1048,22 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
static const char *
|
||||
DisplayOrientationName(int orientation)
|
||||
{
|
||||
switch (orientation)
|
||||
{
|
||||
#define CASE(X) case SDL_ORIENTATION_##X: return #X
|
||||
CASE(UNKNOWN);
|
||||
CASE(LANDSCAPE);
|
||||
CASE(LANDSCAPE_FLIPPED);
|
||||
CASE(PORTRAIT);
|
||||
CASE(PORTRAIT_FLIPPED);
|
||||
#undef CASE
|
||||
default: return "???";
|
||||
}
|
||||
}
|
||||
|
||||
static const char *
|
||||
ControllerAxisName(const SDL_GameControllerAxis axis)
|
||||
{
|
||||
@@ -1102,6 +1118,17 @@ SDLTest_PrintEvent(SDL_Event * event)
|
||||
}
|
||||
|
||||
switch (event->type) {
|
||||
case SDL_DISPLAYEVENT:
|
||||
switch (event->display.event) {
|
||||
case SDL_DISPLAYEVENT_ORIENTATION:
|
||||
SDL_Log("SDL EVENT: Display %d changed orientation to %s", event->display.display, DisplayOrientationName(event->display.data1));
|
||||
break;
|
||||
default:
|
||||
SDL_Log("SDL EVENT: Display %d got unknown event 0x%4.4x",
|
||||
event->display.display, event->display.event);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SDL_WINDOWEVENT:
|
||||
switch (event->window.event) {
|
||||
case SDL_WINDOWEVENT_SHOWN:
|
||||
|
Reference in New Issue
Block a user