Logitech Gamepad on Steam

	   My ill-fated attempts to get a Logitech Rumblebad working on
	   Steam.  A waste of an afternoon.

Posted: Wed 10 Jun, 2015, 15:40
As part of my project build a decent Steam machine on Gentoo I reached the stage where I really wanted to try the games with a gamepad. I am not a massive fan of using a keyboard when gaming and prefer to sit back on the sofa with a game controller rather than balance a keyboard on my lap. I am aware that keyboard is better for many games, that is not going to matter for the level I am playing at.

So I purchase a Logitech F710 Gamepad Controller, which registers itself as a funkily named RumblePad 2. It is the wireless version, which is totally worth the extra money to avoid the cables and more importantly being able to sit further back from the server.

The optimist in me was thinking I could just plug it would work. But no, nothing ever just works, particularly on Gentoo where literally everything is off/disabled until you enable it. So below is the summary of the two day journey (on and off) required to get it working:

This is what is showed up as when I first plugged it in under the /dev/inputs directory:

    cd /dev/input/by-id/
        by-id # ls -artl
        total 0
        lrwxrwxrwx 1 root root   9 Jun 10 19:18 usb-Logitech_USB_Receiver-if01-mouse -> ../mouse0
        lrwxrwxrwx 1 root root   9 Jun 10 19:18 usb-Logitech_USB_Receiver-if01-event-mouse -> ../event4
        lrwxrwxrwx 1 root root   9 Jun 10 19:18 usb-Logitech_USB_Receiver-event-kbd -> ../event3
        drwxr-xr-x 4 root root 260 Jun 10 19:31 ..
        lrwxrwxrwx 1 root root   6 Jun 10 19:31 usb-Logitech_Logitech_Cordless_RumblePad_2-joystick -> ../js0
        lrwxrwxrwx 1 root root   9 Jun 10 19:31 usb-Logitech_Logitech_Cordless_RumblePad_2-event-joystick -> ../event5
        drwxr-xr-x 2 root root 140 Jun 10 19:31 .
        

But this was not enough, it was not working when I check in Steam under Controllers. So I read a bit and discovered evtest which is useful for checking the OS is recieving events from an input device:

    evtest
        Available devices:
        /dev/input/event0:      Power Button
        /dev/input/event1:      Power Button
        /dev/input/event2:      Video Bus
        /dev/input/event3:      Logitech USB Receiver
        /dev/input/event4:      Logitech USB Receiver
        /dev/input/event5:      Logitech Logitech Cordless RumblePad 2
        Select the device event number [0-5]: 5
        Input driver version is 1.0.1
        Input device ID: bus 0x3 vendor 0x46d product 0xc219 version 0x111
        Input device name: "Logitech Logitech Cordless RumblePad 2"
        Supported events:
          Event type 0 (EV_SYN)
          Event type 1 (EV_KEY)
            Event code 304 (BTN_A)
            Event code 305 (BTN_B)
            Event code 306 (BTN_C)
            Event code 307 (BTN_X)
            Event code 308 (BTN_Y)
            Event code 309 (BTN_Z)
            Event code 310 (BTN_TL)
            Event code 311 (BTN_TR)
            Event code 312 (BTN_TL2)
            Event code 313 (BTN_TR2)
            Event code 314 (BTN_SELECT)
            Event code 315 (BTN_START)
          Event type 3 (EV_ABS)
            Event code 0 (ABS_X)
              Value    128
              Min        0
              Max      255
              Flat      15
            Event code 1 (ABS_Y)
              Value    127
              Min        0
              Max      255
              Flat      15
            Event code 2 (ABS_Z)
              Value    127
              Min        0
              Max      255
              Flat      15
            Event code 5 (ABS_RZ)
              Value    128
              Min        0
              Max      255
              Flat      15
            Event code 16 (ABS_HAT0X)
            Event code 5 (ABS_RZ)
              Value    128
              Min        0
              Max      255
              Flat      15
            Event code 16 (ABS_HAT0X)
              Value      0
              Min       -1
              Max        1
            Event code 17 (ABS_HAT0Y)
              Value      0
              Min       -1
              Max        1
          Event type 4 (EV_MSC)
            Event code 4 (MSC_SCAN)
          Event type 21 (EV_FF)
            Event code 80 (FF_RUMBLE)
            Event code 81 (FF_PERIODIC)
            Event code 88 (FF_SQUARE)
            Event code 89 (FF_TRIANGLE)
            Event code 90 (FF_SINE)
            Event code 96 (FF_GAIN)
        

OK, so the kernel completely understands that is it and what kind of events it can generate, so why cant Steam see it? I read up on xboxdrv which allows XBox controllers to work on Linux. With this daemon running, it is possible to translate the events from your device into the XBox equivalent, as explained on this link:

