Skip to content

Commit 317879e

Browse files
committed
add inputmapper getbuttonmapping alternative
the original now returns a string which is compatible with DeviceInput.FromString and the new one returns what the old one returns, which is a normal human readable string
1 parent 43ca6aa commit 317879e

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/Etterna/Singletons/InputMapper.cpp

+24-1
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,29 @@ class LunaInputMapper : public Luna<InputMapper>
15301530
DeviceInput deviceI;
15311531

15321532
if (p->GameToDevice(gameI, bindingColumn, deviceI))
1533-
lua_pushstring(L, INPUTMAN->GetDeviceSpecificInputString(deviceI).c_str());
1533+
lua_pushstring(L, deviceI.ToString().c_str());
1534+
else
1535+
lua_pushnil(L);
1536+
return 1;
1537+
}
1538+
static int GetButtonMappingString(T* p, lua_State* L)
1539+
{
1540+
// similar to GetButtonMapping except gets the string a user can read
1541+
std::string possiblyMappedGameButton = SArg(1);
1542+
int playerSlot = IArg(2);
1543+
CLAMP(playerSlot, 0, 1);
1544+
int bindingColumn = IArg(3);
1545+
CLAMP(bindingColumn, 0, 4);
1546+
1547+
GameController gc = static_cast<GameController>(playerSlot);
1548+
GameButton gb =
1549+
StringToGameButton(p->GetInputScheme(), possiblyMappedGameButton);
1550+
GameInput gameI(gc, gb);
1551+
DeviceInput deviceI;
1552+
1553+
if (p->GameToDevice(gameI, bindingColumn, deviceI))
1554+
lua_pushstring(
1555+
L, INPUTMAN->GetDeviceSpecificInputString(deviceI).c_str());
15341556
else
15351557
lua_pushnil(L);
15361558
return 1;
@@ -1553,6 +1575,7 @@ class LunaInputMapper : public Luna<InputMapper>
15531575
ADD_METHOD(GetGameButtonsToMap);
15541576
ADD_METHOD(GetMenuButtonsToMap);
15551577
ADD_METHOD(GetButtonMapping);
1578+
ADD_METHOD(GetButtonMappingString);
15561579
ADD_METHOD(SaveMappingsToDisk);
15571580
ADD_METHOD(ReadMappingsFromDisk);
15581581
}

0 commit comments

Comments
 (0)