[TLAC] Backport wireframe and extra keyboard bindings

This commit is contained in:
nastys
2022-05-07 18:28:42 +02:00
parent 1c026e2661
commit 25a2a5f6f6
7 changed files with 43 additions and 6 deletions
@@ -83,6 +83,7 @@ namespace TLAC::Components
CoinBinding = new Binding();
ToonBinding = new Binding();
WireframeBinding = new Binding();
FileSystem::ConfigFile configFile(framework::GetModuleDirectory(), KEY_CONFIG_FILE_NAME);
configFile.OpenRead();
@@ -103,6 +104,7 @@ namespace TLAC::Components
Config::BindConfigKeys(configFile.ConfigMap, "MENU_CIRCLE", *MenuCircleBinding, { "D", "L", "Spacebar" });
Config::BindConfigKeys(configFile.ConfigMap, "TOON", *ToonBinding, { "F9" });
Config::BindConfigKeys(configFile.ConfigMap, "COIN", *CoinBinding, { "F10" });
Config::BindConfigKeys(configFile.ConfigMap, "WIREFRAME", *WireframeBinding, { "Backspace" });
mouseScrollPvSelection = configFile.GetBooleanValue("mouse_scroll_pv_selection");
}
@@ -176,6 +178,9 @@ namespace TLAC::Components
if (ToonBinding->AnyTapped())
toggleNpr1();
if (WireframeBinding->AnyTapped())
toggleWireframe();
}
HoldState InputEmulator::GetHoldState()
@@ -467,4 +472,28 @@ namespace TLAC::Components
printf("[TLAC] NPR1 restored\n");
}
}
void InputEmulator::toggleWireframe()
{
static bool wireframeEnabled = false;
if (!wireframeEnabled)
{
// inject samyuu's wireframe code
InjectCode((void*)0x00000000140500BE6, { 0xBA, 0x01, 0x1B, 0x00, 0x00, // mov edx,00001B01
0xB9, 0x08, 0x04, 0x00, 0x00, // mov ecx,00000408
0xE8, 0xE1, 0x5A, 0x3B, 0x00, // call 1408B66D6
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 });
wireframeEnabled = true;
printf("[TLAC] Wireframe enabled\n");
}
else
{
InjectCode((void*)0x00000000140500BE6, { 0xB9, 0x1C, 0x00, 0x00, 0x00, 0xE8, 0x30, 0x7C, 0xF3, 0xFF, 0xB9, 0x1B, 0x00, 0x00, 0x00, 0x8B, 0xD8, 0xE8, 0x24, 0x7C, 0xF3, 0xFF, 0xB9, 0x1A, 0x00, 0x00, 0x00 });
wireframeEnabled = false;
printf("[TLAC] Wireframe disabled\n");
}
}
}
@@ -40,6 +40,7 @@ namespace TLAC::Components
Input::Binding* CoinBinding;
Input::Binding* ToonBinding;
Input::Binding* WireframeBinding;
InputEmulator();
~InputEmulator();
@@ -112,5 +113,6 @@ namespace TLAC::Components
void addCoin();
void toggleNpr1();
void toggleWireframe();
};
}
@@ -26,9 +26,6 @@ namespace TLAC::Input::KeyConfig
{ "Minus", VK_SUBTRACT },
{ "Divide", VK_DIVIDE },
{ "Multiply", VK_MULTIPLY },
{ "Comma", VK_OEM_COMMA },
{ "Period", VK_OEM_PERIOD },
{ "Slash", VK_OEM_2 },
// F-Keys
{ "F1", VK_F1 },
{ "F2", VK_F2 },
@@ -91,7 +88,14 @@ namespace TLAC::Input::KeyConfig
{ "Escape", VK_ESCAPE },
{ "Comma", VK_OEM_COMMA },
{ "Period", VK_OEM_PERIOD },
{ "Colon", VK_OEM_1 },
{ "Slash", VK_OEM_2 },
{ "Tilde", VK_OEM_3 },
{ "LeftBracket", VK_OEM_4 },
{ "Backslash", VK_OEM_5 },
{ "RightBracket", VK_OEM_6 },
{ "SingleDoubleQuote", VK_OEM_7 },
{ "OEM_8", VK_OEM_8 },
// Mouse buttons
{ "MouseLeft", VK_LBUTTON },
{ "MouseMiddle", VK_MBUTTON },