summaryrefslogtreecommitdiffhomepage
path: root/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/main.lua b/main.lua
index 8e2a964..c728606 100644
--- a/main.lua
+++ b/main.lua
@@ -44,6 +44,27 @@ function love.load ()
changeScene(m)
end
+-- Gamepad
+function love.joystickadded(joystick)
+ love.joystick.loadGamepadMappings("gamecontrollerdb.txt")
+ table.insert(Controllers, Controller:new(joystick, "dpleft", "dpright", "dpup", "dpdown", "a", "b"))
+ m:assignController(Controllers[#Controllers])
+end
+
+function love.gamepadpressed(joystick, button)
+ print(button, "pressed")
+ for _,controller in pairs(Controllers) do
+ controller:gamepadpressed(joystick, button)
+ end
+end
+
+function love.gamepadreleased(joystick, button)
+ print(button, "released")
+ for _,controller in pairs(Controllers) do
+ controller:gamepadreleased(joystick, button)
+ end
+end
+
-- Update
function love.update (dt)
Scene:update(dt)