From db941f6b371774b7b9f5de0e8db86a9b4f5a1d7b Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 24 Aug 2016 01:25:07 +0200 Subject: get sets --- controller.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'controller.lua') diff --git a/controller.lua b/controller.lua index 513af45..5ed7dd2 100644 --- a/controller.lua +++ b/controller.lua @@ -29,6 +29,11 @@ function Controller.registerSet(left, right, up, down, attack, jump, joystick) return set end +-- Get table of controls sets. +function Controller.getSets() + return Controller.sets +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 -- cgit v1.1 From b739e555026471db11e24cb4a92f55509e717761 Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 24 Aug 2016 06:43:11 +0200 Subject: Unique joysticks for sets --- controller.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'controller.lua') 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 -- cgit v1.1 From 92c040a9c0104623b19f8f5d6590a260190b4492 Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 30 Sep 2016 16:35:05 +0200 Subject: Added Settings module scrap --- controller.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'controller.lua') diff --git a/controller.lua b/controller.lua index fde63c1..b56bd32 100644 --- a/controller.lua +++ b/controller.lua @@ -160,8 +160,6 @@ end -- Load gamepad mappings from db file and init module function Controller.load() love.joystick.loadGamepadMappings("gamecontrollerdb.txt") - Controller.registerSet("left", "right", "up", "down", "return", "rshift") - Controller.registerSet("a", "d", "w", "s", "g", "h") end -- Create new sets when new joystick is added -- cgit v1.1 From 7e567d1fc37d8e65e4e8fe5c7ece2cea8a6567b1 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 10 Oct 2016 22:33:34 +0200 Subject: Load controller sets from file --- controller.lua | 5 ----- 1 file changed, 5 deletions(-) (limited to 'controller.lua') diff --git a/controller.lua b/controller.lua index b56bd32..e435d63 100644 --- a/controller.lua +++ b/controller.lua @@ -162,11 +162,6 @@ function Controller.load() love.joystick.loadGamepadMappings("gamecontrollerdb.txt") end --- Create new sets when new joystick is added -function Controller.joystickadded(joystick) - Controller.registerSet("axis:leftx-", "axis:leftx+", "axis:lefty-", "axis:lefty+", "a", "b", joystick) -end - -- Gamepad input callbacks function Controller.gamepadaxis(joystick, axis, value) if value ~= 0 then -- cgit v1.1