Author Topic: JoyStick bindings  (Read 2015 times)

I'm working to make my Afterglow PS3 controller to work with blockland, and I have gotten the functions to work except a few.

I need to know what are the axis bindings are, I have:
Xaxis - Left brown townog stick left and right.
Yaxis - Left brown townog sick up and down.
Zaxis - Right brown townog sick left and right
And I can't figure out the up and down binding, I tried Z rotation, and plain axis.
Is there even a way to set it up?

Also, I need the function to toggle the camera from first and third view.

What are you trying to figure out? How torque handles joystick input? How to set axis rotation client side?

What are you trying to figure out? How torque handles joystick input? How to set axis rotation client side?
I already know how to set bindings, I just need the up and down axis of the right brown townog stick, I imagine its something weird, because as I said in the main post, xaxis, yaxis, and zaxis, is already used.

There might only be support for one joystick.

There might only be support for one joystick.
I was afraid I might not be able to get the other brown townog stick to work, I probably will still look around in hopes of finding a way to get it to work.

After I used google, I found this documentation which was what I needed.
Torque 3D - Script Manual: Input Event Listing


Did those work?
Haven't tried yet, but they should.
It'll probably be later or tomorrow when I try.



I remember hearing from a friend that controller support for this version of Torque isn't as easy as a function call because joystick input counts as a button press or something.

Not sure if this is true or not because I never tested for myself.

I remember hearing from a friend that controller support for this version of Torque isn't as easy as a function call because joystick input counts as a button press or something.

Not sure if this is true or not because I never tested for myself.
Yes that is true but I'm using schedules and stuff to get the axis values and applying yaw, pitch and stuff.

When I finish the script I probably will post it so if anyone wants it/needs it.

Are you able to detect the stick only being pushed part way, rather than just on or off?

Are you able to detect the stick only being pushed part way, rather than just on or off?
Are you talking about percentage of how much it is pushed, if so, yea it does do that, which is good, so the camera doesn't turn to much, I'm finished with the script I'll post it tomorrow when I get on my computer.

