Game Development Community

How do I get the joystick to work?

by Conor O Kane · in Torque Game Builder · 04/01/2007 (4:32 am) · 5 replies

I'd like to play the scroller demo tutorial game using my pc gamepad. I would have thought that I could replace
moveMap.bindCmd(keyboard, "w", "$pShip.playerMovement(up);", "$pShip.playerMovement(stopUp);");

with

moveMap.bindCmd(joystick, "upov", "$pShip.playerMovement(up);", "$pShip.playerMovement(stopUp);");

but that has no effect. What am I overlooking please?

#1
04/01/2007 (11:34 pm)
I found some good tips here: http://www.garagegames.com/mg/forums/result.thread.php?qt=32873
which I will try out later.
#2
04/02/2007 (4:53 am)
Thanks to David Bar's tips in the above linked thread I've not got my joystick working, but not perfectly.

The analog stick works great, but the POV hat (d-pad) doesn't register diagonals. As soon as I hit a diagonal my player stops moving.

Also, and this is much more annoying - the TGB editor crashes every time I click outside the editor window once I've run the game with Joystick enabled. Has anybody else experienced this, is there some cleanup code I should be including to close down joystick input after the game stops?

Setting $enableDirectInput to 1 and running activateDirectInput(); is what's causing the editor to crash, but I need to do that to enable the joystick.
#3
04/05/2007 (11:20 pm)
I've bought an Xbox 360 wired controller and the problems with the TGB editor crashing have gone away. Maybe it was a problem with the XBCD drivers for the old Xbox controller? Who knows. I feel like I'm having a conversation with myself.
#4
04/09/2007 (6:51 am)
Hi Conor,
There is a very good entry in TDN for key mapping and it includes a very good section for joystick/game pad usage and binding and including code.

If you have not seen it yet, look here:
http://tdn.garagegames.com/wiki/Script/Input_Keys_and_Maps
#5
04/09/2007 (5:48 pm)
Thanks Jon, the details on the POV hat in there are very useful!