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
@@ -215,6 +215,25 @@ int w_getMode(lua_State *L)
return 3;
}
int w_getDisplayOrientation(lua_State *L)
{
int displayindex = 0;
if (!lua_isnoneornil(L, 1))
displayindex = (int) luaL_checkinteger(L, 1) - 1;
else
{
int x, y;
instance()->getPosition(x, y, displayindex);
}
const char *orientationstr = nullptr;
if (!Window::getConstant(instance()->getDisplayOrientation(displayindex), orientationstr))
return luaL_error(L, "Unknown display orientation type.");
lua_pushstring(L, orientationstr);
return 1;
}
int w_getFullscreenModes(lua_State *L)
{
int displayindex = 0;
@@ -562,6 +581,7 @@ static const luaL_Reg functions[] =
{ "setMode", w_setMode },
{ "updateMode", w_updateMode },
{ "getMode", w_getMode },
{ "getDisplayOrientation", w_getDisplayOrientation },
{ "getFullscreenModes", w_getFullscreenModes },
{ "setFullscreen", w_setFullscreen },
{ "getFullscreen", w_getFullscreen },