xboxlove - Xbox360 Controller module
Re: xboxlove - Xbox360 Controller module
nope this library doesn't work with 0.9.0 tried multiple times, it could also been made a bit more user friendly.
- slime
- Solid Snayke
- Posts: 3170
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: xboxlove - Xbox360 Controller module
You should use the new Gamepad functionality instead, if you use 0.9.0: [wiki]Joystick:isGamepad[/wiki], [wiki]Joystick:getGamepadAxis[/wiki], [wiki]Joystick:isGamepadDown[/wiki], [wiki]love.gamepadpressed[/wiki], etc.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: xboxlove - Xbox360 Controller module
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?
Maybe a little help with that stuff?
Re: xboxlove - Xbox360 Controller module
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?
The logic of these kinds of modules is based around "actions", and mapping certain actions to different keyboard / gamepad controls. It works in a way similar to this:
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
If you understand moonscript (it's Lua but with a few added / changed constructs, e.g. colons are used for tables instead of equal signs like in JavaScript), you can see the code I used for this logic in particular here: https://github.com/Kingdaro/fb-moonscri ... olmap.moon
You can also look into the two libraries I mentioned earlier, since I borrowed logic from both of them.
Re: xboxlove - Xbox360 Controller module
So I spent a few hours updating xboxlove to 0.9, I have tested it on windows 7 and mac osx and everything seems to be working (don't take my word on it).
You can download it here : https://github.com/hazagame/xboxlove
You need to pass the joystick object you get from love.joystick.getJoysticks(), if you pass nil or not a joystick object or you already passed that joystick it will return nil (change it for how you want it to work). Other than that it functions the same as original. Added xboxlove.connected to check if the controller is connected and getJoystick() returns the joystick object.
Why update when 0.9 has much better joystick controls, well I didn't like the fact you still needed the codes so this is still useful.
You can download it here : https://github.com/hazagame/xboxlove
You need to pass the joystick object you get from love.joystick.getJoysticks(), if you pass nil or not a joystick object or you already passed that joystick it will return nil (change it for how you want it to work). Other than that it functions the same as original. Added xboxlove.connected to check if the controller is connected and getJoystick() returns the joystick object.
Why update when 0.9 has much better joystick controls, well I didn't like the fact you still needed the codes so this is still useful.
Who is online
Users browsing this forum: No registered users and 3 guests