Game Development Community

How to add a new serial port device support to Torque?

by Corin · in Hardware Issues · 04/19/2005 (2:32 am) · 10 replies


#1
04/19/2005 (2:32 am)
Just an idea, but what I would do is look into the game pad/joystick resources, see if you can get some info on ports and whatnot from them....

Max
#2
04/19/2005 (3:58 am)
Hey,

Just read your post again, Yeah, I understand you more clearly now, I know that there are some keyboards out there with serial port cables, I assume torque would support those, so you could take a look through the SDK and see if you can find if there is such a think like that for keyboards, and if so then see how it works and try and get it workin with the correct port number for your device....


Just an idea, Max
#3
04/19/2005 (4:58 am)
I'd recommend to create an application (apart from TGE, standalone) that translates the movements of the bike to mouse movements. This way you have more control about what happens and you don't have to change Torque.
#4
04/19/2005 (5:27 am)
AFAIK, there is nothing in the engine which is meant for talking with serial ports, however if you took a serial to USB converter and attached it, then you might be able to use the Joystick resources.
#5
04/19/2005 (6:14 am)
What Dreamer said... Lol

But the average joystick has some hard coded chips in it, we don't know much about this bike thats being used... SO, we shall see...


Max
#6
04/19/2005 (6:36 am)
You own the SDK, post this in those forums.. More people will respond, I'm sure, and be able to share code. This forum is for general discussions.

- Brett
#7
04/19/2005 (9:05 pm)
Don't implement this in Torque. Implement it in a platform-independent way, so that it works with Linux and Mac and any new supported platform. You might start by looking at how to implement it using libSDL, which is a platform-independent layer just for this kind of thing.

The fact that it's connected by serial port is really not that important. All the OS's have reasonable serial port abstractions so SDL should already know how to deal with that.
#8
04/20/2005 (1:12 am)
I haven't looked into the bowels of SDL to see how it's organized, but here's some good starting points:

http://www.libsdl.org/

http://www.libsdl.org/faq.php?action=listentries&category=1

http://www.firingsquad.com/features/linuxsdl/

http://www.libsdl.org/cgi/docwiki.cgi/SDL_20API

I would suggest writing a platform-independent part based on abstract events from the device and then implement platform-specific implementation parts that use the native serial port API to interact with the device, get raw data, and covert it into events.

You can probably check the archives of the SDL mailing list or newsgroup to see if someone else has done a serial port input device.
#9
04/20/2005 (10:38 am)
The bike you got there propably has some sort of interface (RS232?) and maybe an SDK or at least an interface description, right? So I assume this interface will check for the velocity of the wheel which has to be translated in forward motion. But what I can see from the picture the handles cannot be turned, so you will have a problem doing the direction. That's why I was wondering how you want to do the steering motion?

Whatever - I would program a very small program first, in C or in Blitz or in PureBasic or the likes that takes the input of the bike on low level and translates it into mouse movement or 'WASD' keys. In the end you should be able to steer a cursor with the bike device in your little test application.

Then you set up your game to be able to use the WASD keys (well, that's the default). Once you've got that you have to make sure that this 'device movement' makes it into torque.

After that you can take care of how to have higher and lower velocities and so on.
#10
04/21/2005 (4:02 am)
Yep, you want to first start by defining the semantics of the input and an API that represents those semantics. Then worry about mapping it to existing input devices, if that's appropriate.