Xbox 360 Controllers for Windows diff coming to TGE 1.3 / T2D
by Jason Cahill · in Torque Game Builder · 11/21/2005 (12:24 am) · 49 replies
Who wants it? Because I'm putting the finishing touches on this sweet little bad boy (which will be ready before Thanksgiving on TDN). And, I'm not talking about doing it the crappy way (using the driver's built-in Joystick emulation). I'm talking about using the actual MS XInput APIs to go right to the device! That means actual mappings to things like:
actionMap.bind("xinput0", "A", "APressed();" "AReleased();");
actionMap.bind("xinput0", "START", "StartPressed();" "StartReleased();");
Oh yeah, that means graceful connection & disconnection of gamepads, support for up to four controllers on a single PC (mapped to "xinput0" to "xinput3"), the analog triggers work correctly (unlike the Joystick driver)... and wait for it... RUMBLE!
My source diff will also fix up TGE 1.3's poor support for traditional gamepads and also supports "fixed function" force-feedback rumble, in case you have an older Xbox 1 controller that you modded for your PC with XBCD drivers, or a PS-compatible dual strike controller with rumble.
In any event... it's all goodness for you guys. All I ask in return? That we politely voice our words of support to our GG gate keepers to get us a build of T2D 1.1. :-)
See... I'm a reasonable guy. I have something to offer quid... pro... quo.
actionMap.bind("xinput0", "A", "APressed();" "AReleased();");
actionMap.bind("xinput0", "START", "StartPressed();" "StartReleased();");
Oh yeah, that means graceful connection & disconnection of gamepads, support for up to four controllers on a single PC (mapped to "xinput0" to "xinput3"), the analog triggers work correctly (unlike the Joystick driver)... and wait for it... RUMBLE!
My source diff will also fix up TGE 1.3's poor support for traditional gamepads and also supports "fixed function" force-feedback rumble, in case you have an older Xbox 1 controller that you modded for your PC with XBCD drivers, or a PS-compatible dual strike controller with rumble.
In any event... it's all goodness for you guys. All I ask in return? That we politely voice our words of support to our GG gate keepers to get us a build of T2D 1.1. :-)
See... I'm a reasonable guy. I have something to offer quid... pro... quo.
Disclaimer: This diff will only work on Windows PCs running Windows 2000 or above with Direct X 9 (October 2005 edition) available for download right now at MSDN... You will need to purchase an Xbox 360 Game Controller (wired) or and Xbox 360 Game Controller (wireless) with the optional USB plug+charge cable attached... Sorry, no wireless controllers to the PC. :-(
About the author
#2
11/21/2005 (4:59 am)
If your joystick driver supports force feedback (which my PS Dual Strike for Windows from EB Games at $9.95 did), then yes.
#3
11/21/2005 (5:54 am)
@Jason: This is very interesting :) Did you happen to make sure you placed the code down in the platform layer for Win32, or at least wrapped in preprocesser #ifdef blocks to make sure it didn't break cross-platform functionality? If so (and hell, even if not), we would be very interested in looking at the code!
#4
11/21/2005 (9:14 am)
Sweet ...
#5
I sent in a build of just the gamepad stuff (i.e. old joystick support w/ rumble) to Ben Garney about... 5 months ago? Anyway, that was for inclusion in 1.4. At the time, I built a minimal diff against 1.4 HEAD at the time. I've never gone back to see if it was included. The XInput stuff is way, way cooler. Like I said, it will be up here by T-Day.
11/21/2005 (9:17 am)
I did. All of the code is in the Windows platform specific area... the stuff in event.h is ifdef'ed with the platform.I sent in a build of just the gamepad stuff (i.e. old joystick support w/ rumble) to Ben Garney about... 5 months ago? Anyway, that was for inclusion in 1.4. At the time, I built a minimal diff against 1.4 HEAD at the time. I've never gone back to see if it was included. The XInput stuff is way, way cooler. Like I said, it will be up here by T-Day.
#6
11/21/2005 (2:20 pm)
XInput is very nice, having worked with it on the 360. I was planning on doing exactly this after Marble Blast shipped but this is the elegant solution. (Inside joke with Clark. "Elegant Solution" means someone else does it.)
#7
11/21/2005 (3:16 pm)
Is the force feedback something automatic with collision or does it need additional code?
#8
rumble("xinput0", %leftRumble, %rightRumble);
11/21/2005 (5:51 pm)
It would be trivial additional code. Get the collision notification, then call:rumble("xinput0", %leftRumble, %rightRumble);
#9
I'd love feedback from anyone willing to try it out. Everything works perfectly here, but those are always a developers famous last words. :-)
11/23/2005 (8:38 pm)
My turn... This make two big T2D things in the same night. Pretty sweet. Full source code for the engine modifications + four complete samples packaged with both "ready-to-run" precompiled EXE and full source code are up and available in my little corner of TDN: HereI'd love feedback from anyone willing to try it out. Everything works perfectly here, but those are always a developers famous last words. :-)
#10
I'd love feedback from anyone willing to try it out. Everything works perfectly here, but those are always a developers famous last words. :-)
11/23/2005 (8:40 pm)
My turn... This make two big T2D things in the same night. Pretty sweet. Full source code for the engine modifications + four complete samples packaged with both "ready-to-run" precompiled EXE and full source code are up and available in my little corner of TDN: HereI'd love feedback from anyone willing to try it out. Everything works perfectly here, but those are always a developers famous last words. :-)
#11
11/25/2005 (2:06 pm)
Awesome... I was looking to tinker with this to get it to work, but it looks like you've beat me to it. I'm very excited to check this out when I have more time. Thanks!
#12
01/31/2006 (1:55 pm)
I'm curious how exactly to implement this. What code from your examples is needed?
#13
01/31/2006 (4:41 pm)
The source code pack in the link provides the engine mods to t2d 1.0.2 based on TGE 1.3. I'll start work on porting this to 1.4 shortly, now that T2D is on 1.4. You will need to apply the source code changes and rebuild. Then, the samples "just work."
#14
02/24/2006 (3:22 pm)
What an awesome contribution. Thanks a lot Jason.
#16
02/24/2006 (11:26 pm)
You're very welcome! I have the diff for TGB Beta 1.1 completed. I will post it this weekend to the same location on the Wiki.
#17
02/25/2006 (12:54 am)
Is there a version of this for TGE/TSE? It's kind of lame to leave all those guy in the dark about this. :S
#18
02/25/2006 (7:31 am)
The diff works against TAP 1.4 sources, so that means TGE and TGB. I don't know what the TAP version underneath TSE is (even though I own the license), but it's not 1.4. I don't even think it's 1.3. When I respost this, this morning, I will post it for everyone.
#19
The new home for this information in TDN is: http://tdn.garagegames.com/wiki/Torque/EngineMods/Xbox360ControllerSupport
02/25/2006 (8:58 am)
OK, I've updated the source and samples to work with 1.4, meaning you can just drag and drop these files over those in Beta 1.1, recompile, and it will work. I've updated the samples to include the latest compiled exe version of T2D as well (even though the samples don't use any TGB-specific functionality).The new home for this information in TDN is: http://tdn.garagegames.com/wiki/Torque/EngineMods/Xbox360ControllerSupport
#20
02/25/2006 (11:08 am)
That's excellent :) Thanks so much for included a compiled version as well. I'll hopefully have a play with it later on.
Torque Owner Ricky Taylor
=D
Get it finished, NOW >=D.