From 49c6cd2edf399313f2204530ce4285299a9b6858 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 14 Aug 2016 22:41:13 +0200 Subject: Controller callbacks --- controller.lua | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) (limited to 'controller.lua') diff --git a/controller.lua b/controller.lua index 88751a2..971b83b 100644 --- a/controller.lua +++ b/controller.lua @@ -70,37 +70,23 @@ end -- Gamepad input callbacks function Controller.gamepadpressed(joystick, button) print(button, "pressed") - for _,controller in pairs(Controllers) do - controller:gamepadpressed(joystick, button) - end + local set, action, key = Controller.testSets(button, joystick) + Controller.controlpressed(set, action, key) end function Controller.gamepadreleased(joystick, button) print(button, "released") - for _,controller in pairs(Controllers) do - controller:gamepadreleased(joystick, button) - end + local set, action, key = Controller.testSets(button, joystick) + Controller.controlreleased(set, action, key) end -- Keyboard input callbacks -function Controller.keypressed(key) - print(key, "pressed") - for _,controller in pairs(Controllers) do - controller:keypressed(key) - end - - if key == "f6" and debug then - local map = Scene:getMapName() - local nauts = {} - for _,naut in pairs(Scene:getNautsAll()) do - table.insert(nauts, {naut.name, naut.controller}) - end - local new = World:new(map, nauts) - changeScene(new) - end +function Controller.keypressed(button) + print(button, "pressed") + local set, action, key = Controller.testSets(button) + Controller.controlpressed(set, action, key) end -function Controller.keyreleased(key) - print(key, "released") - for _,controller in pairs(Controllers) do - controller:keyreleased(key) - end +function Controller.keyreleased(button) + print(button, "released") + local set, action, key = Controller.testSets(button) + Controller.controlreleased(set, action, key) end \ No newline at end of file -- cgit v1.1