mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Error for invalid constants passed to love.keyboard.isDown/isScancodeDown. Resolves issue #1313.
--HG-- branch : minor
This commit is contained in:
@@ -58,8 +58,12 @@ int w_isDown(lua_State *L)
|
|||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
lua_rawgeti(L, 1, i + 1);
|
lua_rawgeti(L, 1, i + 1);
|
||||||
if (Keyboard::getConstant(luaL_checkstring(L, -1), k))
|
|
||||||
keylist.push_back(k);
|
const char *name = luaL_checkstring(L, -1);
|
||||||
|
if (!Keyboard::getConstant(name, k))
|
||||||
|
return luaL_error(L, "Invalid key constant: %s", name);
|
||||||
|
|
||||||
|
keylist.push_back(k);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,8 +71,11 @@ int w_isDown(lua_State *L)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
if (Keyboard::getConstant(luaL_checkstring(L, i+1), k))
|
const char *name = luaL_checkstring(L, i + 1);
|
||||||
keylist.push_back(k);
|
if (!Keyboard::getConstant(name, k))
|
||||||
|
return luaL_error(L, "Invalid key constant: %s", name);
|
||||||
|
|
||||||
|
keylist.push_back(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,8 +98,12 @@ int w_isScancodeDown(lua_State *L)
|
|||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
lua_rawgeti(L, 1, i + 1);
|
lua_rawgeti(L, 1, i + 1);
|
||||||
if (Keyboard::getConstant(luaL_checkstring(L, -1), scancode))
|
|
||||||
scancodelist.push_back(scancode);
|
const char *name = luaL_checkstring(L, -1);
|
||||||
|
if (!Keyboard::getConstant(name, scancode))
|
||||||
|
return luaL_error(L, "Invalid scancode: %s", name);
|
||||||
|
|
||||||
|
scancodelist.push_back(scancode);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,8 +111,11 @@ int w_isScancodeDown(lua_State *L)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
if (Keyboard::getConstant(luaL_checkstring(L, i+1), scancode))
|
const char *name = luaL_checkstring(L, i + 1);
|
||||||
scancodelist.push_back(scancode);
|
if (!Keyboard::getConstant(name, scancode))
|
||||||
|
return luaL_error(L, "Invalid scancode: %s", name);
|
||||||
|
|
||||||
|
scancodelist.push_back(scancode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user