Skip to content

Commit d258bdc

Browse files
committed
MCP: improve controller tool
1 parent ebb9f61 commit d258bdc

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

platforms/shared/desktop/mcp/mcp_debug_adapter.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <sstream>
3232
#include <iomanip>
3333
#include <vector>
34+
#include <algorithm>
3435

3536
struct DisassemblerBookmark
3637
{
@@ -1515,20 +1516,22 @@ json DebugAdapter::ControllerButton(int player, const std::string& button, const
15151516
}
15161517
GG_Controllers controller = static_cast<GG_Controllers>(player - 1);
15171518

1518-
// Convert button string to GG_Keys enum
1519+
std::string button_lower = button;
1520+
std::transform(button_lower.begin(), button_lower.end(), button_lower.begin(), ::tolower);
1521+
15191522
GG_Keys key = GG_KEY_NONE;
1520-
if (button == "i") key = GG_KEY_I;
1521-
else if (button == "ii") key = GG_KEY_II;
1522-
else if (button == "select") key = GG_KEY_SELECT;
1523-
else if (button == "run") key = GG_KEY_RUN;
1524-
else if (button == "up") key = GG_KEY_UP;
1525-
else if (button == "right") key = GG_KEY_RIGHT;
1526-
else if (button == "down") key = GG_KEY_DOWN;
1527-
else if (button == "left") key = GG_KEY_LEFT;
1528-
else if (button == "iii") key = GG_KEY_III;
1529-
else if (button == "iv") key = GG_KEY_IV;
1530-
else if (button == "v") key = GG_KEY_V;
1531-
else if (button == "vi") key = GG_KEY_VI;
1523+
if (button_lower == "i") key = GG_KEY_I;
1524+
else if (button_lower == "ii") key = GG_KEY_II;
1525+
else if (button_lower == "select") key = GG_KEY_SELECT;
1526+
else if (button_lower == "run") key = GG_KEY_RUN;
1527+
else if (button_lower == "up") key = GG_KEY_UP;
1528+
else if (button_lower == "right") key = GG_KEY_RIGHT;
1529+
else if (button_lower == "down") key = GG_KEY_DOWN;
1530+
else if (button_lower == "left") key = GG_KEY_LEFT;
1531+
else if (button_lower == "iii") key = GG_KEY_III;
1532+
else if (button_lower == "iv") key = GG_KEY_IV;
1533+
else if (button_lower == "v") key = GG_KEY_V;
1534+
else if (button_lower == "vi") key = GG_KEY_VI;
15321535
else
15331536
{
15341537
result["error"] = "Invalid button name";

0 commit comments

Comments
 (0)