diff options
-rw-r--r-- | controller.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/controller.lua b/controller.lua index 5ed7dd2..fde63c1 100644 --- a/controller.lua +++ b/controller.lua @@ -16,6 +16,7 @@ function Controller.controlreleased(set, action, key) end -- Create new controls set. function Controller.registerSet(left, right, up, down, attack, jump, joystick) + if not Controller.isJoystickUnique(joystick) then return end local set = {} set.left = left or "left" set.right = right or "right" @@ -34,6 +35,16 @@ function Controller.getSets() return Controller.sets end +-- Checks if given joystick is unique in current set of Controller sets +function Controller.isJoystickUnique(joystick) + if joystick ~= nil then + for _,set in pairs(Controller.sets) do + if set.joystick == joystick then return false end + end + end + return true +end + -- Tests all sets if they have control assigned to given key and joystick. function Controller.testSets(key, joystick) for i,set in pairs(Controller.sets) do |