Here it is, its kinda glitchy sometimes.
Code: (Joystick.cs) [Select]
$JoyMultiplier = 10;
$CrouchTog = 0;
package joyFunctions
{
function applyJoyYaw()
{
cancel($JoyStickYawSched);
if($JoyStickYaw <= 0.025 && $JoyStickYaw >= -0.025)
$JoyStickYaw = 0;
if($JoyStickYaw > 0.1)
%sched = $JoyStickYaw*10;
if($JoyStickYaw < -0.1)
{
%x = -$JoyStickYaw;
%sched = %x*10;
}
if(%sched < 1)
%sched = 1;
$JoyStickYawSched = schedule(%sched,0,applyJoyYaw);
Yaw($JoyStickYaw*$JoyMultiplier);
}
function applyJoyPitch()
{
cancel($JoyStickpitchSched);
if($JoyStickpitch <= 0.025 && $JoyStickpitch >= -0.025)
$JoyStickpitch = 0;
if($JoyStickpitch > 0.1)
%sched = $JoyStickpitch*10;
if($JoyStickpitch < -0.1)
{
%x = -$JoyStickpitch;
%sched = %x*10;
}
if(%sched < 1)
%sched = 1;
$JoyStickpitchSched = schedule(%sched,0,applyJoyPitch);
pitch($JoyStickpitch*$JoyMultiplier);
}
function yawJoy(%xaxis)
{
$JoyStickYaw = %xaxis;
}
function pitchJoy(%yaxis)
{
$JoyStickPitch = %yaxis;
}
function joyMouseFire(%x)
{
mouseFire(%x);
}
function joyZAxis(%x)
{
if(%x <= 0.025 && %x >= -0.025)
{
moveLeft(0);
moveRight(0);
}
if(%x <= -0.1)
{
moveLeft(0-%x);
moveRight(0);
}
else if(%x >= 0.1)
{
moveRight(%x);
moveLeft(0);
}
}
function JoyTM(%x)
{
if(%x)
{
if($JoyMultiplier == 10)
{
newChatHud_AddLine("Multiplier is now 20");
$JoyMultiplier = 20;
}
else if($JoyMultiplier == 20)
{
newChatHud_AddLine("Multiplier is now 30");
$JoyMultiplier = 30;
}
else if($JoyMultiplier == 30)
{
newChatHud_AddLine("Multiplier is now 10");
$JoyMultiplier = 10;
}
}
}
function joyRZAxis(%x)
{
if(%X <= 0.025 && %X >= -0.025)
{
moveForward(0);
moveBackward(0);
}
if(%x <= -0.1)
{
moveBackward(%x);
moveForward(0);
}
if(%x >= 0.1)
{
moveForward(0-%x);
moveBackward(%x);
}
}
function joyXAxis(%x)
{
$JoyStickxaxis = %x;
}
function joyToggleZoom(%x)
{
toggleZoom(%x);
}
function joyToggleFirstPerson(%x)
{
toggleFirstPerson(%x);
}
function joyscrollTools(%x)
{
useTools(%x);
}
function joyJet(%x)
{
jet(%x);
}
function joyLight(%x)
{
commandToServer('light');
}
function joyScrollToolsBack(%x)
{
scrollTools(0-%x);
}
function joyScrollToolsForward(%x)
{
scrollTools(%x);
}
function joyJump(%x)
{
jump(%x);
}
function joyToggleRTB(%x)
{
if(%x)
RTB_ToggleOverlay();
}
function joyCrouch(%x)
{
if(%x)
crouch($CrouchTog = !$CrouchTog);
}
function joySetup(%x)
{
if(%x)
{
$JSSetup = !$JSSetup;
if($JSSetup)
{
cancel($JoystickYawSched);
cancel($JoyStickPitchSched);
joySetupXY();
newChatHud_Addline("Enabling Setup");
JoyStickRing.setVisible(1);
}
else
{
cancel($JoystickSetupXY);
applyJoyPitch();
applyJoyYaw();
newChatHud_AddLine("Disabling Setup.");
JoyStickRing.setVisible(0);
}
}
}
function joyMF2(%x)
{
moveForward(%x);
}
function joyMB2(%x)
{
moveBackward(%x);
}
function joySetupXY(%count, %mode)
{
cancel($JoystickSetupXY);
%y = $JoystickYaw;
%x = $JoystickPitch;
%xPos = %x+1;
%yPos = %y+1;
joyStickTarget.resize((%yPos*128)-16, (%xPos*128)-16, 32, 32);
if(%x >= 0.75 && %y >= 0.75)//BottomRight
{
if(%mode $= "BR")
%count++;
else
%count = 0;
if(%count >= 30)
{
newChatHud_AddLine("Applying Racing Setup....");
%count = 0;
moveMap.bind(JoyStick0, "button0", "joyToggleFirstPerson");//Triangle
moveMap.bind(JoyStick0, "button1", "joyMF2");//X
moveMap.bind(JoyStick0, "button2", "joyJump");//Circle
moveMap.bind(JoyStick0, "button3", "joyMB2");//Square
moveMap.bind(JoyStick0, "button4", "joyMousefire");//L1
moveMap.bind(JoyStick0, "button5", "joySprayCan");//R1
moveMap.bind(JoyStick0, "button6", "");//L2
moveMap.bind(JoyStick0, "button7", "");//R2
moveMap.bind(JoyStick0, "button8", "JoyTM");//Select
moveMap.bind(JoyStick0, "button9", "joySetup");//Pause - Currently not made, planning to create a Circle, in which you move the brown townog stick in, and you will select that letter, and it adds to the Chat Box.
moveMap.bind(JoyStick0, "button10", "joyJet");//L3
moveMap.bind(JoyStick0, "button11", "joyCrouch");//R3
moveMap.bind(JoyStick0, "button12", "joyToggleRTB");//Home - Planning to make this compatible with the above chat function.
newChatHud_AddLine("Triangle: Toggle 1st/3rd Person, X: Move Foward, Circle: Brakes (Jump), Square: Move Backward, L1: Mouse Fire, R1: Use Spray Can, L2: Unmapped, R2: Unmapped, L3: Jet, R3: Crouch");
newChatHud_AddLine("Left Stick: Moves Camera, Right Stick: Moves Character.");
moveMap.bind(JoyStick0, "xaxis", "yawJoy");
moveMap.bind(JoyStick0, "yaxis", "pitchJoy");
moveMap.bind(JoyStick0, "zaxis", "joyZAxis");
moveMap.bind(JoyStick0, "rzaxis", "joyRZAxis");
}
%mode = "BR";
}
if(%x >= 0.8 && %y <= 0.25 && %y >= -0.25)
{
if(%mode $= "B")
%count++;
else
%count = 0;
if(%count >= 30)
{
newChatHud_AddLine("Applying Standard Setup....");
%count = 0;
moveMap.bind(JoyStick0, "zaxis", "yawJoy");
moveMap.bind(JoyStick0, "rzaxis", "pitchJoy");
moveMap.bind(JoyStick0, "xaxis", "joyZAxis");
moveMap.bind(JoyStick0, "yaxis", "joyRZAxis");
moveMap.bind(JoyStick0, "button0", "joyToggleFirstPerson");//Triangle
moveMap.bind(JoyStick0, "button1", "joyMousefire");//X
moveMap.bind(JoyStick0, "button2", "joyJump");//Circle
moveMap.bind(JoyStick0, "button3", "joyLight");//Square
moveMap.bind(JoyStick0, "button4", "joyToggleZoom");//L1
moveMap.bind(JoyStick0, "button5", "joyScrollTools");//R1
moveMap.bind(JoyStick0, "button6", "joyScrollToolsBack");//L2
moveMap.bind(JoyStick0, "button7", "joyScrollToolsForward");//R2
moveMap.bind(JoyStick0, "button8", "JoyTM");//Select
moveMap.bind(JoyStick0, "button9", "joySetup");//Pause - Currently not made, planning to create a Circle, in which you move the brown townog stick in, and you will select that letter, and it adds to the Chat Box.
moveMap.bind(JoyStick0, "button10", "joyJet");//L3
moveMap.bind(JoyStick0, "button11", "joyCrouch");//R3
moveMap.bind(JoyStick0, "button12", "joyToggleRTB");//Home - Planning to make this compatible with the above chat function.
newChatHud_AddLine("Triangle: Toggle 1st/3rd Person, X: MouseFire, Circle: Jump, Square: Light, L1: Zoom, R1: Items, L2: ScrollTools Back, R2: ScrollTools Forward, L3: Jet, R3: Crouch");
newChatHud_AddLine("Left Stick: Move Character, Right Stick: Move Camera");
}
%mode = "B";
}
if(%x <= 0.1 && %x >= -0.1 && %y <= 0.1 && %y >= -0.1)//center
{
%mode = "";
%count = 0;
}
// centerPrint(findClientbyname(Pah), %mode SPC %count, 1);
// bottomPrint(findClientbyname(Pah), %x SPC %y);
$JoystickSetupXY = schedule(100,0,JoySetupXY,%count,%mode);
}
function joySpraycan(%x)
{
useSprayCan(%x);
}
function enableJoyStickSetup()
{
enableJoystick();
moveMap.bind(JoyStick0, "zaxis", "yawJoy");
moveMap.bind(JoyStick0, "rzaxis", "pitchJoy");
moveMap.bind(JoyStick0, "xaxis", "joyZAxis");
moveMap.bind(JoyStick0, "yaxis", "joyRZAxis");


moveMap.bind(JoyStick0, "button0", "joyToggleFirstPerson");//Triangle
moveMap.bind(JoyStick0, "button1", "joyMousefire");//X
moveMap.bind(JoyStick0, "button2", "joyJump");//Circle
moveMap.bind(JoyStick0, "button3", "joyLight");//Square
moveMap.bind(JoyStick0, "button4", "joyToggleZoom");//L1

moveMap.bind(JoyStick0, "button5", "joyScrollTools");//R1
moveMap.bind(JoyStick0, "button6", "joyScrollToolsBack");//L2
moveMap.bind(JoyStick0, "button7", "joyScrollToolsForward");//R2
moveMap.bind(JoyStick0, "button8", "JoyTM");//Select
moveMap.bind(JoyStick0, "button9", "joySetup");//Pause - Currently not made, planning to create a Circle, in which you move the brown townog stick in, and you will select that letter, and it adds to the Chat Box.
moveMap.bind(JoyStick0, "button10", "joyJet");//L3
moveMap.bind(JoyStick0, "button11", "joyCrouch");//R3
moveMap.bind(JoyStick0, "button12", "joyToggleRTB");//Home - Planning to make this compatible with the above chat function.
}
};
activatePackage("JoyFunctions");
applyJoyPitch();
applyJoyYaw();

