Game Development Community

Using the Xbox 360 controller analog sticks

by USC - IMD student 4 · in Torque Game Builder · 03/09/2008 (2:51 pm) · 2 replies

Hello everyone, I'm trying to implement an Xbox 360 controller into TGB through a behavior I will assign to the player sprite.

My method of binding the buttons (A, B, X, Y) WORKS, and is as follows:

function controllerBehavior::onBehaviorAdd(%this)
{
moveMap.bindObj(joystick0, "button0", "check", %this);
}

etc. for B, X, and Y.

The function does NOT work with the analog control sticks. Nothing happens when they're bound with a bindObj.

So, anyone know how to bind the analog sticks (and thus call functions) within CURRENT versions of torque that utilize behaviors?

#1
03/16/2008 (1:16 pm)
These links on TDN should cover the basics, though I didn't even know that you could use bindObj, so bah :)

You could set it up in a behavior anyway using its namespace.

here
here
and here
#2
03/17/2008 (12:02 pm)
Thanks for the help, Tom. What I ended up doing was binding all the buttons and analog sticks within game.cs, using the code found at http://tdn.garagegames.com/wiki/Script/Input_Keys_and_Maps as a guide.

I didn't actually need to have the functions be part of a behavior, it was just natural for me to try to code them that way because everything else I've written for the game has been contained in behaviors.

Thanks again!