Hello,
So, xboxlove facilitates the implementation of the xbox360 controller, on Windows and OSX.
You will be able to access, via friendly named constants, the value of each sticks/triggers/buttons of the xbox360 controller.
Left Stick :
xboxlove.Axes.LeftX (>= -1 and <= 1)
xboxlove.Axes.LeftY (>= -1 and <= 1)
xboxlove.Axes.LeftAngle (> -pi and <= pi)
Right Stick :
xboxlove.Axes.RightX (>= -1 and <= 1)
xboxlove.Axes.RightY (>= -1 and <= 1)
xboxlove.Axes.LeftAngle (> -pi and <= pi)
Triggers : (On windows, you can't use both triggers at the same time)
xboxlove.Axes.Triggers (>= -1 and <= 1)
or
xboxlove.Axes.LeftTrigger (>= 0 and <= 1)
xboxlove.Axes.RightTrigger (>= 0 and <= 1)
Dpad : (booleans except Direction)
xboxlove.Dpad.Direction
xboxlove.Dpad.Centered
xboxlove.Dpad.Up
xboxlove.Dpad.Down
xboxlove.Dpad.Right
xboxlove.Dpad.Left
Buttons : (booleans)
xboxlove.Buttons.A
xboxlove.Buttons.B
xboxlove.Buttons.X
xboxlove.Buttons.Y
xboxlove.Buttons.LT
xboxlove.Buttons.RT
xboxlove.Buttons.LB
xboxlove.Buttons.RB
xboxlove.Buttons.Back
xboxlove.Buttons.Start
xboxlove.Buttons.LeftStick
xboxlove.Buttons.RightStick
Methods :
xboxlove:update(dt) (Need to be in love.update)
xboxlove:setJoystick(joystick) (return a boolean)
xboxlove:getJoystick()
xboxlove:setDeadzone(axes,deadzone) (Set a deadzone for one or more axes. (axes(str) can contain "LX","LY","TRIG","TLEFT","TRIGHT","RX","RY" or just "ALL") )
xboxlove:isDown(button) (Use a friendly string ("A","Start",etc) to know if a button is down)
Constructor : xboxlove.create(joystick) (Return a xboxlove object and set the joystick (if omit joystick = 1 and if the joystick doesn't exit or is unplugged return nil) )
Edit :
(Jul 30) I added xboxlove:bind
(Aug 01) Work on OSX ! (with this driver)
(Aug 03) Now the value of the sticks stay between 0 and 1 even with a dead zone, so the angles value is more precise
xboxlove - Xbox360 Controller module
xboxlove - Xbox360 Controller module
- Attachments
-
- xboxlove.lua
- 0.21
- (9.75 KiB) Downloaded 430 times
-
- demo.love
- (23.21 KiB) Downloaded 438 times
Last edited by Walz. on Sat Aug 03, 2013 10:48 am, edited 12 times in total.
Re: xboxlove - Use xbox controller in your games
I don't own an Xbox, but if this does what I think it does(add Xbox controller support to LÖVE wirelessly), then this will be awesome!!!
"In those quiet moments, you come into my mind" - Liam Reilly
Re: xboxlove - Use xbox controller in your games
I don't own a Xbox neither but I have usb controller.
Love already support xbox controller with love.joystick.
With my code, it's just easier.
Love already support xbox controller with love.joystick.
With my code, it's just easier.
Re: xboxlove - Use xbox controller in your games
Well still, that's so awesome! It's a great module!
"In those quiet moments, you come into my mind" - Liam Reilly
Re: xboxlove - Xbox360 Controller module
You can't have wireless support without Microsoft's own wireless dongle for PC. The wired USB controllers work well, however, and make very nice gamepads.
Re: xboxlove - Xbox360 Controller module
From the title I thought you came up with a way to overcome default driver and actually utilize controller's full capabilities (separate axis for triggers, axis for battery status and a key for "home" button), but it turned out to be just a simple wrapper. I don't even need to look at the source.
Code: Select all
function xboxlove.isDown ( self, button )
return love.joystick.isDown ( self.joystick, button ) and true or false
end
- slime
- Solid Snayke
- Posts: 3160
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: xboxlove - Xbox360 Controller module
No. Re-read the OP.raidho36 wrote:I don't even need to look at the source.Code: Select all
function xboxlove.isDown ( self, button ) return love.joystick.isDown ( self.joystick, button ) and true or false end
Keep in mind that drivers used in other operating systems map the Xbox controller inputs to different values, so this will likely only work in Windows.
Re: xboxlove - Xbox360 Controller module
Curse you, slime! I actually dig into the source, and just you check this out:
This is the worst case of all, but still half thing is quite sub-optimal in one way or another.
Code: Select all
function xboxlove:isDown(button)
for k,v in pairs(self.Buttons) do
if k == button then return v end
end
return false
end
- slime
- Solid Snayke
- Posts: 3160
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: xboxlove - Xbox360 Controller module
I was actually referring to the fact that the buttons are friendly strings ("A", "B", "X", "Y", etc.) instead of the normal unintuitive joystick button numbers.raidho36 wrote:Curse you, slime! I actually dig into the source, and just you check this out:This is the worst case of all, but still half thing is quite sub-optimal in one way or another.Code: Select all
function xboxlove:isDown(button) for k,v in pairs(self.Buttons) do if k == button then return v end end return false end
Who is online
Users browsing this forum: No registered users and 1 guest