diff --git a/src/arch/InputHandler/InputHandler_Linux_Event.cpp b/src/arch/InputHandler/InputHandler_Linux_Event.cpp index dfc44dedbc..3085a2ceaa 100644 --- a/src/arch/InputHandler/InputHandler_Linux_Event.cpp +++ b/src/arch/InputHandler/InputHandler_Linux_Event.cpp @@ -69,19 +69,6 @@ struct EventDevice static vector g_apEventDevices; -/* Return true if the numbered event device exists. sysfs may not always be - * there; return false if we don't know. */ -static bool EventDeviceExists( int iNum ) -{ - RString sDir = ssprintf( "/sys/class" ); - struct stat st; - if( stat(sDir, &st) == -1 ) - return true; - - RString sFile = ssprintf( "/sys/class/input/event%i", iNum ); - return stat(sFile, &st) == 0; -} - static bool BitIsSet( const uint8_t *pArray, uint32_t iBit ) { return !!(pArray[iBit/8] & (1<<(iBit%8))); diff --git a/src/arch/InputHandler/LinuxInputManager.cpp b/src/arch/InputHandler/LinuxInputManager.cpp index 7162a5475d..2981eccd53 100644 --- a/src/arch/InputHandler/LinuxInputManager.cpp +++ b/src/arch/InputHandler/LinuxInputManager.cpp @@ -33,6 +33,11 @@ RString getDevice(RString inputDir, RString type) return result; } +static bool cmpDevices(RString a, RString b) +{ + return a < b; +} + LinuxInputManager::LinuxInputManager() { m_bEventEnabled = g_sInputDrivers.Get().find("LinuxEvent") != std::string::npos; @@ -71,6 +76,10 @@ LinuxInputManager::LinuxInputManager() if( !bEventPresent && !bJoystickPresent ) LOG->Info("LinuxInputManager: %s seems to have no eventNN or jsNN.", dName.c_str() ); } + + // Sort devices for more consistent numbering. + std::sort(m_vsPendingEventDevices.begin(), m_vsPendingEventDevices.end(), cmpDevices); + std::sort(m_vsPendingJoystickDevices.begin(), m_vsPendingJoystickDevices.end(), cmpDevices); } void LinuxInputManager::InitDriver(InputHandler_Linux_Event* driver)