From 5753ecdc1c365756f7fdf62898d0c505089880c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20P=C3=A9rez=20Fern=C3=A1ndez?= Date: Sat, 28 Oct 2023 02:39:36 +0100 Subject: [PATCH] Add LinuxInputJoysticks parameter to Preferences.ini to ensure pad order consistency --- src/RageInput.cpp | 1 + src/RageInput.h | 1 + src/arch/InputHandler/LinuxInputManager.cpp | 19 ++++++++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/RageInput.cpp b/src/RageInput.cpp index 7d5c3fb7e7..b63681449e 100644 --- a/src/RageInput.cpp +++ b/src/RageInput.cpp @@ -12,6 +12,7 @@ RageInput* INPUTMAN = nullptr; // global and accessible from anywhere in our program Preference g_sInputDrivers( "InputDrivers", "" ); // "" == DEFAULT_INPUT_DRIVER_LIST +Preference g_sInputLinuxJoysticks( "InputLinuxJoysticks", "" ); // "" == DEFAULT_LINUX_INPUT_JOYSTICK_LIST namespace { diff --git a/src/RageInput.h b/src/RageInput.h index 36e2c5f698..fa5fbbcf1d 100644 --- a/src/RageInput.h +++ b/src/RageInput.h @@ -36,6 +36,7 @@ public: }; extern Preference g_sInputDrivers; +extern Preference g_sInputLinuxJoysticks; extern RageInput* INPUTMAN; // global and accessible from anywhere in our program diff --git a/src/arch/InputHandler/LinuxInputManager.cpp b/src/arch/InputHandler/LinuxInputManager.cpp index 3961687100..7e6a0d3c52 100644 --- a/src/arch/InputHandler/LinuxInputManager.cpp +++ b/src/arch/InputHandler/LinuxInputManager.cpp @@ -3,10 +3,11 @@ #include "InputHandler_Linux_Event.h" #include "InputHandler_Linux_Joystick.h" -#include "RageInput.h" // g_sInputDrivers +#include "RageInput.h" // g_sInputDrivers g_sInputLinuxJoysticks #include "RageLog.h" #include // std::string::npos +#include #if defined(HAVE_DIRENT_H) #include @@ -104,6 +105,11 @@ void LinuxInputManager::InitDriver(InputHandler_Linux_Event* driver) void LinuxInputManager::InitDriver(InputHandler_Linux_Joystick* driver) { m_JoystickDriver = driver; + // Discard all the joystick devices if they were assigned manually via + // LinuxInputJoysticks + if( g_sInputLinuxJoysticks.Get() != "" ) { + m_vsPendingJoystickDevices.clear(); + } for (RString &dev : m_vsPendingJoystickDevices) { @@ -112,8 +118,15 @@ void LinuxInputManager::InitDriver(InputHandler_Linux_Joystick* driver) driver->TryDevice(devFile); } - - m_vsPendingJoystickDevices.clear(); + + // If any, add the manually specified devices via LinuxInputJoysticks + std::vector fixedDevices; + split( g_sInputLinuxJoysticks, ",", fixedDevices, true ); + + for (RString dev : fixedDevices) { + RString devFile = dev; + driver->TryDevice(devFile); + } } LinuxInputManager* LINUXINPUT = nullptr; // global and accessible anywhere in our program