R761's commentary

8 January 2009

Force Feedback on Linux with a Logitech momo wheel, part 2

Filed under: Games, Linux, Ubuntu — r761 @ 6:28 pm

Force feedback does work with 2.6.28. Here’s what evtest has to say when running 2.6.28:

evtest /dev/input/by-id/usb-Logitech_Logitech_MOMO_Racing-event-joystick
Input driver version is 1.0.0
Input device ID: bus 0x3 vendor 0x46d product 0xca03 version 0x100
Input device name: "Logitech Logitech MOMO Racing "
Supported events:
Event type 0 (Reset)
Event code 0 (Reset)
Event code 1 (Key)
Event code 3 (Absolute)
Event code 4 (?)
Event code 21 (ForceFeedback)
Event type 1 (Key)
Event code 288 (Trigger)
Event code 289 (ThumbBtn)
Event code 290 (ThumbBtn2)
Event code 291 (TopBtn)
Event code 292 (TopBtn2)
Event code 293 (PinkieBtn)
Event code 294 (BaseBtn)
Event code 295 (BaseBtn2)
Event code 296 (BaseBtn3)
Event code 297 (BaseBtn4)
Event type 3 (Absolute)
Event code 0 (X)
Value 0
Min 0
Max 1023
Fuzz 3
Flat 63
Event code 1 (Y)
Value 0
Min 0
Max 255
Flat 15
Event type 4 (?)
Event code 4 (?)
Event type 21 (ForceFeedback)
Event code 82 (?)
Event code 96 (?)
Event code 97 (?)
Testing ... (interrupt to exit)
Event: time 1231403438.348166, type 3 (Absolute), code 0 (X), value 56
Event: time 1231403438.348183, type 0 (Reset), code 0 (Reset), value 0
Event: time 1231403438.356172, type 3 (Absolute), code 0 (X), value 516
Event: time 1231403438.356190, type 3 (Absolute), code 1 (Y), value 127
Event: time 1231403438.356192, type 0 (Reset), code 0 (Reset), value 0
^C

Note the addition (after kernel upgrade) of “Event code 21 (ForceFeedback)”. fftest only acknowledges one type of event:

./fftest /dev/input/event4
Force feedback test program.
HOLD FIRMLY YOUR WHEEL OR JOYSTICK TO PREVENT DAMAGES

Device /dev/input/event4 opened
Axes query:
Effects: Constant
Number of simultaneous effects: 16
Upload effects[0]: Invalid argument
Upload effects[2]: Invalid argument
Upload effects[3]: Invalid argument
Upload effects[4]: Invalid argument
Upload effects[5]: Invalid argument
Enter effect number, -1 to exit
0
Now Playing: Sine vibration
Enter effect number, -1 to exit
1
Now Playing: Constant Force
Enter effect number, -1 to exit
2
Now Playing: Spring Condition
Enter effect number, -1 to exit
3
Now Playing: Damping Condition
Enter effect number, -1 to exit
4
Now Playing: Strong Rumble
Enter effect number, -1 to exit
5
Now Playing: Weak Rumble
Enter effect number, -1 to exit
6
No such effect
Enter effect number, -1 to exit
-1
No such effect

None of these effects make a noticeable difference to the wheel. The force feedback device is normally /dev/input/event4, though this changes occasionally between plugins. /dev/input/by-id/usb-Logitech_Logitech_MOMO_Racing-event-joystick is a symbolic link to the device (usually to ../event4). Most commands appear to work with either the link, or the actual device. fftest only works with the device (event4), and will fail to run if the link is specified. By default /dev/input/event4 is only accessible by root. The simple, one off fix, is to run

sudo chgrp plugdev /dev/input/by-id/usb-Logitech_Logitech_MOMO_Racing-event-joystick

This can be made permanent with the help of udev rules. Here’s what my /etc/udev/rules.d/80-logitech-mom-wheel.rules looks like now:

ACTION!="add", GOTO="event_end"
SUBSYSTEM!="input", GOTO="event_end"

KERNEL!="js[0-9]*", GOTO="js_end"
SYSFS{idProduct}=="ca03", SYSFS{idVendor}=="046d", RUN+="/usr/bin/logger udev Logitech momo wheel: running jscal"
SYSFS{idProduct}=="ca03", SYSFS{idVendor}=="046d", RUN+="/usr/bin/jscal -s 2,1,0,507,507,1058885,1044464,1,0,127,127,4227201,4194176 $tempnode"
LABEL="js_end"

KERNEL!="event[0-9], GOTO="event_end"
SYSFS{idProduct}=="ca03", SYSFS{idVendor}=="046d", RUN+="/usr/bin/logger udev Logitech momo wheel: setting feedback group"
SYSFS{idProduct}=="ca03", SYSFS{idVendor}=="046d", GROUP="plugdev"
LABEL="event_end"

According to the output in syslog (from the logger command) the group is set 3 times. From what I can tell by watching debug statements in udev rules, the momo wheel is 8 different devices (a joystick, a force feedback device, and I’m not sure what the others are). The auto-centre feedback force can be set with the ffset command:

ffset -a 100 /dev/input/event4

Will make the wheel harder to turn away from the centre. When released it will return to the centre quickly.

ffset -a 20 /dev/input/event4

