mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-19 19:28:28 +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:
parent
f1bc1c1274
commit
f225af0c1e
14 changed files with 290 additions and 25 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue