Gamepad Buttons Can torque tell me what i'm pressing?
by Cinder Games · in Torque Game Engine · 07/11/2005 (12:51 pm) · 15 replies
I'm binding some functions to some button presses... however, i haven't a clue what some of the buttons might be calling themselves, in addition to that, i haven't a clue how to figure out if the analog sticks are being used.
example code..... torque understand button0 and what not just fine... but what about my POV hat? I don't know what torque will call that.
Since i can't map this with the options panel, i'd like to figure out how to actually use one of the gamepads.
GlobalActionMap.bindCmd( joystick, button0, "buttonPress(1);", "buttonUnPress(1);" ); GlobalActionMap.bindCmd( joystick, button1, "buttonPress(2);", "buttonUnPress(2);" );
example code..... torque understand button0 and what not just fine... but what about my POV hat? I don't know what torque will call that.
Since i can't map this with the options panel, i'd like to figure out how to actually use one of the gamepads.
#2
wow, that crashes torque when it loads a level.
07/11/2005 (3:29 pm)
GlobalActionMap.bindCmd( joystick, xaxis, "echo(boom);", "echo(boom);" );
wow, that crashes torque when it loads a level.
#3
07/11/2005 (4:37 pm)
You'll want to do something likeGlobalActionMap.bind( joystick, xaxis, "xaxis(%val);");
#4
that just says unknown command echo()
maybe i just don't get how to use it for the axis' commands. with that last example. it's calling a function xaxis? and sending the variable %val? where's it getting val from?
07/12/2005 (2:16 am)
GlobalActionMap.bind( joystick, xaxis, "echo();");that just says unknown command echo()
maybe i just don't get how to use it for the axis' commands. with that last example. it's calling a function xaxis? and sending the variable %val? where's it getting val from?
#5
Sorry, I should have been a bit more specific.
The following do forward/backward and left/right using the left stick.
The following settings are in client/prefs.cs and can be adjusted to suit
edit: formatting
07/12/2005 (6:47 am)
RamenSorry, I should have been a bit more specific.
The following do forward/backward and left/right using the left stick.
moveMap.bind(joystick, "xaxis", joymovex);
moveMap.bind(joystick, "yaxis", joymovey);
function joymovex(%val)
{
if ($pref::Input::Deadzone < %val | - $pref::Input::Deadzone > %val)
{
$mvRightAction = %val * $pref::Input::Sensitivity;
}
else
{
$mvRightAction = 0;
}
}
function joymovey(%val)
{
if ($pref::Input::Deadzone < %val | - $pref::Input::Deadzone > %val)
{
$mvBackwardAction = %val * $pref::Input::Sensitivity;
}
else
{
$mvBackwardAction = 0;
}
}The following settings are in client/prefs.cs and can be adjusted to suit
$pref::Input::Deadzone = 0.25; $pref::Input::Sensitivity = 1;
edit: formatting
#6
I'll fiddle with that in a few, but i tried using upov, but it didn't seem to register, maybe they're treated differently then a button.. is the POV treated like an axis of some kind?
07/12/2005 (7:24 am)
Great thanks! I'll fiddle with that in a few, but i tried using upov, but it didn't seem to register, maybe they're treated differently then a button.. is the POV treated like an axis of some kind?
#7
This is what I have on left and right pov at the moment (switching weapons) :
For up and down, I am calling another function via the bind (which sets up smooth zoom in and out in the code I have written) :
Most of the gamepad stuff I did was by trial and error with some searching through the source for button names.
Just a final thought - these 2 settings are in client/prefs.cs as well :
07/12/2005 (9:14 am)
I use the pov as buttons (I have never tested the values though so it may actually be passing something else).This is what I have on left and right pov at the moment (switching weapons) :
moveMap.bind(joystick, lpov, joyleft );
moveMap.bind(joystick, rpov, joyright );
function joyleft(%val)
{
%weapon="Shotgun";
commandToServer('use',%Weapon);
}
function joyright(%val)
{
%weapon="Assaultrifle";
commandToServer('use', %weapon);
}For up and down, I am calling another function via the bind (which sets up smooth zoom in and out in the code I have written) :
moveMap.bind(joystick, upov, joyup );
moveMap.bind(joystick, dpov, joydown );
function joyup(%val)
{
setjoyzoomin(%val);
}
function joydown(%val)
{
setjoyzoomout(%val);
}Most of the gamepad stuff I did was by trial and error with some searching through the source for button names.
Just a final thought - these 2 settings are in client/prefs.cs as well :
$pref::Input::GamepadEnabled = "1"; $pref::Input::JoystickEnabled = "1";
#8
thanks the x and y axis' work as they should! But i don't understand the %val part. the function is looking for it, but where is %val coming from? it's not being sent by the bind setup?
also POV refuses to work. Which i knew for sure what torque is seeing it as. windows says it's a POV hat.
But i wish i could setup a function, press a button and torque just tell me what the button is.
Can you bind any buttons via the customize controls GUI? i can't.
07/13/2005 (5:04 am)
@davidthanks the x and y axis' work as they should! But i don't understand the %val part. the function is looking for it, but where is %val coming from? it's not being sent by the bind setup?
also POV refuses to work. Which i knew for sure what torque is seeing it as. windows says it's a POV hat.
But i wish i could setup a function, press a button and torque just tell me what the button is.
Can you bind any buttons via the customize controls GUI? i can't.
#9
ah well here's some clues. this is from actionmap.cc
i guess i'll try all of them till one registers :)
07/13/2005 (5:23 am)
//-------------------------------------- BUTTON EVENTS
// Joystick/Mouse buttons
{ "button0", SI_BUTTON, KEY_BUTTON0 },
{ "button1", SI_BUTTON, KEY_BUTTON1 },
{ "button2", SI_BUTTON, KEY_BUTTON2 },
{ "button3", SI_BUTTON, KEY_BUTTON3 },
{ "button4", SI_BUTTON, KEY_BUTTON4 },
{ "button5", SI_BUTTON, KEY_BUTTON5 },
{ "button6", SI_BUTTON, KEY_BUTTON6 },
{ "button7", SI_BUTTON, KEY_BUTTON7 },
{ "button8", SI_BUTTON, KEY_BUTTON8 },
{ "button9", SI_BUTTON, KEY_BUTTON9 },
{ "button10", SI_BUTTON, KEY_BUTTON10 },
{ "button11", SI_BUTTON, KEY_BUTTON11 },
{ "button12", SI_BUTTON, KEY_BUTTON12 },
{ "button13", SI_BUTTON, KEY_BUTTON13 },
{ "button14", SI_BUTTON, KEY_BUTTON14 },
{ "button15", SI_BUTTON, KEY_BUTTON15 },
{ "button16", SI_BUTTON, KEY_BUTTON16 },
{ "button17", SI_BUTTON, KEY_BUTTON17 },
{ "button18", SI_BUTTON, KEY_BUTTON18 },
{ "button19", SI_BUTTON, KEY_BUTTON19 },
{ "button20", SI_BUTTON, KEY_BUTTON20 },
{ "button21", SI_BUTTON, KEY_BUTTON21 },
{ "button22", SI_BUTTON, KEY_BUTTON22 },
{ "button23", SI_BUTTON, KEY_BUTTON23 },
{ "button24", SI_BUTTON, KEY_BUTTON24 },
{ "button25", SI_BUTTON, KEY_BUTTON25 },
{ "button26", SI_BUTTON, KEY_BUTTON26 },
{ "button27", SI_BUTTON, KEY_BUTTON27 },
{ "button28", SI_BUTTON, KEY_BUTTON28 },
{ "button29", SI_BUTTON, KEY_BUTTON29 },
{ "button30", SI_BUTTON, KEY_BUTTON30 },
{ "button31", SI_BUTTON, KEY_BUTTON31 },
//-------------------------------------- MOVE EVENTS
// Mouse/Joystick axes:
{ "xaxis", SI_MOVE, SI_XAXIS },
{ "yaxis", SI_MOVE, SI_YAXIS },
{ "zaxis", SI_MOVE, SI_ZAXIS },
{ "rxaxis", SI_MOVE, SI_RXAXIS },
{ "ryaxis", SI_MOVE, SI_RYAXIS },
{ "rzaxis", SI_MOVE, SI_RZAXIS },
{ "slider", SI_MOVE, SI_SLIDER },
//-------------------------------------- POV EVENTS
// Joystick POV:
{ "xpov", SI_POV, SI_XPOV },
{ "ypov", SI_POV, SI_YPOV },
{ "upov", SI_POV, SI_UPOV },
{ "dpov", SI_POV, SI_DPOV },
{ "lpov", SI_POV, SI_LPOV },
{ "rpov", SI_POV, SI_RPOV },
{ "xpov2", SI_POV, SI_XPOV2 },
{ "ypov2", SI_POV, SI_YPOV2 },
{ "upov2", SI_POV, SI_UPOV2 },
{ "dpov2", SI_POV, SI_DPOV2 },
{ "lpov2", SI_POV, SI_LPOV2 },
{ "rpov2", SI_POV, SI_RPOV2 },ah well here's some clues. this is from actionmap.cc
i guess i'll try all of them till one registers :)
#10
07/13/2005 (5:58 am)
Hmmm i forgot i had copied over one of them "add gamepad support" resources awhile back. i put back in the original torque files and it did register the pov when i pressed on it. so i'll experiment more and see. But i'd still like the questions about %val and what not explained :)
#11
%val is sent based upon the type of input.
For keys: val is 1 when pressed and 0 when released. Each time a key is pressed and released, the binding is called only twice, not continuously.
For mouse/joystick: val is the amount of movement. You can alter the controls to take the amount of movement into consideration.
HIH
07/13/2005 (6:15 am)
Ramen,%val is sent based upon the type of input.
For keys: val is 1 when pressed and 0 when released. Each time a key is pressed and released, the binding is called only twice, not continuously.
For mouse/joystick: val is the amount of movement. You can alter the controls to take the amount of movement into consideration.
HIH
#12
There really needs to be some way to make resources as "obsolute" or "broken" so people know they don't need to use them.
07/13/2005 (6:21 am)
Oh good. again, i was using that other resource, and %val wasn't coming thru it is now.There really needs to be some way to make resources as "obsolute" or "broken" so people know they don't need to use them.
#13
07/13/2005 (6:24 am)
Well, why i have this thread, anyone know how to get the use joystick/gamepads for the title screens? they don't "work" till you load up a mission.
#14
anything im missing here? thanks
08/03/2005 (4:30 pm)
Oddly my right analog stick isn't working - i used the rxaxis and ryaxis. the right stick responds when calibrating the gamepad in windows and the left stick works moving the guy in torque.anything im missing here? thanks
Torque Owner David Barr
Viola Interactive Ltd
For the pov names try upov, dpov, lpov and rpov (up, down, left, right)
For the sticks names, try xaxis, yaxis, zaxis and rzaxis.