Will make the wheel easier to turn. It will also return to centre more slowly. What Linux games support force feedback? The only one I know of is vdrift. To get vdrift working make sure the permissions are set (see above) and then edit the [ joystick ] section of ~/.vdrift/VDrivf.config to look like:

[ joystick ]
calibrated = off
deadzone = off
ff_device = /dev/input/by-id/usb-Logitech_Logitech_MOMO_Racing-event-joystick
ff_gain = 1.500000
ff_invert = off
selected_index = 0
touchcomp = off
two_hundred = on
type = wheel

That’s it – you are now ready to enjoy vdrift with force feedback.

2 January 2009

Force Feedback on Linux with a Logitech momo wheel

Filed under: Games, Linux, Ubuntu — r761 @ 2:33 pm

Force feedback doesn’t appear to be supported out of the box on Ubuntu 8.10 (with kernel 2.6.27) with the Logitech momo wheel.

By default the /dev/input/eventX devices are not readable by ordinary users. A temporary fix (until the device is removed and added) is to run chgrp plugdev /dev/input/event*.

The force-feedback package (libff/ffutils) has some test commands. To find the right device use evtest /dev/input/eventX. I found the event2 was the correct device:

bash> ./evtest /dev/input/event2
Input driver version is 1.0.0
Input device ID: bus 0x3 vendor 0x46d product 0xca03 version 0x100
Input device name: "Logitech  Logitech MOMO Racing "
Supported events:
  Event type 0 (Reset)
    Event code 0 (Reset)
    Event code 1 (Key)
    Event code 3 (Absolute)
    Event code 4 (?)
  Event type 1 (Key)
    Event code 288 (Trigger)
    Event code 289 (ThumbBtn)
    Event code 290 (ThumbBtn2)
    Event code 291 (TopBtn)
    Event code 292 (TopBtn2)
    Event code 293 (PinkieBtn)
    Event code 294 (BaseBtn)
    Event code 295 (BaseBtn2)
    Event code 296 (BaseBtn3)
    Event code 297 (BaseBtn4)
  Event type 3 (Absolute)
    Event code 0 (X)
      Value    512
      Min        0
      Max     1023
      Fuzz       3
      Flat      63
    Event code 1 (Y)
      Value    127
      Min        0
      Max      255
      Flat      15
  Event type 4 (?)
    Event code 4 (?)
Testing ... (interrupt to exit)
Event: time 1230869143.661631, type 3 (Absolute), code 0 (X), value 512
Event: time 1230869143.661639, type 0 (Reset), code 0 (Reset), value 0
Event: time 1230869143.669637, type 3 (Absolute), code 0 (X), value 501
Event: time 1230869143.669659, type 0 (Reset), code 0 (Reset), value 0
... lots more Events printed if the wheel is moved, or buttons presed.

In theory fftest should test force feedback. This didn’t work for me. Here’s the output:

bash> ./fftest /dev/input/event2
Force feedback test program.
HOLD FIRMLY YOUR WHEEL OR JOYSTICK TO PREVENT DAMAGES

Device /dev/input/event2 opened
Axes query:
Effects:
Number of simultaneous effects: 0
Upload effects[0]: Function not implemented
Upload effects[1]: Function not implemented
Upload effects[2]: Function not implemented
Upload effects[3]: Function not implemented
Upload effects[4]: Function not implemented
Upload effects[5]: Function not implemented
Enter effect number, -1 to exit

There are some changes in the 2.6.28 kernel relating to force feedback and the momo wheel – maybe that will get it working.

Next step: repeat these tests with a 2.6.28 kernel.

1 January 2009

Logitech momo wheel with Linux and Torcs

Filed under: Games, Linux, Ubuntu — r761 @ 10:37 pm

Recently I purchased a Logitech momo wheel for use with car simulators such as the torcs racing game.

Plugging this in to Ubuntu 8.10 it was detected immediately. Running

jstest /dev/input/js0

gives an easy way to show what all the buttons and pedals do. It also demonstrates the problem with the default configuration – there’s a significant dead spot around the centre of the wheel rotation. This can be fixed withjscal. Specifically:

jscal -c /dev/input/js0

Then follow the prompts to calibrate the wheel and pedal ranges. This removes the dead spot in the centre.

jscal -p /dev/input/js0

This prints out a command line which can be run to install the current calibation (as configured with jscal above). For me this output:

/usr/bin/jscal -s 2,1,0,507,507,1058885,1044464,1,0,127,127,4227201,4194176

Now, I could just re-type this command every time I connect the wheel, but being one to automate things I configured udev to automatically run jscal for me. To do this I created the file /etc/udev/rules.d/80-logitech-momo-wheel.rules which looks like:

ACTION!="add", GOTO="momo_end"
SUBSYSTEM!="input", GOTO="momo_end"
KERNEL!="js[0-9]*", GOTO="momo_end"

SYSFS{idProduct}=="ca03", SYSFS{idVendor}=="046d", RUN+="/usr/bin/logger udev Logitech momo wheel: running jscal"
SYSFS{idProduct}=="ca03", SYSFS{idVendor}=="046d", RUN+="/usr/bin/jscal -s 2,1,0,507,507,1058885,1044464,1,0,127,127,4227201,4194176 $tempnode"

LABEL="momo_end"

What about force feedback? It doesn’t appear to be supported by torcs. Accoding to blogdrake, vdrift does support force feedback so that’s next on my list of things to try.

Create a free website or blog at WordPress.com.