Game Development Community

Gamepad controller setup?

by zede05 · in Torque 3D Professional · 02/22/2011 (12:46 am) · 7 replies

I'm using winDirectInPut.cpp right now, and it seems only the 360 controller works with it. How can I get the other controllers (like from Logitech or something generic) to work? Any help would be appreciated!

#1
02/22/2011 (9:19 am)
Anything not a 360 controller should work with joystick binds: tdn.garagegames.com/wiki/Script/Input_Keys_and_Maps#JOYSTICK_AND_MOUSE_INPUTS

moveMap.bindCmd(joystick, "button0", "echo(\"Pressed TRIANGLE\");", "");
#2
02/22/2011 (11:12 am)
I'm pretty sure the "gamepad" bind uses XInput which is (to my knowledge) 360 controller only.
As Brian mentioned, the rest should use the "joystick" inputs
#3
02/22/2011 (1:03 pm)
joystick0 was the key for me... or whatever number is exposed for that particular controller, ie joystick1.

Here is what I used for a saitek dual stick rumble controller:
function joystickMoveX( %val )
{
   $mvXAxis_L = %val;
}

function joystickMoveY( %val )
{
   $mvYAxis_L = -%val;
}

function joystickYaw(%val)
{
      
  $mvYawLeftSpeed = (%val * 0.15);
}

function joystickPitch(%val)
{
   $mvPitchUpSpeed = (%val * 0.1);
}


moveMap.bind( joystick0, xaxis, joystickMoveX );
moveMap.bind( joystick0, yaxis, joystickMoveY );

moveMap.bind( joystick0, zaxis,  joystickPitch);
moveMap.bind( joystick0, rzaxis, joystickYaw);

moveMap.bind(joystick0, button0, toggleCamera);
moveMap.bind(joystick0, button1, toggleZoom);
moveMap.bind(joystick0, button2, toggleFirstPerson);
moveMap.bind(joystick0, button3, toggleZoomFOV);
moveMap.bind(joystick0, button4, toggleTimeAdjustGui);
moveMap.bind( joystick0, button5, showBHV );
moveMap.bind( joystick0, button6, jump );

There is a lot that can be exposed if you want to look into the InputManager/DInputManager code, rumble, etc.

Also, I find I need to do this (sometimes T3D drops the controller or never sees it for some reason, havent really dug into it, but this will rebind it):
enableJoystick();
#4
02/22/2011 (6:16 pm)
Great, that worked, thanks!
#5
02/23/2011 (2:26 am)
When I enable the joystick, the player start moving forward immediately. Do you have the same experience, or do I need something else?
#6
02/23/2011 (5:34 am)
Nope, I just plugged in the above code and it worked (then again, since I'm making a platformer, the bindings are a bit different now). I'm using a logitech controller. If you can, plug in a 360 controller and see if you get the same result, if you do, then I'd assume it's not the controller code fault.
#7
02/23/2011 (6:25 am)
@Richard: Try running the windows calibration utility in control panel. Click the 'properties' for your joystick/pad.

Some pads need the dead zone set pretty large. You can also create a dead zone using the code above (making sure %val is above a certain value before assigning, otherwise assign 0).