diff options
author | Aki <nthirtyone@gmail.com> | 2016-08-15 20:32:15 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2016-08-15 20:32:15 +0200 |
commit | 37fa93429a841c78fde4510250bd47bb6da9727e (patch) | |
tree | d629cb393dac1aef5dbf8e46ee8ba0f1bc95013a | |
parent | 368a26395c906775441e6a5302491f60172c2920 (diff) | |
download | roflnauts-37fa93429a841c78fde4510250bd47bb6da9727e.zip roflnauts-37fa93429a841c78fde4510250bd47bb6da9727e.tar.gz roflnauts-37fa93429a841c78fde4510250bd47bb6da9727e.tar.bz2 |
Controller module additional callbacks
-rw-r--r-- | controller.lua | 10 | ||||
-rw-r--r-- | main.lua | 5 |
2 files changed, 12 insertions, 3 deletions
diff --git a/controller.lua b/controller.lua index b642bd9..a3f04f2 100644 --- a/controller.lua +++ b/controller.lua @@ -70,12 +70,22 @@ function Controller.isDown(set, action) end -- Callbacks from LÖVE2D +-- 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 function Controller.joystickadded(joystick) Controller.registerSet("dpleft", "dpright", "dpup", "dpdown", "a", "b", joystick) end -- Gamepad input callbacks +function Controller.gamepadaxis(joystick, axis, value) + print(joystick, axis, value) +end function Controller.gamepadpressed(joystick, key) local set, action = Controller.testSets(key, joystick) print(joystick, set, action, key) @@ -55,9 +55,7 @@ function love.load() Font:setLineHeight(9/16) love.graphics.setFont(Font) -- Controller - love.joystick.loadGamepadMappings("gamecontrollerdb.txt") - Controller.registerSet("left", "right", "up", "down", "return", "rshift") - Controller.registerSet("a", "d", "w", "s", "g", "h") + Controller.load() -- Scene Scene = Menu:new() end @@ -78,6 +76,7 @@ function love.draw() end -- Pass input to Controller function love.joystickadded(joystick) Controller.joystickadded(joystick) end +function love.gamepadaxis(joystick, axis, value) Controller.gamepadaxis(joystick, axis, value) end function love.gamepadpressed(joystick, key) Controller.gamepadpressed(joystick, key) end function love.gamepadreleased(joystick, key) Controller.gamepadreleased(joystick, key) end function love.keypressed(key) Controller.keypressed(key) end |