Joysticks in T2D?
by C. N. · in Torque Game Builder · 09/07/2005 (9:05 pm) · 4 replies
Hi,
I was just wondering if anyone is using a gamepad for input in their T2D projects? Is there any documentation regarding setting up gamepads in T2D?
Thanks for any suggestions.
I was just wondering if anyone is using a gamepad for input in their T2D projects? Is there any documentation regarding setting up gamepads in T2D?
Thanks for any suggestions.
#2
However, the axis for joysticks need just a regular bind command:
Where joystickx_processor is:
Buttons work just like keyboard keys, except they are called button0 thru buttonX (32 on DirectX I believe).
To get this to work, however, you will need to enable the DirectX joystick handler (under Windows). IIRC, this is done with this prefs.cs entry:
But that doesn't seem right -- I believe there is something else that needs to be done. I'm just typing this from memory, however.
On the Mac, there is no joystick driver at all present in the Torque code. Someone needs to write a HID input device interface on the Mac side. :)
09/08/2005 (4:18 pm)
OotB (out of the box) joysticks work in Torque. Use the axis names as Chunky pointed out. However, remember that they work differently than buttons. Normally you use bindcmd's which call the event when a button is pressed and released, ergo:controlmap.bindcmd (keyboard, "alt z", "calledOnMake();", "calledOnBreak();") ;
However, the axis for joysticks need just a regular bind command:
controlmap.bind (joystick0, "xaxis", joystickx_processor) ;
Where joystickx_processor is:
function joystickx_processor (%val)
{
// %val will be from -1.0 to 1.0, indicating which way the joystick is currently moving
if (%val < -0.5)
{
do_leftmove() ;
} else if (%val > 0.5)
{
do_rightmove() ;
}
}Buttons work just like keyboard keys, except they are called button0 thru buttonX (32 on DirectX I believe).
To get this to work, however, you will need to enable the DirectX joystick handler (under Windows). IIRC, this is done with this prefs.cs entry:
$pref::Input::JoystickEnabled = "1";
But that doesn't seem right -- I believe there is something else that needs to be done. I'm just typing this from memory, however.
On the Mac, there is no joystick driver at all present in the Torque code. Someone needs to write a HID input device interface on the Mac side. :)
#3
I don't have the slightest clue about programming for Mac's... but I know SDL (an API I've been using for years) has great Mac support, so I'm guessing it shouldn't be too hard to get joystick input running on a Mac (does the Mac version of Torque use SDL, like the Linux version?).
09/08/2005 (10:57 pm)
Thanks, I'm gonna give that a try. Joysticks really add a lot to games, eh?I don't have the slightest clue about programming for Mac's... but I know SDL (an API I've been using for years) has great Mac support, so I'm guessing it shouldn't be too hard to get joystick input running on a Mac (does the Mac version of Torque use SDL, like the Linux version?).
#4
There is also nascent HID code out there if one is brave enough. I really wasn't :) Not sure about using SDL support though.
09/09/2005 (8:26 am)
On the Mac, a user can alternatively use GamePad Companion to assign keys to devices. Not ideal, but works. Analog/Mouse emulation isn't the greatest from what I've found though.There is also nascent HID code out there if one is brave enough. I really wasn't :) Not sure about using SDL support though.
Torque Owner Gary "ChunkyKs" Briggs
On linux, it magically worked really easily for me [once I read the source to find out the axis names are xaxis,yaxis,zaxis,rxaxis,ryaxis,rzaxis]
On windows, no idea.
Gary (-;