Custom Steering Input Device
by Metallica · in Torque Game Engine · 01/26/2006 (1:27 am) · 1 replies
Hi,
I have a custom input device which is a steering that is connected to PC using USB. The values that I get range from -1.0000 to 1.0000 which -the left-most and right-most steering position respectively.
Okay so far it works to certain extent. I know my solution is crux, and I am sure there must be other ways to add an input device...
Briefly here is what I had done:
Create a class named SteeringDevice which has a member function named Init and Process..
Within the file main.cc (in \engine\game), I inserted a class variables and within the loop, i call the member function process.
The code in main.cc look something like below:-
SteeringDevice steering;
steering.Init();
while(Game->isRunning())
{
steering.Process();
PROFILE_START(MainLoop);
PROFILE_START(JournalMain);
...
...
}
and the code in the Process member function basically will retrieve the steering position, and then modify the variables
-MoveManager::mYawRightSpeed
-MoveManager::mYawLeftSpeed
So far it is a bit unsuccesful because the steering behaves strangely in a way hard to describe here - you have to see it yourself to understand it.
So the question is
1) What is the proper way to control the steering position?
2) How to translate from the reading from steering of -1.0000 to 1.0000 to something Torque can understand. My code for steering translation was not very succesful:-
if (old_pos > current_pos ) {
// meaning turn to left
// so adjust the yaw right..
Con::printf("Turn to left... value = %8.4f\n", old-current_pos);
MoveManager::mYawRightSpeed = (old_pos-current_pos)*4;
MoveManager::mYawLeftSpeed = -(old_pos-current_pos)*4;
} else {
// turn to right
// so adjust the yaw left..
Con::printf("Turn to right... value = %8.4f\n", old-m_current_pos);
MoveManager::mYawLeftSpeed = (current_pos-old_pos)*4;
MoveManager::mYawRightSpeed = -(current_pos-old_pos)*4;
}
Thanks for all replies.
I have a custom input device which is a steering that is connected to PC using USB. The values that I get range from -1.0000 to 1.0000 which -the left-most and right-most steering position respectively.
Okay so far it works to certain extent. I know my solution is crux, and I am sure there must be other ways to add an input device...
Briefly here is what I had done:
Create a class named SteeringDevice which has a member function named Init and Process..
Within the file main.cc (in \engine\game), I inserted a class variables and within the loop, i call the member function process.
The code in main.cc look something like below:-
SteeringDevice steering;
steering.Init();
while(Game->isRunning())
{
steering.Process();
PROFILE_START(MainLoop);
PROFILE_START(JournalMain);
...
...
}
and the code in the Process member function basically will retrieve the steering position, and then modify the variables
-MoveManager::mYawRightSpeed
-MoveManager::mYawLeftSpeed
So far it is a bit unsuccesful because the steering behaves strangely in a way hard to describe here - you have to see it yourself to understand it.
So the question is
1) What is the proper way to control the steering position?
2) How to translate from the reading from steering of -1.0000 to 1.0000 to something Torque can understand. My code for steering translation was not very succesful:-
if (old_pos > current_pos ) {
// meaning turn to left
// so adjust the yaw right..
Con::printf("Turn to left... value = %8.4f\n", old-current_pos);
MoveManager::mYawRightSpeed = (old_pos-current_pos)*4;
MoveManager::mYawLeftSpeed = -(old_pos-current_pos)*4;
} else {
// turn to right
// so adjust the yaw left..
Con::printf("Turn to right... value = %8.4f\n", old-m_current_pos);
MoveManager::mYawLeftSpeed = (current_pos-old_pos)*4;
MoveManager::mYawRightSpeed = -(current_pos-old_pos)*4;
}
Thanks for all replies.
Torque Owner Bruno Grieco
Don't know if it will help you.