mirror of
https://github.com/love2d/love.git
synced 2026-08-19 12:14:20 +02:00
Added love.joystick.loadGamepadMappings (resolves issue #842), and Joystick:saveGamepadMapping.
The latter returns a mapping string, and the former loads a newline-separated list of mapping strings.
This commit is contained in:
@@ -191,12 +191,14 @@ bool Joystick::isDown(const std::vector<int> &buttonlist) const
|
||||
if (!isConnected())
|
||||
return false;
|
||||
|
||||
int num = getButtonCount();
|
||||
int numbuttons = getButtonCount();
|
||||
|
||||
for (size_t i = 0; i < buttonlist.size(); i++)
|
||||
for (int button : buttonlist)
|
||||
{
|
||||
int button = buttonlist[i];
|
||||
if (button >= 0 && button < num && SDL_JoystickGetButton(joyhandle, button) == 1)
|
||||
if (button < 0 || button >= numbuttons)
|
||||
continue;
|
||||
|
||||
if (SDL_JoystickGetButton(joyhandle, button) == 1)
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -244,9 +246,9 @@ bool Joystick::isGamepadDown(const std::vector<GamepadButton> &blist) const
|
||||
|
||||
SDL_GameControllerButton sdlbutton;
|
||||
|
||||
for (size_t i = 0; i < blist.size(); i++)
|
||||
for (GamepadButton button : blist)
|
||||
{
|
||||
if (!getConstant(blist[i], sdlbutton))
|
||||
if (!getConstant(button, sdlbutton))
|
||||
continue;
|
||||
|
||||
if (SDL_GameControllerGetButton(controller, sdlbutton) == 1)
|
||||
|
||||
Reference in New Issue
Block a user