Add Joystick:getGamepadMappingString and love.joystick.getGamepadMappingString(guid). Resolves issue #1371.

This commit is contained in:
Alex Szpakowski
2019-09-15 14:02:19 -03:00
parent 9ab2a94037
commit 33bc8aabfc
8 changed files with 90 additions and 11 deletions
@@ -160,6 +160,17 @@ int w_saveGamepadMappings(lua_State *L)
return 1;
}
int w_getGamepadMappingString(lua_State *L)
{
const char *guid = luaL_checkstring(L, 1);
std::string mapping = instance()->getGamepadMappingString(guid);
if (mapping.empty())
lua_pushnil(L);
else
luax_pushstring(L, mapping);
return 1;
}
// List of functions to wrap.
static const luaL_Reg functions[] =
{
@@ -168,6 +179,7 @@ static const luaL_Reg functions[] =
{ "setGamepadMapping", w_setGamepadMapping },
{ "loadGamepadMappings", w_loadGamepadMappings },
{ "saveGamepadMappings", w_saveGamepadMappings },
{ "getGamepadMappingString", w_getGamepadMappingString },
{ 0, 0 }
};