Add love.window.getDisplayOrientation and a love.displayrotated callback. Resolves issue #1441.

Note that this tracks screen orientation, rather than device orientation.
This commit is contained in:
Alex Szpakowski
2018-12-17 16:19:56 -04:00
parent 43ee232897
commit d4762b4612
8 changed files with 134 additions and 0 deletions
+20
View File
@@ -743,6 +743,26 @@ const char *Window::getDisplayName(int displayindex) const
return name;
}
Window::DisplayOrientation Window::getDisplayOrientation(int displayindex) const
{
// TODO: We can expose this everywhere, we just need to watch out for the
// SDL binary being older than the headers on Linux.
#if SDL_VERSION_ATLEAST(2, 0, 9) && (defined(LOVE_ANDROID) || !defined(LOVE_LINUX))
switch (SDL_GetDisplayOrientation(displayindex))
{
case SDL_ORIENTATION_UNKNOWN: return ORIENTATION_UNKNOWN;
case SDL_ORIENTATION_LANDSCAPE: return ORIENTATION_LANDSCAPE;
case SDL_ORIENTATION_LANDSCAPE_FLIPPED: return ORIENTATION_LANDSCAPE_FLIPPED;
case SDL_ORIENTATION_PORTRAIT: return ORIENTATION_PORTRAIT;
case SDL_ORIENTATION_PORTRAIT_FLIPPED: return ORIENTATION_PORTRAIT_FLIPPED;
}
#else
LOVE_UNUSED(displayindex);
#endif
return ORIENTATION_UNKNOWN;
}
std::vector<Window::WindowSize> Window::getFullscreenSizes(int displayindex) const
{
std::vector<WindowSize> sizes;
+2
View File
@@ -57,6 +57,8 @@ public:
const char *getDisplayName(int displayindex) const override;
DisplayOrientation getDisplayOrientation(int displayindex) const override;
std::vector<WindowSize> getFullscreenSizes(int displayindex) const override;
void getDesktopDimensions(int displayindex, int &width, int &height) const override;