STEAM GROUP
Linux Force Feedback LinuxFF
STEAM GROUP
Linux Force Feedback LinuxFF
7
IN-GAME
41
ONLINE
Founded
December 12, 2015
Language
English
D4rthCheney May 15, 2018 @ 4:29pm
Logitech G29 udev rules
I recently got a G29 and after struggling to get it working consistently, I finally made some progress thanks to

https://steamcommunity.com/groups/linuxff/discussions/0/451848855023803557/

However, I wanted a way to set up the controller automatically, without having to run a script as root/sudo every time, so I created the following udev rule in conjunction with the attached script.

I'm sure its not perfect, but I'm sharing it in case it helps anyone else, and to incorporate helpful suggestions.

Important Note: This rule only works if you have the g29 in PS3 mode. Otherwise the file locations modified in the script aren't created.

Important Note: I am using Linux Mint with 4.10.0-38-generic kernel. Should work on most other systems of an equivalent kernel, but I haven't tested on them and may not be able to answer questions if it doesn't work on yours.

First:

I created a file, 90-logitech-wheel.rules, in /etc/udev/ruled.d
SUBSYSTEM=="input", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c24f", MODE="0664", GROUP="plugdev", SYMLINK+="logitech_g29", RUN+="/home/<user>/bin/g29config"

The SYMLINK isn't really necessary, nor is it used by the script below, but I included it just in case I wanted to find my device easier.

The RUN parameter needs to point to the script posted below. I put it in my user directory so I could modify it as desired without having to take root ownership. You could also leave it out, and manually run the script, but you would have to invoke sudo everytime.


You can verify the idProduct of your device by running 'lsusb' after it has been plugged in.

you should see something like:
Bus nnn Device mmm: ID 046d:0c24f Logitech G29 Steering
The Bus and Device numbers will be unique to your system. I'm guessing at the string because I don't have the wheel plugged in at the moment, but whats important is the fact that its your G29 and the 046d:0c24f code.

When set in PS3 mode, the driver creates a bunch of files under
/sys/bus/hid/drivers/logitech
but doesn't "obey" the plugdev group rule and keeps them owned by root:root. If anyone knows how to get the driver to give group permissions to a group, eg plugdev, that would be great. Then plugdev group members could modify the mode and range without having to take root.

The RUN parameter of the udev rule points to a script which sets the desired values for alternate_modes and range.

The script is heavily commented, but feel free to ask questions. You can also run it manually (as root) prior to setting up the udev rule to test it. There are several commented out lines that you can modify to aid in debugging.

#!/bin/bash # # Logitech G29 Udev initialization script. # Run by udev to modify the alternate mode and sets the range. # Change the ALTERNAME_MODE and RANGE values at the top of the script as desired. # # note, at first the device appears as a G29, but when changed to G27 the device id changes as does the driver folder # eg # /sys/bus/hid/drivers/logitech/0003:046D:C24F.0033 # gets changed to # /sys/bus/hid/drivers/logitech/0003:046D:C29B.0035 # after changing the mode to G27 # User modifiable variables # Define what mode to use # cat alternate_modes for a full list of options: # eg cat /sys/bus/hid/drivers/logitech/0003:046D:C24F.0033/altername_modes ALTERNAME_MODE=G27 # steering wheel range RANGE=540 # expected location of driver files, you should not have to change this more than once logitechRoot=/sys/bus/hid/drivers/logitech # make sure the logitechRoot exists or else we might royally screw up stuff later. if [ ! -d "$logitechRoot" ] then # echo no directory with $logitechRoot exit -1 fi # initially, the device appears as a G29, i.e. C24F g29device=$(find $logitechRoot -iname "*C24F*") # optional, write the location to a user location for debugging. #echo "G29: " $g29device >> /home/<user>/logitechDevices # if the g29 directory exists, if [ -d "$g29device" ] then # then change it to a g27 echo $ALTERNAME_MODE > $g29device/alternate_modes # wait a bit for the driver to change the device sleep 1 fi # once we set the mode to G27, the id changes from C24F to C29B as does the location of the files g27device=$(find $logitechRoot -iname "*C29B*") # optional, write the location to a user location for debugging. # echo "G27: " $g27device >> /home/<user>/logitechDevices # if the g27 device doesn't exist, exit # ******************* don't screw this up!!! **************** # If g27device isn't defined, you will chgrp/chmod your / directory recursively. if [ ! -d "$g27device" ] then # echo no directory with C29B in $logitechRoot >> /home/<user>/logitechDevices exit -1 fi # echo found directory $g27device # controls steering range echo $RANGE > $g27device/range # modify permissions so plugdev users can change settings chgrp plugdev $g27device/* -R chmod g+rw $g27device/* -R

Constructive criticism requested.

Thanks,
Last edited by D4rthCheney; May 15, 2018 @ 5:07pm
< >
Showing 1-1 of 1 comments
D4rthCheney Jan 30, 2020 @ 5:36pm 
I've was setting up a new system and noticed that Dirt Rally now works with the G29 in ps3 mode after you add some lines to the inputdevices.json in the games share directory, eg ~/.steam/steam/steamapps/common/DiRT\ Rally/share/inputdevices.json
per https://steamcommunity.com/app/310560/discussions/0/1776010325125699594/

So, its safe to remove the part about re-assigning to g27 mode. Now the script just sets the Range to 540 whenever its plugged in, and give users in the plugdev group the ability to make other changes. Of course you can keep that part if you need it for other games.
# User modifiable variables # steering wheel range RANGE=540 # expected location of driver files, you should not have to change this more than once logitechRoot=/sys/bus/hid/drivers/logitech # initially, the device appears as a G29, i.e. C24F g29device=$(find $logitechRoot -iname "*C24F*") # make sure the g29 directory exists or else we might royally screw up stuff later. if [ ! -d "$g29device" ] then # no directory with $g29device, quit exit -1 fi # echo found directory $g29device # optional: make a link to it for user, replace $HOME with the actual path to your home directory, or wherever you want the link # ln -sf $g29device $HOME/g29.d # controls steering range echo $RANGE > $g29device/range # modify permissions so plugdev users can change settings chgrp plugdev $g29device/* -R chmod g+rw $g29device/* -R
Last edited by D4rthCheney; Jan 30, 2020 @ 5:37pm
< >
Showing 1-1 of 1 comments
Per page: 1530 50