mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
Error for invalid constants passed to love.keyboard.isDown/isScancodeDown. Resolves issue #1313.
--HG-- branch : minor
This commit is contained in:
@@ -58,7 +58,11 @@ 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))
|
|
||||||
|
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);
|
keylist.push_back(k);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
@@ -67,7 +71,10 @@ 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);
|
||||||
|
if (!Keyboard::getConstant(name, k))
|
||||||
|
return luaL_error(L, "Invalid key constant: %s", name);
|
||||||
|
|
||||||
keylist.push_back(k);
|
keylist.push_back(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,7 +98,11 @@ 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))
|
|
||||||
|
const char *name = luaL_checkstring(L, -1);
|
||||||
|
if (!Keyboard::getConstant(name, scancode))
|
||||||
|
return luaL_error(L, "Invalid scancode: %s", name);
|
||||||
|
|
||||||
scancodelist.push_back(scancode);
|
scancodelist.push_back(scancode);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
@@ -100,7 +111,10 @@ 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);
|
||||||
|
if (!Keyboard::getConstant(name, scancode))
|
||||||
|
return luaL_error(L, "Invalid scancode: %s", name);
|
||||||
|
|
||||||
scancodelist.push_back(scancode);
|
scancodelist.push_back(scancode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user