Force feedback SDL lib

Hi SDL folks! I’m a developer on the VDrift project [1] and recently we’ve
added simple force feedback support to the game under Linux (there’s an
ongoing discussion on the forums [2] if you’re interested). This code is
still at the very early stages, and I think it’d be ideal to abstract all
the force feedback stuff into a library, instead of having
low-level, platform-specific code in the game.

Of course I think the best way to achieve this would be to integrate force
feedback support into SDL somehow. It could become part of the core of SDL,
or a separate, SDL-compatible library. I think the latter idea is probably
better. However before I start any of this I wanted to hear what all of you
have to say about it.

I’ve never developed an SDL lib before, nor have I looked much at the SDL
source code. Is there any documentation available that might give me an idea
of where to start with writing an SDL lib? I have looked but not really
found any. Soon I’ll start looking through the source code both for SDL and
related libraries to see how they work, and are structured internally. The
joystick code will be one part I look very carefully at.
Any suggestions on other things I should check out?

I don’t currently have access to any OS X machines, and know almost nothing
about the operating system, unfortunately. As far as I understand, there is
little to no force feedback driver support on this platform, so having
complete cross-platform compatibility may not be immediately possible.

Let me know what you all think about all of this. Hopefully I’ll be able to
get started on coding something pretty soon.

Chris Guirl

[1] http://vdrift.net/
[2] http://vdrift.net/Forum/viewtopic.php?t=541

Of course I think the best way to achieve this would be to integrate
force feedback support into SDL somehow. It could become part of the
core of SDL, or a separate, SDL-compatible library. I think the latter
idea is probably better. However before I start any of this I wanted to
hear what all of you have to say about it.

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:

  1. Usually no one has any idea how to make it work on Linux (but that
    has probably improved since then).
  2. 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).

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.

–ryan.

Hello !

Hi SDL folks! I’m a developer on the VDrift project [1] and recently we’ve
added simple force feedback support to the game under Linux (there’s an
ongoing discussion on the forums [2] if you’re interested). This code is
still at the very early stages, and I think it’d be ideal to abstract all
the force feedback stuff into a library, instead of having low-level,
platform-specific code in the game.

Of course I think the best way to achieve this would be to integrate force
feedback support into SDL somehow. It could become part of the core of SDL,
or a separate, SDL-compatible library. I think the latter idea is probably
better. However before I start any of this I wanted to hear what all of you
have to say about it.

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 ?

CU

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:

  1. 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.

  1. 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

[1]
http://sourceforge.net/project/showfiles.php?group_id=44724&package_id=98791
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
http://www.microsoft.com/msj/0298/force.aspx
[4] http://www.wreckedgames.com/
[5] http://www.wreckedgames.com/wiki/index.php/WreckedLibs:OIS
http://www.wreckedgames.com/wiki/index.php/WreckedLibs:OIS

This was a good pile of info, thanks for posting this!

–ryan.

No problem, glad you found the links useful. Most of them were passed to me
by other people…

Johann Deneux reports a new wiki on force feedback up at libff.sf.net [1].
Also since posting here last, I found out about Gforce [2] which looks
useful for testing force effects. I haven’t played around with it yet. It
looks old (gtk1.2) and the last update on that page was in 2002, so I’m sure
it could use some updating.

Chris

[1] http://libff.sourceforge.net/
[2] http://madfab.free.fr/ff/On 3/5/07, Ryan C. Gordon wrote:

This was a good pile of info, thanks for posting this!

I just found out that OS X does support force feedback [1] since version
10.2.3, using Immersion’s API. There’s some OS X sample code on Immersion’s
site [2] (the first two entries on the page).

Chris

[1] http://www.macworld.com/news/2002/12/20/immersion/index.php
[2] http://www.immersion.com/developer/technology/sampleCode/index.phpOn 3/10/07, chris guirl <@chris_guirl> wrote:

On 3/5/07, Ryan C. Gordon wrote:

This was a good pile of info, thanks for posting this!

No problem, glad you found the links useful. Most of them were passed to
me by other people…

Johann Deneux reports a new wiki on force feedback up at libff.sf.net [1].
Also since posting here last, I found out about Gforce [2] which looks
useful for testing force effects. I haven’t played around with it yet. It
looks old (gtk1.2) and the last update on that page was in 2002, so I’m
sure it could use some updating.

Chris

[1] http://libff.sourceforge.net/
[2] http://madfab.free.fr/ff/