VDrift.net
  Home  :  Chat  :  Links  :  Polls  :  Media Gallery  :  Forum  :  Calendar  :  Advanced Search  :  Site Statistics   : VDrift Cars  
 Welcome to VDrift.net
 Thursday, July 29 2010 @ 01:21 PM PDT
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Linux force feedback wheel support
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    VDrift Forum Index -> Development
View previous topic :: View next topic  
Author Message
thelusiv



Joined: 29 Jun 2005
Posts: 2095
Location: Clemson, SC, USA

PostPosted: Wed Feb 21, 2007 7:08 am    Post subject: Linux force feedback wheel support Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
Nigo



Joined: 28 Jun 2006
Posts: 118

PostPosted: Wed Feb 21, 2007 1:48 pm    Post subject: Re: Linux force feedback wheel support Reply with quote

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
Back to top
View user's profile Send private message
thelusiv



Joined: 29 Jun 2005
Posts: 2095
Location: Clemson, SC, USA

PostPosted: Wed Feb 21, 2007 8:16 pm    Post subject: Reply with quote

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

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.
Back to top
View user's profile Send private message Visit poster's website
joevenzon



Joined: 29 Jun 2005
Posts: 2309
Location: Seattle, WA

PostPosted: Thu Feb 22, 2007 12:29 am    Post subject: Reply with quote

Sweet! How is it??
Back to top
View user's profile Send private message Visit poster's website
stenyak



Joined: 08 Dec 2006
Posts: 44

PostPosted: Thu Feb 22, 2007 2:58 pm    Post subject: Reply with quote

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)
Back to top
View user's profile Send private message
jdeneux



Joined: 01 Oct 2005
Posts: 10

PostPosted: Thu Feb 22, 2007 5:29 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Jey



Joined: 23 Feb 2007
Posts: 1

PostPosted: Thu Feb 22, 2007 9:34 pm    Post subject: Reply with quote

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! :p) 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! :p 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... Wink I have a friend who has a force feedback joystick also.
Back to top
View user's profile Send private message
thelusiv



Joined: 29 Jun 2005
Posts: 2095
Location: Clemson, SC, USA

PostPosted: Thu Feb 22, 2007 11:57 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
stenyak



Joined: 08 Dec 2006
Posts: 44

PostPosted: Fri Feb 23, 2007 11:34 am    Post subject: Reply with quote

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).
Back to top
View user's profile Send private message
stenyak



Joined: 08 Dec 2006
Posts: 44

PostPosted: Sat Feb 24, 2007 12:01 pm    Post subject: Reply with quote

I also get no forces after a while playing with ffcfstress.
Back to top
View user's profile Send private message
thelusiv



Joined: 29 Jun 2005
Posts: 2095
Location: Clemson, SC, USA

PostPosted: Sun Feb 25, 2007 12:36 pm    Post subject: Reply with quote

stenyak, what is your kernel version?
Back to top
View user's profile Send private message Visit poster's website
stenyak



Joined: 08 Dec 2006
Posts: 44

PostPosted: Sun Feb 25, 2007 12:38 pm    Post subject: Reply with quote

$ uname -a
Linux 1ksurvivor.homeip.net 2.6.18-gentoo-r6 #5 PREEMPT Tue Feb 6 01:58:33 CET 2007 i686 AMD Sempron(tm) 3000+ AuthenticAMD GNU/Linux
Back to top
View user's profile Send private message
thelusiv



Joined: 29 Jun 2005
Posts: 2095
Location: Clemson, SC, USA

PostPosted: Sun Feb 25, 2007 12:39 pm    Post subject: Reply with quote

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...
Back to top
View user's profile Send private message Visit poster's website
jdeneux



Joined: 01 Oct 2005
Posts: 10

PostPosted: Sun Feb 25, 2007 1:39 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
thelusiv



Joined: 29 Jun 2005
Posts: 2095
Location: Clemson, SC, USA

PostPosted: Sun Feb 25, 2007 3:25 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    VDrift Forum Index -> Development All times are GMT - 4 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
 Copyright © 2010 VDrift.net
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.26 seconds