mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
fixed not being able to remap gamepads by resolving problem with re-initializing joysticks as gamepads
This commit is contained in:
@@ -356,7 +356,7 @@ void JoystickModule::checkGamepads(const std::string &guid) const
|
||||
|
||||
for (auto stick : activeSticks)
|
||||
{
|
||||
if (stick->isGamepad() || guid.compare(stick->getGUID()) != 0)
|
||||
if (guid.compare(stick->getGUID()) != 0)
|
||||
continue;
|
||||
|
||||
// Big hack time: open the index as a game controller and compare
|
||||
@@ -365,12 +365,15 @@ void JoystickModule::checkGamepads(const std::string &guid) const
|
||||
if (controller == nullptr)
|
||||
continue;
|
||||
|
||||
// GameController objects are reference-counted in SDL, so we don't want to
|
||||
// have a joystick open when trying to re-initialize it
|
||||
SDL_Joystick *sdlstick = SDL_GameControllerGetJoystick(controller);
|
||||
if (sdlstick == (SDL_Joystick *) stick->getHandle())
|
||||
stick->openGamepad(d_index);
|
||||
|
||||
// GameController objects are reference-counted in SDL.
|
||||
bool open_gamepad = (sdlstick == (SDL_Joystick *) stick->getHandle());
|
||||
SDL_GameControllerClose(controller);
|
||||
|
||||
// open as gamepad if necessary
|
||||
if (open_gamepad)
|
||||
stick->openGamepad(d_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user