A formal force-feedback API is something I would personally like in SDL
1.3 … this has come up a lot before, but the things that seem to stall
it out are:
- Usually no one has any idea how to make it work on Linux (but that
has probably improved since then).
Things still seem to be moving fairly slowly, although in recent kernel
revisions some improvements have been
made to the force feedback areas of HID. I’ve been talking with some of the
folks involved in developing FF drivers in the past to get an idea of what’s
been done…for some good example code, check out the ff-utils package on
Sourceforge [1]. If you want to check out progress see the linux-input
mailing list archives [2].
My hope is that if there’s a good API, more people will try to use force
feedback in their open source games. This may help generate some more
interest in people testing out the Linux driver support and maybe that will
improve as a result.
- No one involved in SDL development has had a firm grasp of what a
good, cross-platform force feedback API should look like (myself
included).
To be honest I don’t either…however I’ve seen how it’s done in DirectX [3]
(fairly low-level, constructing force effects manually), and also how it was
done by WreckedGames [4] in their object-oriented input system [5] or OIS.
What I think would be best fit for SDL would be something that goes between
these two, and provides high-level routines for common things, as well as
low-level access to the event structures and that type of thing.
By the way, though OIS has stubs for Linux and OS X force feedback code,
only the Windows portion is actually present. This probably gives a better
idea of force feedback API in Windows than the link [3] which is almost 10
years old.
It would probably eventually have to go into SDL itself, since otherwise
it would conflict with SDL’s other joystick functions which would be
competing for control of the devices.
It’s definitely worth exploring further.
So far as I’ve seen (for instance with ff-utils) the devices used are not
joystick devices but event devices, like /dev/input/eventXX (although SDL
may use these as well, I don’t know). I think it can be made to work
alongside SDL; using this method in VDrift seems to be no problem. However
I’m not sure exactly how the devices are structured in Windows…On 3/4/07, Ryan C. Gordon wrote:
On 3/5/07, Torsten Giebl wrote:
I have never coded a game that uses force feedback.
What is the way to programm it ? What are you able
to do with a force feedback device like the PSX 1 Pad.
Can you just say both pad motors 40% or is there more
you can do ?
Well in the case of VDrift (all the force feedback coding I’ve done) it’s a
matter of calculating the force that the wheel should output, and then
sending the force to the device at a certain rate. To send the force one
must construct a force feedback effect structure telling what kind of force
effect, the different parameters available, etc., then uploading it to the
device. Uploading doesn’t start playback, most devices have a cache that can
hold a few effects which can be played later…but in our case we just
upload the effect and play it right away, since it’s real-time steering
feedback.
That’s more of the low-level way of doing things, a good high-level API
should provide things like what you describe, or in the case of VDrift, it
would be a matter of calling a function to play a constant force effect at a
given value.
Chris
[1]
http://sourceforge.net/project/showfiles.php?group_id=44724&package_id=98791
[2] http://www.mail-archive.com/linux-input at atrey.karlin.mff.cuni.cz/
[3] http://www.microsoft.com/msj/0298/force.aspx
[4] http://www.wreckedgames.com/
[5] http://www.wreckedgames.com/wiki/index.php/WreckedLibs:OIS