summaryrefslogtreecommitdiffhomepage
path: root/controller.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-08-14 22:41:13 +0200
committerAki <nthirtyone@gmail.com>2016-08-14 22:41:13 +0200
commit49c6cd2edf399313f2204530ce4285299a9b6858 (patch)
treeafe62f1543e98f4273d2bb6045bc27d46acf1636 /controller.lua
parent3038bd171700d91e56a4050943925a02f5b1eda6 (diff)
downloadroflnauts-49c6cd2edf399313f2204530ce4285299a9b6858.zip
roflnauts-49c6cd2edf399313f2204530ce4285299a9b6858.tar.gz
roflnauts-49c6cd2edf399313f2204530ce4285299a9b6858.tar.bz2
Controller callbacks
Diffstat (limited to 'controller.lua')
-rw-r--r--controller.lua38
1 files changed, 12 insertions, 26 deletions
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