mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +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)
|
for (auto stick : activeSticks)
|
||||||
{
|
{
|
||||||
if (stick->isGamepad() || guid.compare(stick->getGUID()) != 0)
|
if (guid.compare(stick->getGUID()) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Big hack time: open the index as a game controller and compare
|
// 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)
|
if (controller == nullptr)
|
||||||
continue;
|
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);
|
SDL_Joystick *sdlstick = SDL_GameControllerGetJoystick(controller);
|
||||||
if (sdlstick == (SDL_Joystick *) stick->getHandle())
|
bool open_gamepad = (sdlstick == (SDL_Joystick *) stick->getHandle());
|
||||||
stick->openGamepad(d_index);
|
|
||||||
|
|
||||||
// GameController objects are reference-counted in SDL.
|
|
||||||
SDL_GameControllerClose(controller);
|
SDL_GameControllerClose(controller);
|
||||||
|
|
||||||
|
// open as gamepad if necessary
|
||||||
|
if (open_gamepad)
|
||||||
|
stick->openGamepad(d_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user