Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Pardaleco
Prole
Posts: 10
Joined: Mon Dec 31, 2018 7:12 pm

I am having an issue while trying to use 2 gamepads for my local multiplayer game (2 players).

Only 1 controller works fine, everything works as it should, but when I connect my 2nd controller it just doesn't work. It is recognized and it is a gamepad but none of its inputs work.

Am I doing something wrong with the assignment of its index? below I show some simple code that I was using to test it.

Thank you!

Code: Select all

function love.load()
joysticks = love.joystick.getJoysticks()
joystick1 = joysticks[1]
joystick2 = joysticks[2]

position = {x = 400, y = 300}
speed = 300

end

function love.update(dt)
if not joystick1 then return end

position.x = position.x - speed * dt
position.x = position.x + speed * dt
end

position.y = position.y - speed * dt
position.y = position.y + speed * dt
end
end

function love.draw()
love.graphics.circle("fill", position.x, position.y, 50)
love.graphics.print(tostring(directionx), 100,100)
love.graphics.print(tostring(directiony), 100,150)
end<e>

raidho36
Party member
Posts: 1943
Joined: Mon Jun 17, 2013 12:00 pm

That's probably because your gamepad "1" appears as 2nd when two of them are connected.

Pardaleco
Prole
Posts: 10
Joined: Mon Dec 31, 2018 7:12 pm

raidho36 wrote:
Thu Nov 28, 2019 11:08 pm
That's probably because your gamepad "1" appears as 2nd when two of them are connected.
How would I fix that?

raidho36
Party member
Posts: 1943
Joined: Mon Jun 17, 2013 12:00 pm

Pardaleco wrote:
Fri Nov 29, 2019 4:57 am
How would I fix that?
You don't. You can work around it, however. For example, your input settings manager can remember exactly which controller the bindings belong to (by GUID or by USB VID/PID values) so it would pick up that specific controller. Or you can prompt user to specify which controller should control what object. If all else fails, you can simply detect which controller generates input events and set that to primary controller, etc.

Felix_Maxwell
Prole
Posts: 1
Joined: Wed Dec 04, 2019 3:15 pm