Homepage Forums RetroPie Project Controller Configuration in RetroPie Using UDEV rules to assign persistent names to joypads

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #103131
    geauxwave
    Participant

    I’m using USB controller adapters for SNES and PSX controllers. Each one has a single USB connection and two controller input ports.

    The good thing about these is that both ports on each device are recognized whether there is a controller plugged into it or not. So, upon startup, js0, js1, js2, and js3 are assigned to them automatically.

    The bad thing is that the jsx name assignments are not always consistent. Sometimes the SNES adapter gets js0 and js1, and other times it gets assigned js2 and js3. This obviously makes it difficult when specifying controllers with input_player1_joypad_index in the emulator-specific retroarch.cfg file.

    To solve the problem, I created UDEV rules that assign consistent jsx names. Inspiration was taken from this thread: http://ubuntuforums.org/showthread.php?t=1595666&p=9974813#post9974813

    And I refined it to assign unique numbers to devices with identical ID_VENDOR and ID_MODEL values (as is the case with the two ports on each adapter) with a related solution on StackExchange here: http://unix.stackexchange.com/a/105218/125793

    My udev rules are as follows…

    KERNEL=="js?", ENV{ID_VENDOR}=="HuiJia", ENV{ID_MODEL}=="USB_GamePad", IMPORT{program}="/usr/local/bin/unique-num /run/miner-counter 6 SNES_NUM", NAME+="input/js$env{SNES_NUM}"
    KERNEL=="js?", ENV{ID_VENDOR}=="WiseGroup._Ltd", ENV{ID_MODEL}=="MP-8866_Dual_USB_Joypad", IMPORT{program}="/usr/local/bin/unique-num /run/miner-counter2 8 PSX_NUM", NAME+="input/js$env{PSX_NUM}"

    My SNES controller adapter ports (ID_VENDOR=”HuiJia”) are successfully named js6 and js7. They are listed in /dev/input, and I am able to test them with jstest.

    I have specified these joypads in /opt/retropie/configs/snes/retroarch.cfg…

    input_player1_joypad_index = "6"
    input_player2_joypad_index = "7"

    All that said, they do not work. I can only assume that it is because the joypad index that retroarch uses looks at something different, perhaps the true path, maybe? …

    (this is from udevadm info -q all -n /dev/input/js7)

    /devices/platform/bcm2708_usb/ … /input/input/input4/js4

    I really don’t know. I’m pretty much at a stopping point here, after putting a lot of hours into figuring out how to get the udev name assignments working, which i assumed would do the trick based off of the example i saw (first link). But perhaps, that author had not tested to see if it actually did work.

    Also, I’m not sure if this is related, but I do get an IOError upon exiting the emulator. It reads “IOError: [Errno 13] Permission denied: ‘/dev/input/js0’. Could this be related?

    Thanks for any guidance you can provide. I’ve spent a lot of time researching and learning–and don’t mind doing even more to solve the problem–but I am way beyond my pay grade at this point, LOL. Ay help is greatly appreciated!

    #103139
    Floob
    Member

    What happens if you dont specify the joypad buttons in the system specific retroarch.cfg and instead use the auto controller file in /opt/retropie/configs/all/retroarch-joypads/ ?

    If you just put the single SNES usb port in the top left usb port, dos it see both and assign them as player 1 and 2 (indicated by the yellow retroarch writing)?

    #103140
    geauxwave
    Participant

    [quote=103139]What happens if you dont specify the joypad buttons in the system specific retroarch.cfg and instead use the auto controller file in /opt/retropie/configs/all/retroarch-joypads/ ?

    If you just put the single SNES usb port in the top left usb port, dos it see both and assign them as player 1 and 2 (indicated by the yellow retroarch writing)?

    [/quote]

    Thanks for the reply! I’m actually using a USB Hub (the Plugable 7-port USB 2.0), but I have now bypassed it, and plugged the single SNES usb port into the top left usb port on the pi. This works! I reenabled input_autodetect in the global config file, and removed everything i added to the snes-specific config file. It assigns one port of the adapter to Player 1 and the other port to Player 2. I can unplug and plug in controllers between the two ports, swap them, and everything works as it should.

    But what about my other adapter? I have the Playstation adapter plugged into the second usb port in the Pi. Is there a way for me to tell the Playstation emulator to ignore the SNES adapter plugged into the first port, and use the PS controllers? Perhaps could I specify a controller type? In configs/all/retroarch-joypads the Playstation cfg file is called “WiseGroup.,LtdMP-8866DualUSBJoypad.cfg”. Can I somehow point to this in the Playstation specific config file?

    Thanks so much for your help.

    #103143
    geauxwave
    Participant

    Well, after about 20 test reboots, it looks like the USB ports on the Pi (unlike the USB hub’s ports) are consistent with how they assign the joypad numbers. I even plugged in a third adapter (a single Sega Genesis port). Upon every reboot, the SNES ports are always js0 and js1, the Genesis is always js2, and the PSX ports are always js3 and js4. This is awesome, as now I can assign the joypads in the emulator specific configs like I was doing before. It’s too bad that I wasted all that time messing with UDEV rules, LOL, but oh well. At least it works now. :)

    I guess I can eliminate the USB hub. I should be ok having 3 or 4 controller adapters plugged into the pi, considering I’ll only be using a max of two controllers at once, right? That shouldn’t be too much of a power drain for the Pi?

    #104961
    rastendo
    Participant

    How can you tell what js number a controller is assigned to?

    #104972
    Floob
    Member

    You could check with jstest

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Controller Configuration in RetroPie’ is closed to new topics and replies.