//GamePad: AfterGlow PS3
//moveMap.bind(JoyStick0, "xaxis", "yawJoy");
//moveMap.bind(JoyStick0, "yaxis", "pitchJoy");
//moveMap.bind(JoyStick0, "zaxis", "joyZAxis");
//moveMap.bind(JoyStick0, "rzaxis", "joyRZAxis");
moveMap.bind(JoyStick0, "zaxis", "yawJoy");
moveMap.bind(JoyStick0, "rzaxis", "pitchJoy");
moveMap.bind(JoyStick0, "xaxis", "joyZAxis");
moveMap.bind(JoyStick0, "yaxis", "joyRZAxis");


moveMap.bind(JoyStick0, "button0", "joyToggleFirstPerson");//Triangle
moveMap.bind(JoyStick0, "button1", "joyMousefire");//X
moveMap.bind(JoyStick0, "button2", "joyJump");//Circle
moveMap.bind(JoyStick0, "button3", "joyLight");//Square
moveMap.bind(JoyStick0, "button4", "joyToggleZoom");//L1

moveMap.bind(JoyStick0, "button5", "joyScrollTools");//R1
moveMap.bind(JoyStick0, "button6", "joyScrollToolsBack");//L2
moveMap.bind(JoyStick0, "button7", "joyScrollToolsForward");//R2
moveMap.bind(JoyStick0, "button8", "JoyTM");//Select
moveMap.bind(JoyStick0, "button9", "joySetup");//Pause - Currently not made, planning to create a Circle, in which you move the brown townog stick in, and you will select that letter, and it adds to the Chat Box.
moveMap.bind(JoyStick0, "button10", "joyJet");//L3
moveMap.bind(JoyStick0, "button11", "joyCrouch");//R3
moveMap.bind(JoyStick0, "button12", "joyToggleRTB");//Home - Planning to make this compatible with the above chat function.
new GuiBitmapCtrl(JoyStickRing) {
profile = "GuiDefaultProfile";
horizSizing = "center";
vertSizing = "center";
position = "0 0";
extent = "256 256";
minExtent = "256 256";
enabled = 1;
visible = 0;
clipToParent = 1;
wrap = 0;
lockAspectRatio = 1;
alignLeft = 0;
alignTop = 0;
overflowImage = 0;
keepCached = 0;
mColor = "255 255 255 128";
mMultiply = 0;
noCursor = 1;
bitmap = "Add-ons/Client_JoyStick/Images/Ring";
new GuiBitmapCtrl(JoyStickTarget) {
profile = "GuiDefaultProfile";
horizSizing = "center";
vertSizing = "center";
position = "0 0";
extent = "8 8";
minExtent = "8 8";
enabled = 1;
visible = 1;
clipToParent = 1;
wrap = 0;
lockAspectRatio = 1;
alignLeft = 0;
alignTop = 0;
overflowImage = 0;
keepCached = 0;
mColor = "255 255 255 255";
mMultiply = 0;
noCursor = 1;
bitmap = "base/client/ui/crosshair";
};
};
playGui.add(JoyStickRing);
JoyStickRing.center();
I am planning to work on a chat function, that works similar to the different modes.

Pressing start goes into the set up mode, which you can use the right brown townog stick (Left in racer mode) to change the modes, which down is standard, and bottom right is racer.