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:
Sam Lantinga 2018-08-22 21:48:28 -07:00
parent f1bc1c1274
commit f225af0c1e
14 changed files with 290 additions and 25 deletions

View file

@ -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: