Xinput for Love (Real Xbox controller support) BETA

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Charles Randall
Prole
Posts: 34
Joined: Wed May 09, 2012 2:52 pm

Xinput for Love (Real Xbox controller support) BETA

Post by Charles Randall »

Hey all, because there isn't native support for Xinput in Love, and thus Xbox controllers, I've decided to add it. The benefit of this will be: Proper working triggers on xbox controllers, as well as support for gamepad vibration. Extra benefits will be proper support for all those fun xbox accessories with USB connectors (like wheels, guitars, etc).

As I'm writing a drop-in replacement module for Joystick, I'm realizing more and more than the xinput paradigm doesn't match that of SDL. Also, SDL and Xinput can coexist side by side, so I'm thinking at this point rather than making a replacement module for joystick (so that love.joystick.* just magically works with a 360 controller), making a completely new module (love.xinput.*).

In either case, if the love devs don't want to pull in my changes, adding support for my changes will require building your own love executable.

Pros of Joystick replacement:
-super easy to drop in and compile.
-still works with all your existing love code

Cons of Joystick replacement:
-may break existing non-xbox controller functionality
-inability to easily use old SDL joystick code

Pros of new module:
-guaranteed to not break existing code
-can be built API compatible with Joystick
-easy for love devs to pull changes safely

Cons of new module:
-need to write new input code in love apps to support xbox functionality
-much harder to integrate changes to the love codebase for people making their own exe if the love devs don't accept the changes

Anyone have any thoughts? Love devs?
Last edited by Charles Randall on Thu Aug 09, 2012 2:44 am, edited 2 times in total.
User avatar
OmarShehata
Party member
Posts: 259
Joined: Tue May 29, 2012 6:46 pm
Location: Egypt
Contact:

Re: Xinput for Love (Real Xbox controller support)

Post by OmarShehata »

That sounds pretty awesome actually.

It would be super immensely helpful if you posted like an article or a tutorial about how you edited Love's source to do that, because right now, although I have yet to attempt it, editing love's source seems a bit daunting.
User avatar
Charles Randall
Prole
Posts: 34
Joined: Wed May 09, 2012 2:52 pm

Re: Xinput for Love (Real Xbox controller support)

Post by Charles Randall »

I've been making games for 14 years so mostly I'm just doing what I do normally at work. Which is: "find in files", read a lot of code, decide what to do. :)

Love's source is pretty slick though, the module system is making my life super easy doing this. I might even finish a first pass today.
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Xinput for Love (Real Xbox controller support)

Post by Lafolie »

Xinput seems to be made for xbox and windows. Will this module work on other platforms?
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
Charles Randall
Prole
Posts: 34
Joined: Wed May 09, 2012 2:52 pm

Re: Xinput for Love (Real Xbox controller support)

Post by Charles Randall »

Xinput is Windows specific, and I don't think anyone has made drivers for 360 devices for other platforms. But if at any point someone makes an Xinput compatible library, I would gladly hook it up.

That being said, first version is up. I have either the code you can drop in and build yourself, or I have a zipped up pre-packaged exe you can use to test things out.

https://github.com/mrcharles/love2d-xinput

I also have a controller test app you can play with to see what it's doing (and you can compare the differences between the SDL implementation and the XInput implementation).

https://github.com/mrcharles/love2d-x360-test
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Xinput for Love (Real Xbox controller support) ALPHA

Post by bartbes »

I don't see a reason to drop support for the majority of joystick devices just to support one.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Xinput for Love (Real Xbox controller support) ALPHA

Post by Nixola »

Didn't he add a new module, instead of replacing love.joystick?
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Xinput for Love (Real Xbox controller support)

Post by Lafolie »

Charles Randall wrote:Xinput is Windows specific, and I don't think anyone has made drivers for 360 devices for other platforms. But if at any point someone makes an Xinput compatible library, I would gladly hook it up.
There are dozens of driver software packages for all manner of devices like this. Xbox, Wii, and PS3 controllers for example, can all be used on OS X, Linux and Windows.

Whilst this is a neat idea, and I very much hope to see it working (the merged triggers thing is annoying!), I think that people value the cross-platform properties of Löve, and you will find that many of its users are not of the windows persuasion.

Besides, should SDL make it to the next version, I think the inbuilt joypad module will be able to compete with Xinput.
bartbes wrote:I don't see a reason to drop support for the majority of joystick devices just to support one.
I thought of adding a pre-configured option for people using the xbox controller in my games, but dismissed the idea as being too dismissive itself. I recently reinstalled Steam and tried some games to find that they only seem to support the Xbox controller. It's funny to see that we both arrive to this conclusion, yet major developers/publishers deem the Xbox pad to be "the controller". Despite the fact that it's probably the most popular pad, it seems to be a rather odd decision.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
Charles Randall
Prole
Posts: 34
Joined: Wed May 09, 2012 2:52 pm

Re: Xinput for Love (Real Xbox controller support) ALPHA

Post by Charles Randall »

First, this is just an alpha so for now it flat out replaces the joystick module. This was my proof of concept in order to make sure the idea was even possible.

Second, the reason everyone supports xbox 360 controllers is that they are the most common controller out there which you can simply plug into your system and have it work.

Third, the problem with non-XInput libraries is that without special drivers customized for the xbox 360 controllers, the triggers will never function properly, because to standard joystick libraries, both triggers read as the same axis, which means they are impossible to distinguish at run time. Holding both triggers is the same as not holding the triggers at all.

Fourth, supporting Xinput gives direct support for a ton of really awesome controllers. I've tested with a Guitar Hero 2 guitar, for example. Works great. I have a Forza racing wheel that I'll test as well at some point. Dance pads? Those should work too. I don't know how well these things work without Xinput, if at all.

Fifth, you get proper vibration support, which SDL doesn't support at all. As far as I can tell anyway.

That all being said, I am sharing this because I am going to do it anyway, and I expect there are probably a few devs out there who will appreciate the extra features this brings to Love2D.

My next steps is to make it into its own Module, and if need be, modify love's source directly to support dynamic module drop in, so that I can simply ship a DLL which you can put in your love directory if you want it, and have it work, without actually modifying love itself. Of course, this step will require acceptance on the part of the Love devs themselves, but the ability to create your own modules in C++ would certainly be a feature that more advanced developers would appreciate, and would contribute very strongly to the value of Love as a full scale game development tool.
User avatar
Charles Randall
Prole
Posts: 34
Joined: Wed May 09, 2012 2:52 pm

Re: Xinput for Love (Real Xbox controller support)

Post by Charles Randall »

Lafolie wrote:
Charles Randall wrote: Whilst this is a neat idea, and I very much hope to see it working (the merged triggers thing is annoying!), I think that people value the cross-platform properties of Löve, and you will find that many of its users are not of the windows persuasion.
It's working. You can grab it right now and give it a test.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests