diff --git a/src/Components/Modules/Gamepad.cpp b/src/Components/Modules/Gamepad.cpp index ab161b80..39529bcc 100644 --- a/src/Components/Modules/Gamepad.cpp +++ b/src/Components/Modules/Gamepad.cpp @@ -146,6 +146,7 @@ namespace Components Dvar::Var Gamepad::gpad_enabled; Dvar::Var Gamepad::gpad_debug; Dvar::Var Gamepad::gpad_present; + Dvar::Var Gamepad::gpad_in_use; Dvar::Var Gamepad::gpad_sticksConfig; Dvar::Var Gamepad::gpad_buttonConfig; Dvar::Var Gamepad::gpad_menu_scroll_delay_first; @@ -675,7 +676,10 @@ namespace Components CL_GamepadGenerateAPad(gamePadIndex, physicalAxis, time); if (std::fabs(value) > 0.0f) + { gamePad.inUse = true; + gpad_in_use.setRaw(true); + } } void Gamepad::UI_GamepadKeyEvent(const int gamePadIndex, const int key, const bool down) @@ -824,6 +828,7 @@ namespace Components auto& gamePad = gamePads[gamePadIndex]; gamePad.inUse = true; + gpad_in_use.setRaw(true); if (Game::Key_IsKeyCatcherActive(gamePadIndex, Game::KEYCATCH_UI)) CL_GamepadResetMenuScrollTime(gamePadIndex, key, buttonEvent == Game::GPAD_BUTTON_PRESSED, time); @@ -1323,6 +1328,7 @@ namespace Components gpad_enabled = Dvar::Register("gpad_enabled", false, Game::DVAR_FLAG_SAVED, "Game pad enabled"); gpad_debug = Dvar::Register("gpad_debug", false, 0, "Game pad debugging"); gpad_present = Dvar::Register("gpad_present", false, 0, "Game pad present"); + gpad_in_use = Dvar::Register("gpad_in_use", false, 0, "A game pad is in use"); gpad_sticksConfig = Dvar::Register("gpad_sticksConfig", "thumbstick_default", Game::DVAR_FLAG_SAVED, "Game pad stick configuration"); gpad_buttonConfig = Dvar::Register("gpad_buttonConfig", "buttons_default", Game::DVAR_FLAG_SAVED, "Game pad button configuration"); gpad_menu_scroll_delay_first = Dvar::Register("gpad_menu_scroll_delay_first", 420, 0, 1000, Game::DVAR_FLAG_SAVED, "Menu scroll key-repeat delay, for the first repeat, in milliseconds"); @@ -1391,6 +1397,7 @@ namespace Components { // A keyboard key has been pressed. Mark controller as unused. gamePads[0].inUse = false; + gpad_in_use.setRaw(false); // Call original function Utils::Hook::Call(0x4F6480)(localClientNum, key, down, time); diff --git a/src/Components/Modules/Gamepad.hpp b/src/Components/Modules/Gamepad.hpp index a5143220..95e8d0ea 100644 --- a/src/Components/Modules/Gamepad.hpp +++ b/src/Components/Modules/Gamepad.hpp @@ -187,6 +187,7 @@ namespace Components static Dvar::Var gpad_enabled; static Dvar::Var gpad_debug; static Dvar::Var gpad_present; + static Dvar::Var gpad_in_use; static Dvar::Var gpad_sticksConfig; static Dvar::Var gpad_buttonConfig; static Dvar::Var gpad_menu_scroll_delay_first;