Re: xboxlove - Xbox360 Controller module
Posted: Mon Dec 16, 2013 6:33 pm
nope this library doesn't work with 0.9.0 tried multiple times, it could also been made a bit more user friendly.
There are actually libraries available (specifically TLBind and Common Organization of Controls Kit) that do just that, and I've written my own for a project I have using logic from both of these. (I'm not releasing it since it was made specifically for moonscript, and only has all of the features I actually need in said project.)Jasoco wrote:I couldn't figure out how to get it to work right. There's way too many buttons and sticks, I just wanted some easy to use library where I can say "if my left stick's X axis is < 0" or "if my A button is pressed" or "if the right trigger is > 0.5 pressed in" in the same way I say "if my F key is pressed" or "when my spacebar is down" or "when I release the right mouse button".
Maybe a little help with that stuff?
Code: Select all
local controls = some.func(returning(a_control "bind").object)
function love.load()
controls:bind("left", { key = "left" }, { joyAxis = 1, -1 }, { gamepadAxis = "leftx", -1 })
controls:bind("right", { key = "right"}, { joyAxis = 1, 1}, { gamepadAxis = "leftx", 1 })
controls:bind("jump", { key = " " }, { joyButton = 1 }, { gamepadButton = "a" })
end
function love.update(dt)
controls:update(dt) -- usually doesn't require dt, since it's a bunch of state checks
if controls.held.left then
movePlayerLeft()
end
if controls.held.right then
movePlayerRight()
end
if controls.pressed.jump then
playerJump()
end
end