Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linux force feedback wheel support
02-21-2007, 07:08 AM
Post: #1
Linux force feedback wheel support
I've just finished coding something that I think should work for force feedback in Linux for VDrift. If you have a working force feedback device please try it out.

Prerequisites:
* a steering wheel supporting constant force effects (like my Logitech Momo Racing force feedback steering wheel)
* Linux
* HID_FF is enabled in your kernel
* your device's USB ID is in kernel-source/drivers/usb/input/hid-ff.c
* the ff-utils test program ffcfstress works for you. Note the device name you use with this program (should be /dev/input/eventX).
* VDrift SVN r1547 or later

Once you've met the prereqs, now recompile vdrift like this:
Code:
scons force_feedback=1

Now open your VDrift.config. Find the section [ joystick ] and add the following line to the joystick section somewhere:
Code:
ff_device = /dev/input/event0
change event0 to whatever device you should use (the one that worked with ffcfstress).

Start up VDrift. Start a practice game. You should feel a force effect on your steering wheel based on the aligning moment force from the front tires.


The code is adapted from the ffcfstress program into a class which is initialized by VAMOSWORLD. I only added support for Linux now but adding Windows support should be easy, since the driver support there is much better. I'm not sure what to do about OS X or FreeBSD...

I haven't tested it yet. It took me a while to test out force-feedback at all, and after I found it worked, coding the force feedback class was easy. However something is broken with my NVIDIA driver; since I had to compile a custom kernel to enable HID_FF in Ubuntu, I've had to recompile the NVIDIA driver, and while X starts OK, I get "Couldn't find matching GLX visual" errors when trying to run 3D apps...anyway I'm pretty sure that the force-feedback support should work. Somebody please give it a try and let me know how it goes.

Thanks to stenyak and jdeneux for help figuring out how to set this up, and also to Oliver Hamann who wrote the ffcfstress program.
Visit this user's website Find all posts by this user
Quote this message in a reply
02-21-2007, 01:48 PM
Post: #2
Re: Linux force feedback wheel support
I think your 3D error is because when you compile the driver it installs the NVidia libs in your old kernel's modules directory... something like that
check /var/log/nvidia-installer.log
Find all posts by this user
Quote this message in a reply
02-21-2007, 08:16 PM
Post: #3
 
I've gone back and forth trying different things to get NVIDIA drivers to work correctly. Finally I reverted to an older driver which works fine. Tongue

So today I tested out the force-feedback support I added last night and made some adjustments. Playing in game, everything seems to work properly now. Only one problem - after about one minute of force feedback use, the driver (or something) cuts out and I don't get any more feedback. I had this problem with the ffcfstress program as well.

If anyone else has a chance, please try this out, and let me know how it works for you. Especially if you have a different wheel than me - I want to see if the problem is specific to my wheel or general to the driver or force code in VDrift.
Visit this user's website Find all posts by this user
Quote this message in a reply
02-22-2007, 12:29 AM
Post: #4
 
Sweet! How is it??
Find all posts by this user
Quote this message in a reply
02-22-2007, 02:58 PM
Post: #5
 
Just guessing here: do you unload effects everytime you add a new one? (could be the ffb chip memory filling up till no more is available, making it crash or something.. maybe)
Find all posts by this user
Quote this message in a reply
02-22-2007, 05:29 PM
Post: #6
 
I think it's a bug in the hid-lgff driver. The duration is expressed on a 16 bits integer, where 65535 means "for ever"... except the original hid-lgff driver I wrote did not handle this. That would cause your effect to play for exactly 65.535 seconds and stop Idea

I'll have to remember to fix that if it isn't already fixed in the latest kernel, but in the mean time you can easily avoid that bug by simply stopping and re-starting the effect now and then. Perhaps you don't even need to stop, sending a new start might suffice.

Unless it's something else... Worth a try anyway.
Find all posts by this user
Quote this message in a reply
02-22-2007, 09:34 PM
Post: #7
 
Hello,

I am not a player of your game yet (but it won't last. Now that I know it, I will try it this week-end probably). But I heard about the fact you have been the first person to program Force Feedback in a Linux game.

And I have a question: do you use some interface library to easily access to the force feedback accessories? Or else do you interface directly with the driver? Or what?

If this does not exist, it would be a nice idea to create a separate generic API for force feedback interfacing. Thanks to such a thing, other programmers (lazy ones!!! And for other concurrent games! Tongue) would be able to simply access the force feedback material generically, with simple function (or class method) calls...
What? Noooo... it is not an appeal for you to make it! Tongue Me forcing you to work more?!

Anyway, great job. I will try the game, but I will have to ask my little brother to undig his force feedback wheel in his stuffs... ;-) I have a friend who has a force feedback joystick also.
Find all posts by this user
Quote this message in a reply
02-22-2007, 11:57 PM
Post: #8
 
