controller with torque game engine, need help
by Ryan Avent · in Technical Issues · 06/06/2009 (9:17 pm) · 14 replies
hi i want to use a controle pad to move the charicter in the the demo game that comes with the torque game engine (TGE), i have searched the forum and am unable to vue most of the threads about useing controllers,
i want to know what game pads can be used and what exackly will i need to change to be able to use it.
any help at all would be good thanks.
i want to know what game pads can be used and what exackly will i need to change to be able to use it.
any help at all would be good thanks.
About the author
#2
06/07/2009 (11:39 am)
thanks it gives you some example script to work with but as i am new to torque script i am still unshure where to put it do i place this script in its own .cs file of in one that allready exsists?
#3
}
// This code as been tested on WindowsXP for TGE 1.5 and TGB 1.1.3
function ps2bind()
{
//SETUP
$enableDirectInput = "1";
activateDirectInput();
enableJoystick();
//BUTTONS
GlobalActionMap.bindCmd( gamepad, "button12", "echo(\"Pressed TRIANGLE\");", "");
GlobalActionMap.bindCmd( gamepad, "button13", "echo(\"Pressed CIRCLE\");", "");
GlobalActionMap.bindCmd( gamepad, "button14", "echo(\"Pressed X\");", "");
GlobalActionMap.bindCmd( gamepad, "button15", "echo(\"Pressed SQUARE\");", "");
GlobalActionMap.bindCmd( gamepad, "button8", "echo(\"Pressed L2\");", "");
GlobalActionMap.bindCmd( gamepad, "button9", "echo(\"Pressed R2\");", "");
GlobalActionMap.bindCmd( gamepad, "button10", "echo(\"Pressed L1\");", "");
GlobalActionMap.bindCmd( gamepad, "button11", "echo(\"Pressed R1\");", "");
GlobalActionMap.bindCmd( gamepad, "button0", "echo(\"Pressed SELECT\");", "");
GlobalActionMap.bindCmd( gamepad, "button3", "echo(\"Pressed START\");", "");
GlobalActionMap.bindCmd( gamepad, "button1", "echo(\"Pressed L-ANALOG\");", "");
GlobalActionMap.bindCmd( gamepad, "button2", "echo(\"Pressed R-ANALOG\");", "");
// ANALOG
GlobalActionMap.bindCmd( gamepad, xaxis, "LAnaglogX");
GlobalActionMap.bindCmd( gamepad, yaxis, "LAnaglogY");
GlobalActionMap.bindCmd( gamepad, rzaxis, "RAnaglogX");
GlobalActionMap.bindCmd( gamepad, zaxis, "RAnaglogY");
// D-PAD
// Press are release
GlobalActionMap.bindCmd( gamepad, upov, "echo(\"Pressed UPOV\");", "" );
GlobalActionMap.bindCmd( gamepad, dpov, "echo(\"Pressed DPOV\");", "" );
GlobalActionMap.bindCmd( gamepad, lpov, "echo(\"Pressed LPOV\");", "" );
GlobalActionMap.bindCmd( gamepad, rpov, "echo(\"Pressed RPOV\");", "" );
// Press before releasing of previous pov
GlobalActionMap.bindCmd( gamepad, upov2, "echo(\"Pressed UPOV2\");", "" );
GlobalActionMap.bindCmd( gamepad, dpov2, "echo(\"Pressed DPOV2\");", "" );
GlobalActionMap.bindCmd( gamepad, lpov2, "echo(\"Pressed LPOV2\");", "" );
GlobalActionMap.bindCmd( gamepad, rpov2, "echo(\"Pressed RPOV2\");", "" );
}
function LAnaglogX( %value )
{
if ( %value!= 0 ) echo( "Left Analog Stick X value = " @ %value );
}
function LAnaglogY( %value )
{
if ( %value!= 0 ) echo ( "Left Analog Stick Y value = " @ %value );
}
function RAnaglogX( %value )
{
if ( %value!= 0 ) echo ( "RightAnalog Stick X value = " @ %value );
}
function RAnaglogY( %value )
{
if ( %value!= 0 ) echo ( "RightAnalog Stick Y value = " @ %value );
}
its a reworked virsion of the code on the TDN to work for the ps3 game pad i just cant get the thing to work any ideas ????
06/07/2009 (12:40 pm)
this is the code im useing atm its located in the player.gui atm as thorught this was the right place}
// This code as been tested on WindowsXP for TGE 1.5 and TGB 1.1.3
function ps2bind()
{
//SETUP
$enableDirectInput = "1";
activateDirectInput();
enableJoystick();
//BUTTONS
GlobalActionMap.bindCmd( gamepad, "button12", "echo(\"Pressed TRIANGLE\");", "");
GlobalActionMap.bindCmd( gamepad, "button13", "echo(\"Pressed CIRCLE\");", "");
GlobalActionMap.bindCmd( gamepad, "button14", "echo(\"Pressed X\");", "");
GlobalActionMap.bindCmd( gamepad, "button15", "echo(\"Pressed SQUARE\");", "");
GlobalActionMap.bindCmd( gamepad, "button8", "echo(\"Pressed L2\");", "");
GlobalActionMap.bindCmd( gamepad, "button9", "echo(\"Pressed R2\");", "");
GlobalActionMap.bindCmd( gamepad, "button10", "echo(\"Pressed L1\");", "");
GlobalActionMap.bindCmd( gamepad, "button11", "echo(\"Pressed R1\");", "");
GlobalActionMap.bindCmd( gamepad, "button0", "echo(\"Pressed SELECT\");", "");
GlobalActionMap.bindCmd( gamepad, "button3", "echo(\"Pressed START\");", "");
GlobalActionMap.bindCmd( gamepad, "button1", "echo(\"Pressed L-ANALOG\");", "");
GlobalActionMap.bindCmd( gamepad, "button2", "echo(\"Pressed R-ANALOG\");", "");
// ANALOG
GlobalActionMap.bindCmd( gamepad, xaxis, "LAnaglogX");
GlobalActionMap.bindCmd( gamepad, yaxis, "LAnaglogY");
GlobalActionMap.bindCmd( gamepad, rzaxis, "RAnaglogX");
GlobalActionMap.bindCmd( gamepad, zaxis, "RAnaglogY");
// D-PAD
// Press are release
GlobalActionMap.bindCmd( gamepad, upov, "echo(\"Pressed UPOV\");", "" );
GlobalActionMap.bindCmd( gamepad, dpov, "echo(\"Pressed DPOV\");", "" );
GlobalActionMap.bindCmd( gamepad, lpov, "echo(\"Pressed LPOV\");", "" );
GlobalActionMap.bindCmd( gamepad, rpov, "echo(\"Pressed RPOV\");", "" );
// Press before releasing of previous pov
GlobalActionMap.bindCmd( gamepad, upov2, "echo(\"Pressed UPOV2\");", "" );
GlobalActionMap.bindCmd( gamepad, dpov2, "echo(\"Pressed DPOV2\");", "" );
GlobalActionMap.bindCmd( gamepad, lpov2, "echo(\"Pressed LPOV2\");", "" );
GlobalActionMap.bindCmd( gamepad, rpov2, "echo(\"Pressed RPOV2\");", "" );
}
function LAnaglogX( %value )
{
if ( %value!= 0 ) echo( "Left Analog Stick X value = " @ %value );
}
function LAnaglogY( %value )
{
if ( %value!= 0 ) echo ( "Left Analog Stick Y value = " @ %value );
}
function RAnaglogX( %value )
{
if ( %value!= 0 ) echo ( "RightAnalog Stick X value = " @ %value );
}
function RAnaglogY( %value )
{
if ( %value!= 0 ) echo ( "RightAnalog Stick Y value = " @ %value );
}
its a reworked virsion of the code on the TDN to work for the ps3 game pad i just cant get the thing to work any ideas ????
#4
Here is a sample that should work
Paste this in "client/scripts/default.bind.cs"
06/07/2009 (4:02 pm)
if you are trying to get your player to be controlled by the analog sticks please note that the tdn functions above that you are using are examples. You must change the binding functions to controll the player instead of outputting echos in the console like the exampleHere is a sample that should work
Paste this in "client/scripts/default.bind.cs"
$pref::Input::Deadzone = 0.0;
$pref::Input::TriggerDeadzone = 0.6;
$pref::Input::Sensitivity = 2;
$Pref::Input::YSensitivity = 1;
$Pref::Input::XSensitivity = 1;
$Pref::Input::YawSensitivity = 0.1;
$Pref::Input::PitchSensitivity = 0.1;
$Pref::Input::InvertRightStick = 0;
$pref::Input::InvertLook = 1;
//=======================================================
function PS3_yaw(%val, %fromInvert)
{
if($Pref::Input::InvertRightStick && ! %fromInvert)
{
PS3_pitch(%val, true);
return;
}
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
$mvYawLeftSpeed = ( %val < 0 ? -1 : 1 ) * mPow( mAbs( %val ), 2.7182818284590452353602874 ) * $Pref::Input::YawSensitivity;
}
else
$mvYawLeftSpeed = 0;
}
function PS3_pitch(%val, %fromInvert)
{
if($Pref::Input::InvertRightStick && ! %fromInvert)
{
PS3_yaw(%val, true);
return;
}
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
if($pref::Input::InvertLook)
%factor = 1;
else
%factor = -1;
$mvPitchUpSpeed = -(( %val < 0 ? -1 : 1 ) * mPow( mAbs( %val ), 2.7182818284590452353602874 ) * %factor * $Pref::Input::PitchSensitivity);
}
else
$mvPitchUpSpeed = 0;
}
function PS3_turn(%val)
{
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
$mvLeftAction = -(%val * $Pref::Input::XSensitivity);
}
else
{
if (!$keyLeft)
{
$mvLeftAction = 0;
}
if (!$keyRight)
{
$mvRightAction = 0;
}
}
}
function PS3_throttle(%val)
{
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
$mvForwardAction = (%val * $Pref::Input::YSensitivity);
}
else
{
if (!$keyForward)
{
$mvForwardAction = 0;
}
if (!$keyBackward)
{
$mvBackwardAction = 0;
}
}
}
moveMap.bind(gamepad, xaxis, PS3_turn);
moveMap.bind(gamepad, yaxis, PS3_throttle);
moveMap.bind(gamepad, rzaxis, PS3_yaw);
moveMap.bind(gamepad, zaxis, PS3_pitch);
#5
ok so iv put that code at the bottom of the code i allready had, overwriting the analog function bit that right?
had to change the buttons as checked the game controlers propertys (found in controle pannel) it dosent say what the names for the joystics are, does that matter?
heres the code as it is atm
------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
//pad
// This code as been tested on WindowsXP for TGE 1.5 and TGB 1.1.3
function ps2bind()
{
//SETUP
$enableDirectInput = "1";
activateDirectInput();
enableJoystick();
//BUTTONS
GlobalActionMap.bindCmd( gamepad, "button1", "echo("Pressed TRIANGLE");", "");
GlobalActionMap.bindCmd( gamepad, "button2", "echo("Pressed CIRCLE");", "");
GlobalActionMap.bindCmd( gamepad, "button3", "echo("Pressed X");", "");
GlobalActionMap.bindCmd( gamepad, "button4", "echo("Pressed SQUARE");", "");
GlobalActionMap.bindCmd( gamepad, "button5", "echo("Pressed L2");", "");
GlobalActionMap.bindCmd( gamepad, "button6", "echo("Pressed R2");", "");
GlobalActionMap.bindCmd( gamepad, "button7", "echo("Pressed L1");", "");
GlobalActionMap.bindCmd( gamepad, "button8", "echo("Pressed R1");", "");
GlobalActionMap.bindCmd( gamepad, "button9", "echo("Pressed SELECT");", "");
GlobalActionMap.bindCmd( gamepad, "button12", "echo("Pressed START");", "");
GlobalActionMap.bindCmd( gamepad, "button10", "echo("Pressed L-ANALOG");", "");
GlobalActionMap.bindCmd( gamepad, "button11", "echo("Pressed R-ANALOG");", "");
// ANALOG
GlobalActionMap.bind(joystick, xaxis, "LAnaglogX");
GlobalActionMap.bind(joystick, yaxis, "LAnaglogY");
GlobalActionMap.bind(joystick, rzaxis, "RAnaglogX");
GlobalActionMap.bind(joystick, zaxis, "RAnaglogY");
06/07/2009 (5:18 pm)
sorry im compleetly new at torque script can only do bot paths and triggers atm, ok so iv put that code at the bottom of the code i allready had, overwriting the analog function bit that right?
had to change the buttons as checked the game controlers propertys (found in controle pannel) it dosent say what the names for the joystics are, does that matter?
heres the code as it is atm
------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
//pad
// This code as been tested on WindowsXP for TGE 1.5 and TGB 1.1.3
function ps2bind()
{
//SETUP
$enableDirectInput = "1";
activateDirectInput();
enableJoystick();
//BUTTONS
GlobalActionMap.bindCmd( gamepad, "button1", "echo("Pressed TRIANGLE");", "");
GlobalActionMap.bindCmd( gamepad, "button2", "echo("Pressed CIRCLE");", "");
GlobalActionMap.bindCmd( gamepad, "button3", "echo("Pressed X");", "");
GlobalActionMap.bindCmd( gamepad, "button4", "echo("Pressed SQUARE");", "");
GlobalActionMap.bindCmd( gamepad, "button5", "echo("Pressed L2");", "");
GlobalActionMap.bindCmd( gamepad, "button6", "echo("Pressed R2");", "");
GlobalActionMap.bindCmd( gamepad, "button7", "echo("Pressed L1");", "");
GlobalActionMap.bindCmd( gamepad, "button8", "echo("Pressed R1");", "");
GlobalActionMap.bindCmd( gamepad, "button9", "echo("Pressed SELECT");", "");
GlobalActionMap.bindCmd( gamepad, "button12", "echo("Pressed START");", "");
GlobalActionMap.bindCmd( gamepad, "button10", "echo("Pressed L-ANALOG");", "");
GlobalActionMap.bindCmd( gamepad, "button11", "echo("Pressed R-ANALOG");", "");
// ANALOG
GlobalActionMap.bind(joystick, xaxis, "LAnaglogX");
GlobalActionMap.bind(joystick, yaxis, "LAnaglogY");
GlobalActionMap.bind(joystick, rzaxis, "RAnaglogX");
GlobalActionMap.bind(joystick, zaxis, "RAnaglogY");
#6
// Press are release
GlobalActionMap.bindCmd( joystick, upov, "echo("Pressed UPOV");", "" );
GlobalActionMap.bindCmd( joystick, dpov, "echo("Pressed DPOV");", "" );
GlobalActionMap.bindCmd( joystick, lpov, "echo("Pressed LPOV");", "" );
GlobalActionMap.bindCmd( joystick, rpov, "echo("Pressed RPOV");", "" );
// Press before releasing of previous pov
GlobalActionMap.bindCmd( joystick, upov2, "echo("Pressed UPOV2");", "" );
GlobalActionMap.bindCmd( joystick, dpov2, "echo("Pressed DPOV2");", "" );
GlobalActionMap.bindCmd( joystick, lpov2, "echo("Pressed LPOV2");", "" );
GlobalActionMap.bindCmd( joystick, rpov2, "echo("Pressed RPOV2");", "" );
}
$pref::Input::Deadzone = 0.0;
$pref::Input::TriggerDeadzone = 0.6;
$pref::Input::Sensitivity = 2;
$Pref::Input::YSensitivity = 1;
$Pref::Input::XSensitivity = 1;
$Pref::Input::YawSensitivity = 0.1;
$Pref::Input::PitchSensitivity = 0.1;
$Pref::Input::InvertRightStick = 0;
$pref::Input::InvertLook = 1;
//=======================================================
function PS3_yaw(%val, %fromInvert)
{
if($Pref::Input::InvertRightStick && ! %fromInvert)
{
PS3_pitch(%val, true);
return;
}
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
$mvYawLeftSpeed = ( %val < 0 ? -1 : 1 ) * mPow( mAbs( %val ), 2.7182818284590452353602874 ) *
$Pref::Input::YawSensitivity;
}
else
$mvYawLeftSpeed = 0;
}
function PS3_pitch(%val, %fromInvert)
{
if($Pref::Input::InvertRightStick && ! %fromInvert)
{
PS3_yaw(%val, true);
return;
}
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
if($pref::Input::InvertLook)
%factor = 1;
else
%factor = -1;
$mvPitchUpSpeed = -(( %val < 0 ? -1 : 1 ) * mPow( mAbs( %val ), 2.7182818284590452353602874 )
* %factor * $Pref::Input::PitchSensitivity);
}
else
$mvPitchUpSpeed = 0;
}
function PS3_turn(%val)
{
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
$mvLeftAction = -(%val * $Pref::Input::XSensitivity);
}
else
{
if (!$keyLeft)
{
$mvLeftAction = 0;
}
if (!$keyRight)
{
$mvRightAction = 0;
}
}
}
function PS3_throttle(%val)
{
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
$mvForwardAction = (%val * $Pref::Input::YSensitivity);
}
else
{
if (!$keyForward)
{
$mvForwardAction = 0;
}
if (!$keyBackward)
{
$mvBackwardAction = 0;
}
}
}
moveMap.bind(gamepad, xaxis, PS3_turn);
moveMap.bind(gamepad, yaxis, PS3_throttle);
moveMap.bind(gamepad, rzaxis, PS3_yaw);
moveMap.bind(gamepad, zaxis, PS3_pitch);
------------------------------------------------------------------------
i get no errors but still doesnt move and no words appeair the control box have no idea
06/07/2009 (5:19 pm)
// D-PAD// Press are release
GlobalActionMap.bindCmd( joystick, upov, "echo("Pressed UPOV");", "" );
GlobalActionMap.bindCmd( joystick, dpov, "echo("Pressed DPOV");", "" );
GlobalActionMap.bindCmd( joystick, lpov, "echo("Pressed LPOV");", "" );
GlobalActionMap.bindCmd( joystick, rpov, "echo("Pressed RPOV");", "" );
// Press before releasing of previous pov
GlobalActionMap.bindCmd( joystick, upov2, "echo("Pressed UPOV2");", "" );
GlobalActionMap.bindCmd( joystick, dpov2, "echo("Pressed DPOV2");", "" );
GlobalActionMap.bindCmd( joystick, lpov2, "echo("Pressed LPOV2");", "" );
GlobalActionMap.bindCmd( joystick, rpov2, "echo("Pressed RPOV2");", "" );
}
$pref::Input::Deadzone = 0.0;
$pref::Input::TriggerDeadzone = 0.6;
$pref::Input::Sensitivity = 2;
$Pref::Input::YSensitivity = 1;
$Pref::Input::XSensitivity = 1;
$Pref::Input::YawSensitivity = 0.1;
$Pref::Input::PitchSensitivity = 0.1;
$Pref::Input::InvertRightStick = 0;
$pref::Input::InvertLook = 1;
//=======================================================
function PS3_yaw(%val, %fromInvert)
{
if($Pref::Input::InvertRightStick && ! %fromInvert)
{
PS3_pitch(%val, true);
return;
}
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
$mvYawLeftSpeed = ( %val < 0 ? -1 : 1 ) * mPow( mAbs( %val ), 2.7182818284590452353602874 ) *
$Pref::Input::YawSensitivity;
}
else
$mvYawLeftSpeed = 0;
}
function PS3_pitch(%val, %fromInvert)
{
if($Pref::Input::InvertRightStick && ! %fromInvert)
{
PS3_yaw(%val, true);
return;
}
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
if($pref::Input::InvertLook)
%factor = 1;
else
%factor = -1;
$mvPitchUpSpeed = -(( %val < 0 ? -1 : 1 ) * mPow( mAbs( %val ), 2.7182818284590452353602874 )
* %factor * $Pref::Input::PitchSensitivity);
}
else
$mvPitchUpSpeed = 0;
}
function PS3_turn(%val)
{
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
$mvLeftAction = -(%val * $Pref::Input::XSensitivity);
}
else
{
if (!$keyLeft)
{
$mvLeftAction = 0;
}
if (!$keyRight)
{
$mvRightAction = 0;
}
}
}
function PS3_throttle(%val)
{
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
$mvForwardAction = (%val * $Pref::Input::YSensitivity);
}
else
{
if (!$keyForward)
{
$mvForwardAction = 0;
}
if (!$keyBackward)
{
$mvBackwardAction = 0;
}
}
}
moveMap.bind(gamepad, xaxis, PS3_turn);
moveMap.bind(gamepad, yaxis, PS3_throttle);
moveMap.bind(gamepad, rzaxis, PS3_yaw);
moveMap.bind(gamepad, zaxis, PS3_pitch);
------------------------------------------------------------------------
i get no errors but still doesnt move and no words appeair the control box have no idea
#7
And you can remove this bit of code since its being overwritten anyway :
// ANALOG
GlobalActionMap.bind(joystick, xaxis, "LAnaglogX");
GlobalActionMap.bind(joystick, yaxis, "LAnaglogY");
GlobalActionMap.bind(joystick, rzaxis, "RAnaglogX");
GlobalActionMap.bind(joystick, zaxis, "RAnaglogY");
06/07/2009 (6:41 pm)
ok i noticed one thing with my code and yours...replace all instances of "gamepad" with "joystick" (without quotes). sorry for this error..it SHOULD work and if you have any problems just reply here and ill try to helpAnd you can remove this bit of code since its being overwritten anyway :
// ANALOG
GlobalActionMap.bind(joystick, xaxis, "LAnaglogX");
GlobalActionMap.bind(joystick, yaxis, "LAnaglogY");
GlobalActionMap.bind(joystick, rzaxis, "RAnaglogX");
GlobalActionMap.bind(joystick, zaxis, "RAnaglogY");
#8
06/07/2009 (8:01 pm)
haha cheers well it kinda works the right stick seems to controle moveing of the player as well as roatation of the camra very strange, whats more is with out touching the joystick the camra by defult looks directly up not sure why, theres nothing about controlers in any of the books i have
#9
moveMap.bind(joystick, xaxis, PS3_turn);
moveMap.bind(joystick, yaxis, PS3_throttle);
moveMap.bind(joystick, rzaxis, PS3_yaw);
moveMap.bind(joystick, zaxis, PS3_pitch);
i changed some of the code (shown below) so that i could use both sticks,
function PS3_yaw(%val, %fromInvert)
{
if($Pref::Input::InvertRightStick && ! %fromInvert)
{
PS3_pitch(%val, true);
return;
}
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
$mvYawLeftSpeed = ( %val < 0 ? -1 : 1 ) * mPow( mAbs( %val ), 2.7182818284590452353602874 ) *
$Pref::Input::YawSensitivity;
}
else
$mvYawLeftSpeed = 0;
}
function PS3_pitch(%val, %fromInvert)
{
if($Pref::Input::InvertRightStick && ! %fromInvert)
{
PS3_yaw(%val, true);
return;
}
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
if($pref::Input::InvertLook)
%factor = 1;
else
%factor = -1;
$mvPitchUpSpeed = -(( %val < 0 ? -1 : 1 ) * mPow( mAbs( %val ), 2.7182818284590452353602874 )
* %factor * $Pref::Input::PitchSensitivity);
}
else
$mvPitchUpSpeed = 0;
}
function PS3_turn(%val)
{
if($Pref::Input::InvertLeftStick && ! %fromInvert)
{
PS3_pitch(%val, true);
return;
}
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
$mvLeftAction = -(%val * $Pref::Input::XSensitivity);
}
else
{
if (!$keyLeft)
{
$mvLeftAction = 0;
}
if (!$keyRight)
{
$mvRightAction = 0;
}
}
}
function PS3_throttle(%val)
{
if($Pref::Input::InvertLeftStick && ! %fromInvert)
{
PS3_pitch(%val, true);
return;
}
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
$mvForwardAction = (%val * $Pref::Input::YSensitivity);
}
else
{
if (!$keyForward)
{
$mvForwardAction = 0;
}
if (!$keyBackward)
{
$mvBackwardAction = 0;
------------------------------------------------------------------------
changed the throttle and turn so that they are controled by the left stick, but the right stick can still controle all directions not sure why.
if i am right about the above script being the axis them there are 7 diffrent, i am only fermilure with xyz and -x-y-z and i am compleetly unsure what to do so that the left stick controlls moveing forword back left right and all directional axis on a flat level and to get the the right stick to allow the player to look up down laft and right (think oblivion)
06/07/2009 (8:35 pm)
i asume that this bit of script tels the rest what axis to move onmoveMap.bind(joystick, xaxis, PS3_turn);
moveMap.bind(joystick, yaxis, PS3_throttle);
moveMap.bind(joystick, rzaxis, PS3_yaw);
moveMap.bind(joystick, zaxis, PS3_pitch);
i changed some of the code (shown below) so that i could use both sticks,
function PS3_yaw(%val, %fromInvert)
{
if($Pref::Input::InvertRightStick && ! %fromInvert)
{
PS3_pitch(%val, true);
return;
}
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
$mvYawLeftSpeed = ( %val < 0 ? -1 : 1 ) * mPow( mAbs( %val ), 2.7182818284590452353602874 ) *
$Pref::Input::YawSensitivity;
}
else
$mvYawLeftSpeed = 0;
}
function PS3_pitch(%val, %fromInvert)
{
if($Pref::Input::InvertRightStick && ! %fromInvert)
{
PS3_yaw(%val, true);
return;
}
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
if($pref::Input::InvertLook)
%factor = 1;
else
%factor = -1;
$mvPitchUpSpeed = -(( %val < 0 ? -1 : 1 ) * mPow( mAbs( %val ), 2.7182818284590452353602874 )
* %factor * $Pref::Input::PitchSensitivity);
}
else
$mvPitchUpSpeed = 0;
}
function PS3_turn(%val)
{
if($Pref::Input::InvertLeftStick && ! %fromInvert)
{
PS3_pitch(%val, true);
return;
}
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
$mvLeftAction = -(%val * $Pref::Input::XSensitivity);
}
else
{
if (!$keyLeft)
{
$mvLeftAction = 0;
}
if (!$keyRight)
{
$mvRightAction = 0;
}
}
}
function PS3_throttle(%val)
{
if($Pref::Input::InvertLeftStick && ! %fromInvert)
{
PS3_pitch(%val, true);
return;
}
if (%val < -$Pref::Input::DeadZone || %val > $Pref::Input::DeadZone)
{
$mvForwardAction = (%val * $Pref::Input::YSensitivity);
}
else
{
if (!$keyForward)
{
$mvForwardAction = 0;
}
if (!$keyBackward)
{
$mvBackwardAction = 0;
------------------------------------------------------------------------
changed the throttle and turn so that they are controled by the left stick, but the right stick can still controle all directions not sure why.
if i am right about the above script being the axis them there are 7 diffrent, i am only fermilure with xyz and -x-y-z and i am compleetly unsure what to do so that the left stick controlls moveing forword back left right and all directional axis on a flat level and to get the the right stick to allow the player to look up down laft and right (think oblivion)
#10
I will get my ps3 controller and see if i can fix the axis mappings
06/08/2009 (12:22 pm)
ahh yes..that is how the original functions work..i never used them on a ps3 controller thought i used my xbox 360 functions from my game here..n as far as getting analog movement when nothing is touched you should play with "$Pref::Input::DeadZone" and find the magic number there. that tells the functions what values to ignore (usually around 0.1 - 0.25) since they may be just noise from the controller (4got to mention that earlier)I will get my ps3 controller and see if i can fix the axis mappings
#11
06/08/2009 (1:04 pm)
i have an xbox 360 controler if it will be easyer to script
#12
but yes i guess if your gonna have one controller supported u should do both
06/08/2009 (1:39 pm)
well the xinput addon for tourqe really makes the xbox 360 controller shine, but i'm gonna take a stab @ this because its something ive been meaning to do for a while :pbut yes i guess if your gonna have one controller supported u should do both
#13
06/20/2012 (1:33 pm)
Hey scooby and Ryan is it okay that I copied and pasted your PS3 controller input for default.bind.cs? Also Ryan I used the "DirectInput" stuff is that alright?
#14
06/20/2012 (1:35 pm)
PS: I gave both of you credit in the default.bind.cs code.
Torque 3D Owner Scooby Brown
Here is a tdn link for an example