Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

XBOXDRV Guidance Needed



  • OK, I went through the first process of figuring out all the button assignments, and have created a file (on my computer for safe keeping) with this inside:

    sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
        --evdev /dev/input/by-id/usb-©Microsoft_Xbox_360_Wireless_Receiver_for_Windows_E1594E70-event-joystick \
        --silent \
        --detach-kernel-driver \
        --force-feedback \
        --deadzone-trigger 15% \
        --deadzone 4000 \
        --mimic-xpad \
        --dpad-as-button \
        --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_RX=x2,ABS_RY=y2,ABS_Z=lt,ABS_RZ=rt \
        --evdev-keymap BTN_SOUTH=a,BTN_EAST=b,BTN_NORTH=x,BTN_WEST=y,BTN_TL=lb,BTN_TR=rb,BTN_THUMBL=tl,BTN_THUMBR=tr,BTN_MODE=guide,BTN_SELECT=back,BTN_START=start,BTN_TRIGGER_HAPPY3=du,BTN_TRIGGER_HAPPY4=dd,BTN_TRIGGER_HAPPY1=dl,BTN_TRIGGER_HAPPY2=dr \
        &
    

    I added this to my /etc/rc.local file, so now it looks like this:

    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
    
    # Print the IP address
    _IP=$(hostname -I) || true
    if [ "$_IP" ]; then
      printf "My IP address is %s\n" "$_IP"
    fi
    
    /etc/switch.sh &
    
    
    sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
        --evdev /dev/input/by-id/usb-©Microsoft_Xbox_360_Wireless_Receiver_for_Windows_E1594E70-event-joystick \
        --silent \
        --detach-kernel-driver \
        --force-feedback \
        --deadzone-trigger 15% \
        --deadzone 4000 \
        --mimic-xpad \
        --dpad-as-button \
        --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_RX=x2,ABS_RY=y2,ABS_Z=lt,ABS_RZ=rt \
        --evdev-keymap BTN_SOUTH=a,BTN_EAST=b,BTN_NORTH=x,BTN_WEST=y,BTN_TL=lb,BTN_TR=rb,BTN_THUMBL=tl,BTN_THUMBR=tr,BTN_MODE=guide,BTN_SELECT=back,BTN_START=start,BTN_TRIGGER_HAPPY3=du,BTN_TRIGGER_HAPPY4=dd,BTN_TRIGGER_HAPPY1=dl,BTN_TRIGGER_HAPPY2=dr \
        &
    
    
    exit 0
    

    After doing that, and rebooting, ES loaded up, but my previously working controller wasn't working (to be expected). I plugged in another controller and initiated the "Configure Input" dialog, and mapped the controller as indicated in ES. Everything mapped fine, and with different codes for each. I went a step further and tested it in 2 different emulators, and can confirm that the driver loads and maps to RetroPad.

    Now the problem I'm having is getting the driver to load "on-demand". I ran this:

    sudo nano /etc/udev/rules.d/55-permissions-uinput.rules
    

    and added this:

    KERNEL=="uinput", MODE="0660", GROUP="users"
    

    It was my understanding that this essentially tells the driver to be able to be loaded as needed rather than all the time. I then followed the guide further and tried to add the driver commands to the launch script for Streets of Rage Remake. Nothing happens. I've gone back and forth numerous times trying to match my config to the example (which is using ScummVM). At one point, I was getting an error about no xboxdrv being loaded, which I thought might have come from the line in the script to killall. But that's where I'm at. Here is my current "Streets of Rage Remake.sh" file:

    #!/bin/bash
    sudo killall >/dev/null xboxdrv
    sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
        >/dev/null \
        --evdev /dev/input/by-id/usb-©Microsoft_Xbox_360_Wireless_Receiver_for_Windows_E1594E70-event-joystick \
        --silent \
        --detach-kernel-driver \
        --force-feedback \
        --deadzone-trigger 15% \
        --deadzone 4000 \
        --mimic-xpad \
        --dpad-as-button \
        --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_RX=x2,ABS_RY=y2,ABS_Z=lt,ABS_RZ=rt \
        --evdev-keymap BTN_SOUTH=a,BTN_EAST=b,BTN_NORTH=x,BTN_WEST=y,BTN_TL=lb,BTN_TR=rb,BTN_THUMBL=tl,BTN_THUMBR=tr,BTN_MODE=guide,BTN_SELECT=back,BTN_START=start,BTN_TRIGGER_HAPPY3=du,BTN_TRIGGER_HAPPY4=dd,BTN_TRIGGER_HAPPY1=dl,BTN_TRIGGER_HAPPY2=dr \
        --ui-buttonmap BTN_NORTH=KEY_X,BTN_SOUTH=KEY_C,BTN_EAST=KEY_V,BTN_TL=KEY_A,BTN_WEST=KEY_S,BTN_TR=KEY_D,BTN_MODE=KEY_B,BTN_SELECT=KEY_ESC,BTN_START=KEY_ENTER \
        --ui-buttonmap BTN_TRIGGER_HAPPY3=KEY_UP,BTN_TRIGGER_HAPPY4=KEY_DOWN,BTN_TRIGGER_HAPPY1=KEY_LEFT,BTN_TRIGGER_HAPPY2=KEY,RIGHT \
        -- \
    "/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "sorr" ""
    

  • Global Moderator

    @hansolo77

    We're doing things a little bit different here in an effort to simplify things a bit. You now have a mapping command that launches without error. Since we only want to concern ourselves with one or two emulators and not the whole system, remove the xboxdrv command from your rc.local and we'll only worry about having the mapping launch alongside the emulator. Also, go ahead and make a note of all the keyboard keys the emulator or port will call for and post it here.



  • Yeah, I'm taking a step back for a moment... When I last rebooted my system, it indicated it couldn't find a gamelist to one of my systems. I checked, and the file exists but it was empty. So I though "oh crap" and was going to restore a backup. Well, I don't have a recent backup prior to taking on this task. So I've gone back and uninstalled the XBOXDRV temporarily, and removed the additions to the rc.local file so I can get a good backup of the stable system before going forward.

    For the record here are my identified keys:

    Xbox Controller
    ===============
    
    
    cat /proc/bus/input/devices
    ---------------------------
    
    N: Name="Xbox 360 Wireless Receiver"
    H: Handlers=js5 event7
    
    
    ls /dev/input/by-id/
    --------------------
    usb-©Microsoft_Xbox_360_Wireless_Receiver_for_Windows_E1594E70-event-joystick
    
    
    
    Keymap
    ------
    
    
    A = BTN_SOUTH
    B = BTN_EAST
    X = BTN_NORTH
    Y = BTN_WEST
    BACK = BTN_SELECT
    START = BTN_START
    GUIDE = BTN_MODE
    LB = BTN_TL
    RB = BTN_TR
    LT = ABS_Z
    RT = ABS_RZ
    Left Stick Button = BTN_THUMBL
    Right Stick Button = BTN_THUMBR
    Left Stick UP/DOWN = ABS_Y
    Left Stick LEFT/RIGHT = ABS_X
    Right Stick UP/DOWN = ABS_RY
    Right Stick LEFT/RIGHT = ABS_RX
    D-Pad UP = BTN_TRIGGER_HAPPY3
    D-Pad DOWN = BTN_TRIGGER_HAPPY4
    D-Pad LEFT = BTN_TRIGGER_HAPPY1
    D-Pad RIGHT = BTN_TRIGGER_HAPPY2
    

    Strange that my action buttons (A,B,X,Y) don't exactly match compass directions. The X and Y are reversed. Oh well, that's what it reported.

    Give me about 10 minutes and I'll be good to go. I'm re-imaging the SD card now to a good backup, then I'll install the driver again. So do I still have to ENABLE it in the setup scripts?


  • Global Moderator

    @hansolo77 said in XBOXDRV Guidance Needed:

    Strange that my action buttons (A,B,X,Y) don't exactly match compass directions.

    Surprisingly, that's common.

    Give me about 10 minutes and I'll be good to go.

    Take your time.

    So do I still have to ENABLE it in the setup scripts?

    No, we'll be enabling it when it launches alongside your intended emulator and disabling it as the emulator quits.



  • Ok, so I've been dissecting this line by line to figure out what's not working. To start, launching the port from ES doesn't work. It just takes me back to ES. If I try to launch the script directly from a terminal window, I can't get it to launch because it has spaces. Whenever I type it out, it says no such file "Street" (the script path is called "Streets of Rage Remake"). So I created a new identical file called "TEST.sh". And tried launching that. Still nothing, saying permission denied. More research ensued, and I discovered I could run it by this:

    bash /home/pi/RetroPie/roms/ports/test.sh
    

    It scrolls something very briefly, then starts the port without the controller working. I've been slowly adding # comments out of each line to track down where it's failing. I can't make heads or tails out of that, so I decided to just type out the entire command on one line.. starting with:

    sudo killall >/dev/null xboxdrv
    

    That results in an error about no xboxdrv running. Ok, so I comment that line out. Next line:

    sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
    

    Results in an error about not being able to attach to the USB device, and recommends I run with the --detach-kernel-driver option. Ok, that makes sense, and it's in the full script.

    So I then took it a step further, and typed out this entire thing:

    sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv --evdev /dev/input/by-id/usb-©Microsoft_Xbox_360_Wireless_Receiver_for_Windows_E1594E70-event-joystick --detach-kernel-driver
    

    Basically I took out the >/dev/null part and all the backslashes, as I figured those are only needed in a script file. The end result tells me another error, about the controller device not existing. Now that I look at it, the controller in the script is listed as CMicrosoft and not ©Microsoft. So I need to figure out how to fix that.



  • Ok.. I fixed the ©Microsoft bit. The problem is definitely in how the script is laid out. Are all the backslashes necessary? I seem to recall in other codes you actually use a semicolon. But that's just crazy talk. I just feel like the only thing it's doing is launching the driver then failing once it tries to mount the device.


  • Global Moderator

    @hansolo77 said in XBOXDRV Guidance Needed:

    Are all the backslashes necessary?

    The whole thing is actually one command on one line. The backslashes are just there to break it up visually so that it's easier to read. I'm finishing up a phone call, but I'll be back with you shortly.



  • LOL.. "mediamogul tech support". :)

    I'm actually very close now. I took out the >dev/null bits, and now have it mostly working (to a point). So now my script looks like this..

    #!/bin/bash
    sudo killall xboxdrv
    sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
        --evdev /dev/input/by-id/usb-©Microsoft_Xbox_360_Wireless_Receiver_for_Windows_E1594E70-event-joystick \
        --detach-kernel-driver \
        --force-feedback \
        --deadzone-trigger 15% \
        --deadzone 4000 \
        --mimic-xpad \
        --dpad-as-button \
        --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_RX=x2,ABS_RY=y2,ABS_Z=lt,ABS_RZ=rt \
        --evdev-keymap BTN_SOUTH=a,BTN_EAST=b,BTN_NORTH=x,BTN_WEST=y,BTN_TL=lb,BTN_TR=rb,BTN_THUMBL=tl,BTN_THUMBR=tr,BTN_MODE=guide,BTN_SELECT=back,BTN_START=start,BTN_TRIGGER_HAPPY3=du,BTN_TRIGGER_HAPPY4=dd,BTN_TRIGGER_HAPPY1=dl,BTN_TRIGGER_HAPPY2=dr \
        -- \
    #"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "sorr" ""
    

    By taking out the null stuff, I can now see what's really happening behind the scenes. I also took out the --silent \ line so I can see what the driver is spitting out. When I run run this now (with the actual port launching being commented out) I get a nice dialog saying

    Your Xbox/Xbox360 controller should now be available as:
      /dev/input/js13
      /dev/input/event7
    
    Press Ctrl-C to quit, use '--silent' to suppress the event output
    

    The problem though is that it's still not registering as an input in this stupid game! LOL!! One thing I'm thinking about doing is trying that bit I thought of before, moving the /dev/input/js0 out and letting the driver create a new entry for it. Then have it move back after. I'm testing that now.


  • Global Moderator

    @hansolo77

    I'm still here, but hammers keep falling around me like a Warner Brothers cartoon. To quote everyone's favorite Austrian, I'll be back.



  • Not to worry! I got it! WOO!!!
    All the while I was having trouble, I discovered I didn't have the --ui-buttonmap settings reinserted. I had them set up initially before I made the reverts and my backup SD. I just forgot to add them back into the script. Now, everything is working.

    TO EVERYBODY OUT THERE!!! DO THIS!! XBOXDRV is the only way to make your controllers work inside Streets of Rage Remix so you can ESCAPE out of the game! Plus, it helped me where my controller couldn't be mapped.

    My next project is figuring out how to map my Atari Joystick to work inside of the Atari800 emulator. I probably have to do the same thing, but I have no idea where to begin. That emulator doesn't have a keyboard backup mapping that I can see, so I'll have to figure out what joystick it's seeking mapping to, and try to get mine to match. Might just need to do a move command on the /dev/input/js# for it, but I'll worry about that when I get there.

    What a load off, this has bugged me for a week. I'm super excited now. So question to @mediamogul .... if I wanted to add a second controller, but keep these assignments, can I just add that as a separate thing in the script? Or do I need to do some fancy foot work to make the driver initialize 2 controllers together? Right now, I'm mapped using my Xbox360 Wireless controller. I ordered, and have arriving on Wednesday, a set of USB plugged Sega 6-button controllers. My plan is to use those when I play, but to have the Xbox working as a backup. I know the game itself is capable of 2 players, with 2 different keyboard mappings. But I don't know where to begin to have 2 controllers running simultaneously.


  • Global Moderator

    @hansolo77

    Man, I hate pine trees. The least little bit of snow and they fall right out of the ground. If you guys don't hear from me in the future, I will have likely met the tree with my name on it.

    Not to worry! I got it! WOO!!!

    Hah! I've just settled in for some serious troubleshooting, but I'm very glad it's working. Going into this you were a bit worried, but you got it without nearly a word from me about it.

    My next project is figuring out how to map my Atari Joystick to work inside of the Atari800 emulator.

    Now that you've done one mapping, they get progressively easier and you'll get more and more creative with all the possibilities afforded to you as well. Before long, you'll have complete control over every aspect if you want to take it that far.

    if I wanted to add a second controller... some fancy foot work to make the driver initialize 2 controllers together?

    Yeah, they will need to run as separate instances. The command you're running now is really just one line, so you could just use a semicolon to add the second command to the same line.



  • Well, I'm just glad I got it working. I had the buttonmap bits wrong. Initially, I had it set to

    BTN_NORTH=KEY_X,BTN_SOUTH=KEY_C
    

    etc, where infact I needed to have it as

    x=KEY_X, a=KEY_C
    

    etc. So you're configuring the long name "evdev" controls, to a short name XBOXDRV one. Then you configure the keymap to be the shortname=actual control. I was trying to use long name=actual control. Once I figured that last bit out, everything started working like it should have.


  • Global Moderator

    @hansolo77

    Bingo, bango, bongo! All in all, you moved through every troubleshooting method I could have recommended. Temporarily removing >dev/null, for example, is a great way to uncover what issues you're having. As complicated as it can get, xboxdvr is pretty verbose about it's errors, which makes solving them pretty easy.



  • @mediamogul Not knowing much about Linux (learning more each day!) and various terminal commands, I don't even know what that >dev/null command does. The > bit looks like something to redirect output, like in DOS/Command Prompt in Windows when you want to say create a text file of a directory listing (dir > list.txt). So my theory is saying we're basically displaying any output generated on the devices (null meaning all). I'm probably way off though. :)

    I'll give you a chance to troubleshoot something for me... My system runs all emulators and games fine until after I run Streets of Rage Remix. Once I return back to ES and try to run a different game, nothing happens. I get the RunCommand screen, then it returns to ES. If I reboot the system, everything is working again. Here's my runcommand.log:

    Parameters: 
    Executing: pushd /opt/retropie/ports/sorr; ./bgdi-330 ./SorR.dat; popd
    /opt/retropie/ports/sorr /home/pi
    /home/pi
    

    So something with my modified launch script is getting mucked up. I don't have that pushd thing in the script at all, so I don't know where that's coming from.


    For the records.. this is my "working" launching script:

    sudo killall xboxdrv
    sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
        --evdev /dev/input/by-id/usb-©Microsoft_Xbox_360_Wireless_Receiver_for_Windows_E1594E70-event-joystick \
        --detach-kernel-driver \
        --silent \
        --force-feedback \
        --deadzone-trigger 15% \
        --deadzone 4000 \
        --mimic-xpad \
        --dpad-as-button \
        --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_RX=x2,ABS_RY=y2,ABS_Z=lt,ABS_RZ=rt \
        --evdev-keymap BTN_SOUTH=a,BTN_EAST=b,BTN_NORTH=x,BTN_WEST=y,BTN_TL=lb,BTN_TR=rb,BTN_THUMBL=tl,BTN_THUMBR=tr,BTN_MODE=guide,BTN_SELECT=back,BTN_START=start,BTN_TRIGGER_HAPPY3=du,BTN_TRIGGER_HAPPY4=dd,BTN_TRIGGER_HAPPY1=dl,BTN_TRIGGER_HAPPY2=dr \
        --ui-buttonmap x=KEY_X,a=KEY_C,b=KEY_V,lb=KEY_A,Y=KEY_S,rb=KEY_D \
        --ui-buttonmap guide=KEY_B,start=KEY_ENTER,back=KEY_ESC \
        --ui-buttonmap du=KEY_UP,dd=KEY_DOWN,dl=KEY_LEFT,dr=KEY_RIGHT \
        -- \
    "/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "sorr" ""
    

  • Global Moderator

    @hansolo77

    Rather than going round and round on the cause, this might be a great opportunity to try the simpler method I had in mind earlier. It's also a much cleaner approach and shouldn't cause the type of conflicts you're currently experiencing. If you're game, go ahead and restore your launch script to the way it was before and add the following to /opt/retropie/configs/all/runcommand-onstart.sh:

    if [ "$1" = "sorr" ]
    then
        sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
        --evdev /dev/input/by-id/usb-©Microsoft_Xbox_360_Wireless_Receiver_for_Windows_E1594E70-event-joystick \
        --detach-kernel-driver \
        --silent \
        --force-feedback \
        --deadzone-trigger 15% \
        --deadzone 4000 \
        --mimic-xpad \
        --dpad-as-button \
        --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_RX=x2,ABS_RY=y2,ABS_Z=lt,ABS_RZ=rt \
        --evdev-keymap BTN_SOUTH=a,BTN_EAST=b,BTN_NORTH=x,BTN_WEST=y,BTN_TL=lb,BTN_TR=rb,BTN_THUMBL=tl,BTN_THUMBR=tr,BTN_MODE=guide,BTN_SELECT=back,BTN_START=start,BTN_TRIGGER_HAPPY3=du,BTN_TRIGGER_HAPPY4=dd,BTN_TRIGGER_HAPPY1=dl,BTN_TRIGGER_HAPPY2=dr \
        --ui-buttonmap x=KEY_X,a=KEY_C,b=KEY_V,lb=KEY_A,Y=KEY_S,rb=KEY_D \
        --ui-buttonmap guide=KEY_B,start=KEY_ENTER,back=KEY_ESC \
        --ui-buttonmap du=KEY_UP,dd=KEY_DOWN,dl=KEY_LEFT,dr=KEY_RIGHT \
    &
    fi
    

    Then add the following to /opt/retropie/configs/all/runcommand-onend.sh:

    sudo killall xboxdrv
    

    When I get some free time to sit down with it, I want to add this simpler and cleaner method to the guide, replacing the steps you had to work through.



  • Ok let me work through this a moment... so runcommand will actually run through the onstart script first.. then if it identifies that the command being launched is sorr then it will execute the script to launch the driver.. then it returns to runcommand to launch the game.. then when it finishes, it will run through the onend script to make sure the driver has been completely removed.

    Sound about right? Seems simple enough to do.


  • Global Moderator

    @hansolo77

    Sound about right?

    More or less, yessir.

    runcommand-onstart.sh always runs when a port/emulator is launched. The if /else statement we're adding to it then looks for $1 (see below) to be "sorr". If it is, it will run the xboxdrv command. The addition to runcommand-onend.shjust breaks it all down afterward, leaving you with your base controller settings. Other variables that can be added to the if / else statement for a variety of other situations are:

    • $1 - the system (eg: atari2600, nes, snes, megadrive, fba, etc).
    • $2 - the emulator (eg: lr-stella, lr-fceumm, lr-picodrive, pifba, etc).
    • $3 - the full path to the rom file.
    • $4 - the full command line used to launch the emulator.


  • My onstart file has this in it already:

    # the line below is needed to use the joystick selection by name method
    bash "/opt/retropie/supplementary/joystick-selection/js-onstart.sh" "$@"
    

    would I move that down and put the if statements above it since the bash doesn't have any?



  • Ok, that didn't work. I can confirm all my other games still work after rebooting, but when I try to launch SORR, it just goes back to the ES screen. It also looks like I lost my runcommand dialog box.



  • How can I test to see if the new changes are working? How do I pass a defined variable into a terminal entry? Something like bash /opt/retropie/configs/all/runcommand-onstart.sh $1=sorr Without some kind of observable interaction, I can't track down the problem.


Log in to reply
 

Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.