Jey, so far it's all just directly writing to the driver. I wish there was a library of some kind, but there's not really one. I'm seriously considering writing one, probably SDL-based. Glad you're interested Smile

jdeneux, someone on #vdrift IRC with the same wheel as me reported that it worked continuously for over two minutes for him when he tested it. He was using a fairly recent kernel (2.6.20 i think) and I'm using 2.6.17. Soon I'll upgrade and do more testing...probably this weekend.

stenyak, I'm not really unloading the effects, I'm pretty sure they're still in the device's buffer at least because the "force feedback light" on the wheel stays on even after I stop playing. I need to look into how to manage the effects better. The code that's in forcefeedback.cpp in VDrift SVN right now is basically just the same stuff from ffcfstress.c, copied and adapted to C++ a little. I don't believe that had any unloading code either.
Visit this user's website Find all posts by this user
Quote this message in a reply
02-23-2007, 11:34 AM
Post: #9
 
Following the recent "developing sims as a community" posts, i think it would be nice if your force feedback was usable by more sims. If not by realeasing a library or contributing to one, at least making the code easily reusable by copy-paste-creditting the cpp file to other project (like mine O: -), having as little header dependency as possible (if possible, only to kernel or similar headers).
Find all posts by this user
Quote this message in a reply
02-24-2007, 12:01 PM
Post: #10
 
I also get no forces after a while playing with ffcfstress.
Find all posts by this user
Quote this message in a reply
02-25-2007, 12:36 PM
Post: #11
 
stenyak, what is your kernel version?
Visit this user's website Find all posts by this user
Quote this message in a reply
02-25-2007, 12:38 PM
Post: #12
 
$ uname -a
Linux 1ksurvivor.homeip.net 2.6.18-gentoo-r6 #5 PREEMPT Tue Feb 6 01:58:33 CET 2007 i686 AMD Sempron™ 3000+ AuthenticAMD GNU/Linux
Find all posts by this user
Quote this message in a reply
02-25-2007, 12:39 PM
Post: #13
 
I think the FF overhaul happened in 2.6.19 or 2.6.20 (I don't feel like digging through patches right now to figure it out) so I'm guessing that's why you and I have that problem. Let me know if you update your kernel and if anything changes then...
Visit this user's website Find all posts by this user
Quote this message in a reply
02-25-2007, 01:39 PM
Post: #14
 
I gave it a go, but it was not too successful. My joystick is listed in the game, but it behaves as if it had no axes (no blue boxes at all when calibrating). That is not specific to VDrift though, I suspect a bug in my version of SDL, or maybe in the driver.
So I played with the keyboard, and kept a hand on the joystick to feel if something was moving. I never managed to achieve high speed (past the 3rd gear) with the default car playing with the keyboard: In curves, the car just understeers, I spent more time in the grass than on the road Smile

I never felt anything, maybe the forces were just too weak. I got many error messages related to failed effect updates. That happens with ffcfstress also, and is due to the iforce device not being happy about receiving too many packets too fast.

The joystick is supported by the iforce module, not the hid module. I will try with a wheel and see if I have more success.

The joystick worked with ffcfstress, although it did not behave fully as expected. The stick would jerk violently if I started moving it instead of just holding it in the centre position.

To summarize: It seems VDrift isn't doing anything wrong, but the experience was not quite successful.
Find all posts by this user
Quote this message in a reply
02-25-2007, 03:25 PM
Post: #15
 
jdeneux, I haven't yet created a gain setting for the force-feedback. You could also try turning on stop-and-start to see if that gives you better results. What kind of joystick were you trying to use? Does it work in jstest, jscal, jscalibrator, etc.?

If you're playing with the keyboard I recommend turning on "Button Control Delay" in Options -> Controls. Also turn on the Input Graph in Options -> Display. This will make the keyboard controls much easier to drive with. If they're not already on, also turn on ABS and TCS. Smile

However there should be some noticeable force feedback if you're driving and turning, no matter what gear. I basically kept the same settings that ffcfstress defaulted with - the updates happen at about 25 Hz, the gain is 2.0 because that felt good on my wheel, etc. I'll see if I can make it a little easier to tune, like perhaps you could try chaging line 987 in src/vamosworld.cpp from
Code:
if( ff_update_time >= 40.0 )
to
Code:
if( ff_update_time >= 100.0 )
this would set the updates to happen at 10 Hz instead of 25 Hz, and maybe you won't get the error messages anymore.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)