Each player can only bind buttons from their own joystick
This commit is contained in:
parent
2af0378bb7
commit
541dc1e38c
1 changed files with 8 additions and 15 deletions
|
@ -92,25 +92,18 @@ end
|
|||
function menu_state:update(dt)
|
||||
menuTime = menuTime + dt
|
||||
|
||||
local buttons
|
||||
for i, joystick in ipairs(love.joystick.getJoysticks()) do
|
||||
local jButtons = getJoystickButtons(joystick)
|
||||
if buttons == nil then
|
||||
buttons = jButtons
|
||||
else
|
||||
for j = 1, #buttons, 1 do
|
||||
buttons[j] = buttons[j] or jButtons[i]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if currentlyChosen ~= nil then
|
||||
local button = nil
|
||||
local joysticks = love.joystick.getJoysticks()
|
||||
if #joysticks >= currentlyChosen.data.player then
|
||||
local buttons = getJoystickButtons(joysticks[currentlyChosen.data.player])
|
||||
|
||||
for i = 1, #buttons, 1 do
|
||||
if buttons[i] then
|
||||
button = i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if button ~= nil then
|
||||
local key = string.format("button%d", button)
|
||||
|
|
Loading…
Reference in a new issue