Enabling force feedback in kernel

From VDrift
Revision as of 08:14, 8 April 2009 by Cborivant (talk) (Configure the new kernel)
Jump to: navigation, search

Here is how to enable force feedback on Ubuntu 8.10 64 bits kernels (should also work on 32 bits ones):

For the G25 owners

If you use a G25 wheel, you need to patch your kernel to be able to use it in its native mode First create a patch file named G25.patch for the kernel ( Tested on 2.6.27 ) :

diff -Naur linux-source-2.6.27/drivers/hid/usbhid/hid-ff.c linux-source-2.6.27.orig/drivers/hid/usbhid/hid-ff.c
--- linux-source-2.6.27/drivers/hid/usbhid/hid-ff.c    2008-10-10 00:13:53.000000000 +0200                     
+++ linux-source-2.6.27.orig/drivers/hid/usbhid/hid-ff.c       2009-02-23 22:21:27.000000000 +0100             
@@ -57,6 +57,7 @@                                                                                              
       { 0x46d, 0xc286, hid_lgff_init }, /* Logitech Force 3D Pro Joystick */                                  
       { 0x46d, 0xc294, hid_lgff_init }, /* Logitech Formula Force EX */                                       
       { 0x46d, 0xc295, hid_lgff_init }, /* Logitech MOMO force wheel */
+      { 0x46d, 0xc299, hid_lgff_init }, /* Logitech G25 wheel */
       { 0x46d, 0xca03, hid_lgff_init }, /* Logitech MOMO force wheel */
 #endif
 #ifdef CONFIG_LOGIRUMBLEPAD2_FF
diff -Naur linux-source-2.6.27/drivers/hid/usbhid/hid-lgff.c linux-source-2.6.27.orig/drivers/hid/usbhid/hid-lgff.c
--- linux-source-2.6.27/drivers/hid/usbhid/hid-lgff.c  2008-10-10 00:13:53.000000000 +0200
+++ linux-source-2.6.27.orig/drivers/hid/usbhid/hid-lgff.c     2009-02-23 22:23:22.000000000 +0100
@@ -55,6 +55,7 @@
       { 0x046d, 0xc286, ff_joystick },
       { 0x046d, 0xc294, ff_joystick },
       { 0x046d, 0xc295, ff_joystick },
+      { 0x046d, 0xc299, ff_joystick },
       { 0x046d, 0xca03, ff_joystick },
 };

diff -Naur linux-source-2.6.27/drivers/hid/usbhid/hid-quirks.c linux-source-2.6.27.orig/drivers/hid/usbhid/hid-quirks.c
--- linux-source-2.6.27/drivers/hid/usbhid/hid-quirks.c        2009-03-13 18:54:14.000000000 +0100
+++ linux-source-2.6.27.orig/drivers/hid/usbhid/hid-quirks.c   2009-02-23 22:25:45.000000000 +0100
@@ -316,6 +316,7 @@
 #define USB_DEVICE_ID_LOGITECH_HARMONY_64 0xc14f
 #define USB_DEVICE_ID_LOGITECH_EXTREME_3D     0xc215
 #define USB_DEVICE_ID_LOGITECH_WHEEL  0xc294
+#define USB_DEVICE_ID_LOGITECH_WHEELG25       0xc299
 #define USB_DEVICE_ID_LOGITECH_ELITE_KBD      0xc30a
 #define USB_DEVICE_ID_LOGITECH_KBD    0xc311
 #define USB_DEVICE_ID_S510_RECEIVER   0xc50c
@@ -625,6 +626,7 @@
       { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
       { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D, HID_QUIRK_NOGET },
       { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL, HID_QUIRK_NOGET },
+      { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEELG25, HID_QUIRK_NOGET },
       { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0, HID_QUIRK_NOGET },
       { USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE, HID_QUIRK_NOGET },
       { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },

Enabling force feedback in the kernel

Prepare to compile a kernel

Make sure U have everything needed to compile your kernel :

sudo apt-get install fakeroot build-essential makedumpfile libncurses5 libncurses5-dev
sudo apt-get build-dep linux

Get the kernel source code :

sudo apt-get install linux-source

Now we are ready to start : Prepare your environment:

mkdir ~/src
cd ~/src
tar xjvf /usr/src/linux-source-<version>.tar.bz2
cd linux-source-<version>[/code]

Apply the G25 patch if needed

copy the G25.patch file into the source directory and

patch -p1 <G25.patch

the output should be something like that:

patching file drivers/hid/usbhid/hid-ff.c
patching file drivers/hid/usbhid/hid-lgff.c
patching file drivers/hid/usbhid/hid-quirks.c

Configure the new kernel

Get the running kernel configuration:

cp -vi /boot/config-`uname -r` .config

Adjust the kernel configuration:

make oldconfig
make menuconfig

Go to Device Drivers , and HID Devices and enable the following options

Force feedback support (EXPERIMENTAL)
  PID device support
  Logitech devices support
  Logitech Rumblepad 2 support
  PantherLord/GreenAsia based device support
  ThrustMaster devices support
  Zeroplus based game controller support

I have to disable paravirtualized guest support otherwise the kernel cleaning fail. Go to Processor type and features and disable the following:

Paravirtualized guest support

Compile and package the new kernel

make-kpkg clean
fakeroot make-kpkg --initrd --append-to-version=-ff kernel-image kernel-headers

you now have 2 new package files in ~/src.

Install the new kernel

sudo dpkg -i linux-image-2.6.27.18-ff_2.6.27.18-ff-10.00.Custom_amd64.deb linux-headers-2.6.27.18-ff_2.6.27.18-ff-10.00.Custom_amd64.deb