Game Development Community

Gamepad/Xbox controller in T3D?

by Michael Levy · in Torque 3D Beginner · 02/17/2010 (9:32 am) · 4 replies

Hey everyone, I'm rather new to the forums so please forgive me if this has been answered somewhere else already.

I'm looking at purchasing Torque 3D to use in my senior project. I'm developing a turn-based RPG akin to Final Fantasy X. I've got most of the details worked out; however, I've hit a potential snag. I'm looking at getting the binary for T3D as it fits into my college budget very nicely.

The problem is that I'd like to use a gamepad/Xbox 360 controller for the game. From searching the forums, I know that its possible as I've seen people say that they do so in TGEA. What I can't find is:

1. Does T3D support the use of a gamepad/Xbox controller? (I would assume it does since the previous versions do)

2. Do I have to have access to the source code to include DirectInput and/or possibly something else to enable the gamepad/Xbox functionality or can I do it through scripting?

Any help on clarifying this would be most helpful! Thanks!

About the author

Recent Threads


#1
02/17/2010 (3:36 pm)
1. Yes.
2. No.

Plug in a 360 controller, and ensure that you have made a script call to "activateDirectInput();". You can put it in main.cs if you want it to accept DirectInput right from the start.

Edit: You also need "$enableDirectInput = 1;" as well.
#2
03/03/2010 (8:12 am)
i've tried this, and even put some echo's here and tehre, and it doesnt work for me...

the console says "DirectInputActivated" or something, but i dont see the gamepad functions working... help anyone?
#3
03/05/2010 (8:29 am)
Can you give an example of a function you wrote and how you mapped it to a moveMap binding? I'm thinking either the moveMap was not set up properly or the device is not being detected.
#4
03/05/2010 (9:18 am)
hello there, Michael.

right now, im using stock T3D code for that, for example:

function gamepadYaw(%val)
{
   %yawAdj = getGamepadAdjustAmount(%val);
   if(ServerConnection.isControlObjectRotDampedCamera())
   {
      // Clamp and scale
      %yawAdj = mClamp(%yawAdj, -m2Pi()+0.01, m2Pi()-0.01);
      %yawAdj *= 0.5;
   }

   $mvYaw += %yawAdj;
}

and here are the bindings:
moveMap.bind( keyboard, space, jump );
moveMap.bind( mouse, xaxis, yaw );
moveMap.bind( mouse, yaxis, pitch );

moveMap.bind( gamepad, thumbrx, "D", "-0.23 0.23", gamepadYaw );
moveMap.bind( gamepad, thumbry, "D", "-0.23 0.23", gamepadPitch );
moveMap.bind( gamepad, thumblx, "D", "-0.23 0.23", gamePadMoveX );
moveMap.bind( gamepad, thumbly, "D", "-0.23 0.23", gamePadMoveY );

moveMap.bind( gamepad, btn_a, jump );
moveMap.bindCmd( gamepad, btn_back, "disconnect();", "" );

moveMap.bindCmd(gamepad, dpadl, "toggleLightColorViz();", "");
moveMap.bindCmd(gamepad, dpadu, "toggleDepthViz();", "");
moveMap.bindCmd(gamepad, dpadd, "toggleNormalsViz();", "");
moveMap.bindCmd(gamepad, dpadr, "toggleLightSpecularViz();", "");

like i said, those are stock T3D scripts that are saved when you create a demo with full template.

i've tried modifying "gamepad" to "gamepad0", and nothing... gonna try again... maybe the device (a logitec gamepad) is not properly detected by the engine? (windows detects it just fine, and it works with other games).

PS: all that code, comes from default.binds.cs ... and i've already deleted config.cs, just in case.