mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
Improved resilience to buggy controller drivers which could previously crash the application
This commit is contained in:
parent
ebf8f53362
commit
ce171b2e17
|
@ -641,6 +641,16 @@ void InputManager::addControllerByDeviceIndex(Window* window, int deviceIndex)
|
|||
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joy), &guid[0], 64);
|
||||
guid.erase(guid.find('\0'));
|
||||
|
||||
if (guid.substr(0, 32) == "00000000000000000000000000000000") {
|
||||
// This can occur if there are SDL bugs or controller driver bugs.
|
||||
LOG(LogWarning)
|
||||
<< "Attempted to add an invalid controller entry with zero GUID, buggy drivers?";
|
||||
SDL_GameControllerClose(controller);
|
||||
mControllers.erase(mControllers.find(joyID));
|
||||
mJoysticks.erase(mJoysticks.find(joyID));
|
||||
return;
|
||||
}
|
||||
|
||||
mInputConfigs[joyID] =
|
||||
std::make_unique<InputConfig>(joyID, SDL_GameControllerName(mControllers[joyID]), guid);
|
||||
|
||||
|
|
Loading…
Reference in a new issue