Add LinuxInputJoysticks parameter to Preferences.ini to ensure pad order consistency

This commit is contained in:
Sergio Pérez Fernández
2024-02-21 12:29:26 -08:00
committed by teejusb
parent acf8be530d
commit 5753ecdc1c
3 changed files with 18 additions and 3 deletions
+1
View File
@@ -12,6 +12,7 @@
RageInput* INPUTMAN = nullptr; // global and accessible from anywhere in our program
Preference<RString> g_sInputDrivers( "InputDrivers", "" ); // "" == DEFAULT_INPUT_DRIVER_LIST
Preference<RString> g_sInputLinuxJoysticks( "InputLinuxJoysticks", "" ); // "" == DEFAULT_LINUX_INPUT_JOYSTICK_LIST
namespace
{
+1
View File
@@ -36,6 +36,7 @@ public:
};
extern Preference<RString> g_sInputDrivers;
extern Preference<RString> g_sInputLinuxJoysticks;
extern RageInput* INPUTMAN; // global and accessible from anywhere in our program
+16 -3
View File
@@ -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 <string> // std::string::npos
#include <vector>
#if defined(HAVE_DIRENT_H)
#include <dirent.h>
@@ -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<RString> 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