Game Development Community

XBox controller input

by Michael McCarthy · in Torque 2D Beginner · 03/25/2014 (11:14 pm) · 4 replies

Sorry if this is a simple question but I've been sinking a lot of time into this issue and can't find much material on it online.

I can't seem to get input from my Xbox controller. My first issue is that I cannot get the script to recognize the call enableXInput(). I may be putting it in the wrong place or not calling it properly but I have tried every combination I can think of.

If anyone can help or has an example of getting Xbox input callback, start of game code to the actual call, I would be very thankful.

About the author


#1
03/26/2014 (3:32 am)
Hello Michael,

What version of T2D are you using? Is it 2.0 from a binary download or the master branch? Or are you using the development branch?

Xbox controller support is only available from the development branch at the moment. We're coming up on the 3.0 release so some documentation has already been updated ahead of time - sorry for any confusion.
#2
03/27/2014 (2:57 pm)
I am using the masterbranch. So if I switch to the development branch I can use Xinput? Will my existing scripts still work the same as they do in the master?
#3
03/27/2014 (3:22 pm)
I strongly suggest setting the development branch to a different folder instead of overwriting your master branch.

No guarantees can be made that your scripts will work 100%; they SHOULD work but several bugfixes might yield funky behaviors. For instance, changes to how angles are calculated might make for really weird movement in your original code.
#4
03/27/2014 (3:35 pm)
Yes, if you switch to the development branch you can use Xinput.

I don't know what your scripts look like, but there aren't that many breaking changes from 2.0 to 3.0. The biggest change has to do with polar coordinates (polar velocity and particle emission angles being two obvious sources). So you should be able to copy your modules over and continue developing where you left off without any major rewrites.