From 541dc1e38cfd0b7142db8d4c285ed72e3bc25035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erkki=20Sepp=C3=A4l=C3=A4?= Date: Fri, 24 Oct 2014 09:53:28 +0300 Subject: [PATCH] Each player can only bind buttons from their own joystick --- menu_state.lua | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/menu_state.lua b/menu_state.lua index a6360e4..1c2a3ae 100644 --- a/menu_state.lua +++ b/menu_state.lua @@ -92,23 +92,16 @@ 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 - for i = 1, #buttons, 1 do - if buttons[i] then - button = i + 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