Joystick input number changing with different number of controllers

Home Forums RetroPie Project Everything else related to the RetroPie Project Joystick input number changing with different number of controllers

RetroPie has a new website and forum. Please visit https://retropie.org.uk/ for the new site. The new forum is located at https://retropie.org.uk/forum/. This forum is left here as a read-only archive.

This topic contains 9 replies, has 4 voices, and was last updated by Profile photo of adcooney adcooney 1 year, 10 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #89164
    Profile photo of adcooney
    adcooney
    Participant

    Hi all,

    So I have image 2.6 on a new SD card and configured it with 2 controllers. Everything is fine – runs megadrive/psx/n64/etc.

    Then I decide I want to try setting up 3-4 controllers mostly for retroarch and mame. The problem I am finding is that for RetroArch I am using retroarch-joyconfig to create a cfg file that I then append to the retroarch.cfg. The problem I am finding is for 2 controllers I used js0 and js1, but now I put 3 controllers in the JS starts at 5 and (I think) this is breaking my old configs due to the input_playerX_joypad_index parameter. I believe that is indexing the JS index which have now all changed.

    Is there any way to keep the js input sane such that with N controllers it will always start be 0..(N-1) ? Or does anyone know how to achieve my goal. I’d like my config to work regardless of the number of controllers plugged in.

    I am using 1 wired xbox controller and 2 wireless controllers.

    Adz

    #89252
    Profile photo of adcooney
    adcooney
    Participant

    I can see perhaps not many people have such a problem. I spoke to a colleague at work (who is much much better at Linux than I am) and they suggested using udev rules to force the js indexes.

    Not sure if anyone else knows a way to do this correctly. I did change to using xboxdrv instead of the default (I think that is xpad out of the box?). Perhaps I should revert this?

    #89333
    Profile photo of adcooney
    adcooney
    Participant

    Okay I think I have fixed it. For anyone that cares I created a rules file within /etc/udev/rules.d/ that looks like the following

    
    KERNEL=="js?", ATTRS{name}=="Xbox Gamepad (userspace driver)", NAME="input/js0"
    KERNEL=="js?", ATTRS{name}=="Xbox Gamepad (userspace driver) #2", NAME="input/js1"
    KERNEL=="js?", ATTRS{name}=="Xbox Gamepad (userspace driver) #3", NAME="input/js2"
    KERNEL=="js?", ATTRS{name}=="Xbox Gamepad (userspace driver) #4", NAME="input/js3"
    

    This appears to have resolved my issues. I can now plugin at least 1-3 in and player 1 is always player 1. At least it works for megadrive,psx,snes.

    #96565
    Profile photo of erik
    erik
    Participant

    Hi there,

    I have a similar problem. If i follow the tutorial to setup my four xbox controllers somehow the the driver numbers are mixed up. This is what happens when i try to configure controller1:

    pi@retropie /opt/retropie/emulators/retroarch $ ./retroarch-joyconfig -o /opt/retropie/configs/all/p1.cfg -p 1 -j 0
    etropie/configs/all/p1.cfg -p 1 -j 0
    Found joypad driver: udev
    Using joypad: Xbox Gamepad (userspace driver) #3

    I don´t know why but somehow js0 allways gets #3. I think i could fix this for retroarch by changing the device number for each player but in mupen64plus this doesn’t work.

    Is there a way to use your rules file to fix this?
    Could you give me some details of how to make the rules file work?

    #100497
    Profile photo of adcooney
    adcooney
    Participant

    Hi,

    So this may be what I had. Presumably if you put one controller or two it uses js0 and when you put extra ones in that is when the js index changes? So I’d hope my rules file would work. Please note if you use it although I personally have had no problems and despite programming for 10years I er just ‘learnt’ how to make it!

    I cannot remember the name of the file I made either but its something like ’99-permissions-xboxdrv.rules’. The rules file is loaded on boot, you should be able to create it, restart the Pi and then see via jstest. I can post you the actual name of the file I used later after work. I do not know offhand nor do I actually know how important it is.

    #100540
    Profile photo of adcooney
    adcooney
    Participant

    So I have a udev rule:

    /etc/udev/rules.d/99-x-box.rules

    It contains:

    KERNEL=="js?", ATTRS{name}=="Xbox Gamepad (userspace driver)", NAME="input/js0"
    KERNEL=="js?", ATTRS{name}=="Xbox Gamepad (userspace driver) #2", NAME="input/js1"
    KERNEL=="js?", ATTRS{name}=="Xbox Gamepad (userspace driver) #3", NAME="input/js2"
    KERNEL=="js?", ATTRS{name}=="Xbox Gamepad (userspace driver) #4", NAME="input/js3"

    As far as I remember that is all I had to do to resolve the JS indexing problem. You will still need configurations for players 1-4.

    #100548
    Profile photo of herbfargus
    herbfargus
    Moderator

    I don’t know how related this is as I don’t own an Xbox controller but I’ve found that player order for my controllers is determined where they are plugged in the USB as follows:

    controller order

    #100575
    Profile photo of adcooney
    adcooney
    Participant

    The specific problem I was solving was when I was using 3-4 controllers but it would be a mixture of wired and wireless. Normally one wired xbox controller and 3 wireless via a receiver. If you had a wired and a single wireless controller they were always on js0 and js1. But once I’d added more the js numbers changed their starting point.

    The idea with that udev rule is it forces the controllers to ALWAYS go from 0-3 (like your usb ones) regardless of how many are wired or wireless. Obviously you still need configs stating the index for each player (if necessary). Anyway it works fine for me and has done since I ‘resolved’ this. I can play 4 player mario kart for example with an array of controllers. I may have missed something entirely which is why I’ve had to do this but yeah…works so I don’t care 🙂

    #100824
    Profile photo of smithers
    smithers
    Participant

    Does this script only work with Xbox pads? I am using a pair of Thrustmaster T-Mini Wireless pads, which are ps3 style. If I have both wireless dongles plugged in then often they seem to get confused and one pad ( normally player 1) will start to lose button functionality then stop working altogether whilst player2 works fine?

    If I have only 1 pad plugged in then it works perfect. I really would love to get this fixed but before I install Xboxdrv I just wondered if this fix is what I actually need or if it’s something different entirely? The pads are sold as part of a twin set so they surely must not be clashing on the same wireless frequency, its got to be software related… I hope!

    #100842
    Profile photo of adcooney
    adcooney
    Participant

    No I doubt it. This is specifically using the input name ‘Xbox Gamepad (userspace driver)’ to re-map the js inputs. Unless your Thrustmaster T-Mini pads are also named the same (which is doubtful) it will not work. You would have to change to match the name of your pad.

    Offhand I cannot recall how to get this information, I think if my memory serves its available in some log file after boot.

Viewing 10 posts - 1 through 10 (of 10 total)

Forums are currently read only - please visit the new RetroPie forums at https://retropie.org.uk/forums/

Skip to toolbar