xboxlove - Xbox360 Controller module

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: xboxlove - Xbox360 Controller module

Post by Jasoco » Fri Aug 02, 2013 6:25 am

slime wrote:The new 0.9.0 Joystick API is not finalized yet. The main repository / builds for 0.9.0 don't have any changes related to SDL 2 in yet, so the Joystick API there is not what it is in the SDL 2 branch (although it's still a tiny bit different from the old 0.8.0, mostly some renamed functions for consistency.)

I think you will be happy with the changes and additions though. :)
I can wait. Especially if Walz is prepared to update. Will be awesome when it's out. I never thought 9 would drop support, but didn't know it wasn't completely replaced yet.

User avatar
Walz.
Prole
Posts: 13
Joined: Mon May 06, 2013 2:42 pm

Re: xboxlove - Xbox360 Controller module

Post by Walz. » Fri Aug 02, 2013 11:37 am

Jasoco wrote:Pretty darn neato. Very useful. You're amazing.

Could you maybe make a single "xboxlove:init()" function that we could just call easily from the start. I look at the source of your demo.love and I'm not completely sure which code I need and which is just for the app. And I read the methods section and am confused. For now I'll just try and copy what's in the demo, but it's confusing from the start.

I mean it says I just need to use the update function but in your demo you're using other extra code and setting joysticks and deadzones. I just want to plop it into a project and use maybe 2 lines to load and update it. Like what does joystick = 1 mean? Does that mean we can use two or more? How exactly do you go about it? (Not that I have more than one)

Edit: Also, how do I use this on 0.9.0? When I try to run it it says "getNumJoysticks is a nil value". 0.9.0 seems to have changed how Joysticks work. Can one of the 0.9.0 people chime in maybe? I'd loooove to get this working in 9. Maybe we can get this working on both 8 and 9 since 9 is apparently coming soon™*. Should be pretty easy, I just don't know how Joysticks work on 9 let alone 8. So I don't know what to change.

*Valve Time™
I'm not good at commenting my code ... (and love.draw in the demo is a mess)
You can use more than one controller.
Each xboxlove object represent one controller.
Ex :

Code: Select all

function love.load()
    require 'xboxlove'
    player1 = xboxlove.create(1)
    player2 = xboxlove.create(2)

    player1:setDeadzone("all",0.15)
    player2:setDeadzone("all",0.15)
end

function love.update(dt)
    player1:update(dt)
    player2:update(dt)
end
And now you can use player1:isDown("A") or access all the variables like player2.Axes.LeftX (x-axis of the left stick)

Could you help one more time, what name do you get from your Xbox360 controller when you use : love.joystick.getName(1).
On Windows, it's "Controller (XBOX 360 For Windows)". It would help me check if xboxlove is using a xbox360 controller and not an other controller.

(for the 0.9, you just need to change love.joystick.getNumJoysticks() to love.joystick.getJoystickCount())

User avatar
Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: xboxlove - Xbox360 Controller module

Post by Jasoco » Sun Aug 04, 2013 7:00 am

Walz. wrote:Could you help one more time, what name do you get from your Xbox360 controller when you use : love.joystick.getName(1).
On Windows, it's "Controller (XBOX 360 For Windows)". It would help me check if xboxlove is using a xbox360 controller and not an other controller.

(for the 0.9, you just need to change love.joystick.getNumJoysticks() to love.joystick.getJoystickCount())
On OS X it just returns as "Controller".

Also, if that's all I need to do to make it work on 9, I'll try it out. Thanks. I'll let you know shortly how it goes...

Edit: Okay, I now get an error when it gets to the first love.joystick.getAxis() call. Says getAxis is nil.

User avatar
slime
Solid Snayke
Posts: 2858
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: xboxlove - Xbox360 Controller module

Post by slime » Sun Aug 04, 2013 10:51 am

Jasoco wrote:Also, if that's all I need to do to make it work on 9, I'll try it out. Thanks. I'll let you know shortly how it goes...

Edit: Okay, I now get an error when it gets to the first love.joystick.getAxis() call. Says getAxis is nil.
You're using an experimental branch of LÖVE 0.9.0 which has a different Joystick API (among other things), not the official changes...

(also I don't suggest attempting to make things work with the current 0.9.0 Joystick API, as it will change before release.)

User avatar
Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: xboxlove - Xbox360 Controller module

Post by Jasoco » Mon Aug 05, 2013 7:09 am

slime wrote:
Jasoco wrote:Also, if that's all I need to do to make it work on 9, I'll try it out. Thanks. I'll let you know shortly how it goes...

Edit: Okay, I now get an error when it gets to the first love.joystick.getAxis() call. Says getAxis is nil.
You're using an experimental branch of LÖVE 0.9.0 which has a different Joystick API (among other things), not the official changes...

(also I don't suggest attempting to make things work with the current 0.9.0 Joystick API, as it will change before release.)
Is there currently no replacement for getAxis? If so then okie dokie.

User avatar
adnzzzzZ
Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

Re: xboxlove - Xbox360 Controller module

Post by adnzzzzZ » Thu Aug 22, 2013 8:00 am

Thanks for writing this. It was really easy to add to my game!

jjmafiae
Party member
Posts: 1333
Joined: Tue Jul 24, 2012 8:22 am

Re: xboxlove - Xbox360 Controller module

Post by jjmafiae » Fri Oct 18, 2013 11:54 am

can use this for my commercial game called 9891? you will get credit.

User avatar
Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: xboxlove - Xbox360 Controller module

Post by Jasoco » Mon Dec 16, 2013 5:16 pm

Now that 0.9.0's finally out with better controller support, anyone willing to tackle updating this library? Or creating a new one?

jjmafiae
Party member
Posts: 1333
Joined: Tue Jul 24, 2012 8:22 am

Re: xboxlove - Xbox360 Controller module

Post by jjmafiae » Mon Dec 16, 2013 5:24 pm

i tried updating it, lets just say it didn't end well.....

User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: xboxlove - Xbox360 Controller module

Post by Ranguna259 » Mon Dec 16, 2013 6:00 pm

Is there really need to update this lib ? Isn't the joystick module pretty stright forward ?
For those that are thinking on creating a new lib keep in mind that the PS4 controller is Plug-and-Play so if someone creates a new lib don't forget to add it's profile.
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest