Racing Wheel support?
by Jorge Luis Gandulfo · in Torque 3D Professional · 10/01/2009 (6:58 pm) · 29 replies
I couln't make any Gamepad or Racing wheel to work with T3D.
I didn't looked deeply into it, but enableJoystick() was already active.
Is there any consideration to have in mind to make this work?
Thanks a lot in advance
I didn't looked deeply into it, but enableJoystick() was already active.
Is there any consideration to have in mind to make this work?
Thanks a lot in advance
#22
BindObj() calls the bind'ed command as a method on the object you specify, while bind just calls it as a function. I was saving key mapping information based on the devices' names, so it didn't matter in which USB ports they are plugged, they would get the correct mappings. To do so, I create an ActionMap for each input device, then do the binding based on the prefs for that device name (that way the devices always get the correct mappings, doesn't matter if they're joystick0, joystick1, etc).
But the commands mapped using bind() couldn't identify which ActionMap fired them, and I needed to know because I the positive/negative axis commands were done via script. By using bindObj(), and passing the ActionMap itself as target object, it's possible to know which ActionMap fired the callback and read information specific for that device from it.
10/07/2009 (7:28 pm)
Ah, something that isn't used by any of the Torque demos, but I found insanely useful when writing my own key mapping system: using bindObj() instead of bind(). BindObj() calls the bind'ed command as a method on the object you specify, while bind just calls it as a function. I was saving key mapping information based on the devices' names, so it didn't matter in which USB ports they are plugged, they would get the correct mappings. To do so, I create an ActionMap for each input device, then do the binding based on the prefs for that device name (that way the devices always get the correct mappings, doesn't matter if they're joystick0, joystick1, etc).
But the commands mapped using bind() couldn't identify which ActionMap fired them, and I needed to know because I the positive/negative axis commands were done via script. By using bindObj(), and passing the ActionMap itself as target object, it's possible to know which ActionMap fired the callback and read information specific for that device from it.
#23
I checked the Extensive resource for wheels, but it has the same result in C++ code, it only allowed you to identify joystick from wheels in scripts, something i don't need atm.
So your one line solution worked great.
Now for the scripting side there is some work to do to make the wheel actually move the car as you wish, the axis and stuff don't work as i should want to.
Anybody implemented this already? I'm trying to figure out how to setup the G25 or the Momo with a decent map binding that actually makes the wheels turn as they should, and make the accelerator and brake to work.
10/15/2009 (4:22 pm)
Thanks Again, Manoel.I checked the Extensive resource for wheels, but it has the same result in C++ code, it only allowed you to identify joystick from wheels in scripts, something i don't need atm.
So your one line solution worked great.
Now for the scripting side there is some work to do to make the wheel actually move the car as you wish, the axis and stuff don't work as i should want to.
Anybody implemented this already? I'm trying to figure out how to setup the G25 or the Momo with a decent map binding that actually makes the wheels turn as they should, and make the accelerator and brake to work.
#24
This is the code i´m using atm, obviously this not very good (as my knowledge on the input system is pretty reduced), and is having weird results, but is just an idea so maybe any of you can point this problem out.
Is there a way to point the wheels to a specific spot instead of trying to add a yaw movement, i just want the wheels to point at the same angle as the driving wheel is atm.
Also i can't map the accelerator and break property, anybody know what axis they are handling?
11/03/2009 (11:18 am)
I been having some weird results trying to map a Momo Racing Wheel to drive a wheeled vehicle in T3D.This is the code i´m using atm, obviously this not very good (as my knowledge on the input system is pretty reduced), and is having weird results, but is just an idea so maybe any of you can point this problem out.
Is there a way to point the wheels to a specific spot instead of trying to add a yaw movement, i just want the wheels to point at the same angle as the driving wheel is atm.
Also i can't map the accelerator and break property, anybody know what axis they are handling?
function yaw2(%val)
{
//$mvYaw += getJoystickAdjustmentAmount(%val, $lastYaw);
//$lastYaw = %val;
if (%val != 0)
{
if (%val < 0) //go LEFT
{
if (%val < $lastVal)
{
%offset = %val - $lastVal;
}
else
{
%offset = -($lastVal - %val);
}
}
else //go RIGHT
{
if (%val > $lastVal)
{
%offset = %val - $lastVal;
}
else
{
%offset = -($lastVal - %val);
}
}
$mvYaw = %offset * 2.6;
}
else
{
$mvYaw = 0;
}
$lastVal = %val;
}
moveMap.bind( joystick0, xaxis, yaw2 );
#25
Yeah still waiting on that mythical racing game for Instant Action that they have been working on forever.
11/03/2009 (4:53 pm)
Quote:nicolas said:...
I'm awaiting the Luma Racing Kit impatiently too!
Yeah still waiting on that mythical racing game for Instant Action that they have been working on forever.
#26
$mvYaw is zero'ed every time after it is read. Comment out the last 3 lines and you'll be able to set $mvYaw directly and have it retain its value. Be warned that this will have adverse effects on the editor camera controls, so you might want to do something more complex, like having a global variable that toggles the yaw resetting.
11/04/2009 (9:47 am)
@Jorge: in MoveList::getNextMove(), this is where the yaw/pitch/roll are processed:F32 pitchAdd = MoveManager::mPitchUpSpeed - MoveManager::mPitchDownSpeed; F32 yawAdd = MoveManager::mYawLeftSpeed - MoveManager::mYawRightSpeed; F32 rollAdd = MoveManager::mRollRightSpeed - MoveManager::mRollLeftSpeed; curMove.pitch = MoveManager::mPitch + pitchAdd; curMove.yaw = MoveManager::mYaw + yawAdd; curMove.roll = MoveManager::mRoll + rollAdd; MoveManager::mPitch = 0; MoveManager::mYaw = 0; MoveManager::mRoll = 0;
$mvYaw is zero'ed every time after it is read. Comment out the last 3 lines and you'll be able to set $mvYaw directly and have it retain its value. Be warned that this will have adverse effects on the editor camera controls, so you might want to do something more complex, like having a global variable that toggles the yaw resetting.
#27
for G25 accelerator is yaxis and break is rzaxis
12/02/2009 (4:49 am)
for G25 you could try using joystick example from DirectX SDK locate at "Microsoft DirectX SDK (August 2009)\Samples\C++\DirectInput\Joystick" it will tell you which axis and button g25 are usingfor G25 accelerator is yaxis and break is rzaxis
#29
Old thread but I have a solution, here is what I did to get the steering (in game) to match the steering wheel. Otherwise, mSteering.x was just getting added to. So for instance if you center (0.0) the wheel and the last mSteering.x was .5, it would add .5 + 0.0 instead of setting mSteering.x to 0.
11/13/2010 (7:25 pm)
@JorgeOld thread but I have a solution, here is what I did to get the steering (in game) to match the steering wheel. Otherwise, mSteering.x was just getting added to. So for instance if you center (0.0) the wheel and the last mSteering.x was .5, it would add .5 + 0.0 instead of setting mSteering.x to 0.
F32 y = move->yaw;
mSteering.x = mClampF(mSteering.x + y,-mDataBlock->maxSteeringAngle,
mDataBlock->maxSteeringAngle);
F32 p = move->pitch;
mSteering.y = mClampF(mSteering.y + p,-mDataBlock->maxSteeringAngle,
mDataBlock->maxSteeringAngle);F32 y = move->yaw;
mSteering.x = mClampF(y,-mDataBlock->maxSteeringAngle,
mDataBlock->maxSteeringAngle);
F32 p = move->pitch;
mSteering.y = mClampF(p,-mDataBlock->maxSteeringAngle,
mDataBlock->maxSteeringAngle);
Torque 3D Owner Akiraa