From 0875a87e26578c53868e94bcfab442f2e3ff392e Mon Sep 17 00:00:00 2001 From: Jan Date: Sun, 22 Aug 2021 16:18:43 +0200 Subject: [PATCH] Add commands for applying gamepad stick and button configurations --- src/Components/Modules/Gamepad.cpp | 14 ++++++++++++++ src/Components/Modules/Gamepad.hpp | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/Components/Modules/Gamepad.cpp b/src/Components/Modules/Gamepad.cpp index f59beeb8..1db9dd4e 100644 --- a/src/Components/Modules/Gamepad.cpp +++ b/src/Components/Modules/Gamepad.cpp @@ -1265,6 +1265,18 @@ namespace Components } } + void Gamepad::Bind_GP_SticksConfigs_f(Command::Params* params) + { + const auto* stickConfigName = gpad_sticksConfig.get(); + Game::Cbuf_AddText(0, Utils::String::VA("exec %s\n", stickConfigName)); + } + + void Gamepad::Bind_GP_ButtonsConfigs_f(Command::Params* params) + { + const auto* buttonConfigName = gpad_buttonConfig.get(); + Game::Cbuf_AddText(0, Utils::String::VA("exec %s\n", buttonConfigName)); + } + void Gamepad::InitDvars() { gpad_enabled = Dvar::Register("gpad_enabled", false, Game::DVAR_FLAG_SAVED, "Game pad enabled"); @@ -1333,6 +1345,8 @@ namespace Components Command::Add("bindaxis", Axis_Bind_f); Command::Add("unbindallaxis", Axis_Unbindall_f); + Command::Add("bindgpsticksconfigs", Bind_GP_SticksConfigs_f); + Command::Add("bindgpbuttonsconfigs", Bind_GP_ButtonsConfigs_f); if (Dedicated::IsEnabled()) return; diff --git a/src/Components/Modules/Gamepad.hpp b/src/Components/Modules/Gamepad.hpp index d0985139..ca133b7d 100644 --- a/src/Components/Modules/Gamepad.hpp +++ b/src/Components/Modules/Gamepad.hpp @@ -265,6 +265,8 @@ namespace Components static Game::GamepadMapping StringToGamePadMapping(const char* str); static void Axis_Bind_f(Command::Params* params); static void Axis_Unbindall_f(Command::Params* params); + static void Bind_GP_SticksConfigs_f(Command::Params* params); + static void Bind_GP_ButtonsConfigs_f(Command::Params* params); static void InitDvars(); static void IN_Init_Hk();