https://www.mail-archive.com/xboxdrv@googlegroups.com/msg00071.html

This was further re-enforced by this help page on Steam Community which explains how to make PS2 controller appear like an XBox controller so that Steam will recognise it. At this point I am thinking - does it really have to be this complicated?

Play with any USB controller on Linux using xboxdrv to emulate a XBOX controller

Nevertheless I grabbed the suggested configuration and created my very own .xboxdrv configuration file:

    # Xboxdrv configuration for the Logitech Cordless RumblePad 2 USB controller
        # xboxdrv --config rumblepad2.xboxdrv

        [xboxdrv]
        evdev       = /dev/input/by-id/usb-Logitech_Logitech_Cordless_RumblePad_2-event-joystick
        evdev-grab  = true
        mimic-xpad  = true
        silent      = true

        [axismap]
        -Y1         = Y1
        -Y2         = Y2

        [evdev-absmap]
        ABS_X = DPAD_X
        ABS_Y = DPAD_Y

        ABS_HAT0X = X1
        ABS_HAT0Y = Y1

        ABS_Z = X2
        ABS_RZ = Y2

        [evdev-keymap]
        BTN_EAST = A
        BTN_C = B
        BTN_SOUTH = X
        BTN_NORTH = Y
        BTN_Z = RB
        BTN_TR = RT
        BTN_WEST = LB
        BTN_TL = LT
        BTN_TR2 = START
        BTN_TL2 = BACK
        BTN_SELECT = TL
        BTN_START = TR
        

When I then tried this out with xboxdrv it returned the following error:

    xboxdrv 0.8.5 - http://pingus.seul.org/~grumbel/xboxdrv/ 
        Copyright © 2008-2011 Ingo Ruhnke <grumbel@gmx.de> 
        Licensed under GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
        This program comes with ABSOLUTELY NO WARRANTY. 
        This is free software, and you are welcome to redistribute it under certain conditions; see the file COPYING for details. 


        -- [ ERROR ] ------------------------------------------------------

        Error: No stuitable uinput device found, tried:

          /dev/input/uinput: No such file or directory
          /dev/uinput: No such file or directory
          /dev/misc/uinput: No such file or directory

        Troubleshooting:
          * make sure uinput kernel module is loaded 
          * make sure joydev kernel module is loaded 
          * make sure you have permissions to access the uinput device
        

So this helpfully points out that having events generated from the standard /dev/input location is not enough. It needs events to be generated from the uinput (User Input Devices). So according this post uinput ' is a linux kernel module that allows to handle the input subsystem from user land.' So I do not totally understand this because surely mouse-clicks and selecting carried out in LibreOffice using a mouse shows that I can already handle the input events in user land. I do not need to run LibreOffice as root or anything, when logged in my applications can access these events. So with some skepticism I then went away and enabled this in my kernel on Gentoo as shown below:

    Input Devices > Miscellaneous > User Input Devices
        

Then rebuilt the kernel, installed it, rebooted, and tried the following commmand and it worked:

    xboxdrv --config /etc/xboxdrv/rumblepad2.xboxdrv
        

When I tried to run this as a daemon on startup it errored however:

    conf.d # /etc/init.d/xboxdrv start
        * Caching service dependencies ...  
        [ ok ]    * Starting xboxdrv ...    
        [ ok ]    conf.d # [ERROR] XboxdrvDaemon::run(): fatal exception: failed to open connection to bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory 
        

I had a look at the code and could not see anything obvious that I was missing, so in the end I just removed the --daemon mode, and added -b (background) option in start-stop-daemon. And finally added it to my startup with this:

    rc-update add xboxdrv default
        

And actually, it was still not working. When checking for Configuration and Controllers in Big Picture mode it still showed up with no registered controllers... argh. This is where Gentoo grinds you down and makes you start thinking, will this ever work? It is typically after many hours trying to fix something that should be trivial and you know you have spent way more time that you should have on it. The arguments against Linux, and Gentoo, start to mount up....

But I had another look and tried to cat /dev/uinput/... to ensure I could see the events as pressed the buttons on the controller, and turns out I could not. These new files were read-only to others, and when I run Steam on my machine I am logged in as a general users, not as root. So I changed the startup script to ensure these devices were started with globally read-able permissions (yes, this means someone could monitor my keyboard keystrokes... ) and then it all worked.

Leaving the uncomfortable question, would this have worked at the beginnning... was xboxdrv necessary? I could find this out but I dont care now. Its working brilliantly and that is all that matters. Portal 2 is much more fun to play with the Game Controller for starters. Next time I am rebuilding my machine, in a few years, I will try the quick fix first.