RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    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

    Guide: Advanced Controller Mappings

    Scheduled Pinned Locked Moved Help and Support
    joystickcontrollermappingxboxdrvscummvm
    626 Posts 35 Posters 460.7k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mediamogulM
      mediamogul Global Moderator @Riverstorm
      last edited by mediamogul

      @riverstorm said in Guide: Advanced Controller Mappings:

      It feels real good but I would be curious how it compares to the xboxdrv driver restriction.

      I'm hoping to try it out this evening alongside 'Donkey Kong' for this weeks MAME ROW. Without good 4-way restriction, Mario just loses interest half way up the ladders, when you can get him to climb at all.

      it's not the "The Money Pit". I throw out those movie/TV references because none of them are lost on you. ;)

      Ha! Well done sir. That has to hold the record for the most obscure 80s comedy reference on this site. I used to rent that quite a bit back in the day. I always felt like it was half-way educating me to future home life. Along with 'The Volunteers', I personally believe it's Tom Hanks' most underrated comedic movie. I'd even go so far as to say it's Shelly Long's best, although 'Don't Tell Her it's Me' is so bad it almost doubles around to being good again.

      RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

      1 Reply Last reply Reply Quote 0
      • RiverstormR
        Riverstorm
        last edited by

        @mediamogul - lol...and there short ladders too! If you ever write a book I imagine it would be a real hoot to read. Mario making it to the top of the ladder with The Money Pit playing in the background. Sounds like a pretty good evening for me. The club scene has pretty much all but played out for me long ago. Now I am just waiting for my nieces and nephews to be "initiated" into the 21 club and my work is done. Oh the horror stories of those early drinking days at a club. ;) My oldest was there a long time ago and my youngest has a ways to go.

        mediamogulM 1 Reply Last reply Reply Quote 0
        • mediamogulM
          mediamogul Global Moderator @Riverstorm
          last edited by

          @riverstorm

          0_1538802993786_Untitled-1.jpg

          RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

          1 Reply Last reply Reply Quote 0
          • P
            PMac10000 @spud11
            last edited by

            @spud11 Lots of great info here. I am close to achieving my simple goal, which is to restrict my 2x"Dragonrise USB" cabinet sticks to 4-way operation when playing an old-school 4-way arcade game, using the xboxdrv method described. I am attempting a version of spud11's runcommand-onstart.sh script, but the games do not accept any input from the controllers upon launching the emulators... I must be missing something basic.

            To troubleshoot, I can run the simplified script below to attempt to drive Player1's controls with xboxdrv (instead of the recognized DragonRise controller). The script runs successfully and tells me that my XBox/XBox360 controller should now be available at:
            /dev/input/js3
            /dev/input/event7

            Then, in emulationstation I can now "configure input" using the newly detected third Gamepad (called "Player_1_-_4-Way_Joystick_xboxdrv" as expected) and map the Player 1 D-pad and buttons to it, as I did before with the DragonRise inputs.

            However, upon launching (let's say) Donkey Kong from emulationstation, I see the "DragonRise" controller notification and upon controlling Mario, I still have the usual ladder problems.

            I feel like I'm close, but I must be missing something simple. Sorry if I revived a thread that's too old! Thanks in advance.

            #!/bin/sh
            sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
             --evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.1.2:1.0-event-joystick \
             --silent \
             --detach-kernel-driver \
             --deadzone=4000 \
             --deadzone-trigger 15% \
             --force-feedback \
             --mimic-xpad \
             --trigger-as-button \
             --ui-buttonmap lb=void,rb=void,tl=void,tr=void,guide=void,lt=void,rt=void \
             --device-name "Player_1_-_4-Way_Joystick_xboxdrv" \
             --evdev-absmap ABS_X=x1,ABS_Y=y1 \
             --four-way-restrictor \
             --evdev-keymap BTN_THUMB=y,BTN_PINKIE=a,BTN_TOP2=b,BTN_TOP=rb,BTN_TRIGGER=x,BTN_THUMB2=lb,BTN_BASE2=back,BTN_BASE=start,BTN_BASE3=lt \
            &
            
            mediamogulM 1 Reply Last reply Reply Quote 0
            • mediamogulM
              mediamogul Global Moderator @PMac10000
              last edited by

              @PMac10000 said in Guide: Advanced Controller Mappings:

              However, upon launching (let's say) Donkey Kong from emulationstation, I see the "DragonRise" controller notification and upon controlling Mario, I still have the usual ladder problems.

              When using xboxdrv, second virtual controller is created that is mapped to your actual controller. However, the listing for the original controller still exists. It could be that you just need to set 'Player_1_-_4-Way_Joystick_xboxdrv' as the default player one controller.

              RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

              P 1 Reply Last reply Reply Quote 0
              • P
                PMac10000 @mediamogul
                last edited by

                @mediamogul said in Guide: Advanced Controller Mappings:

                When using xboxdrv, second virtual controller is created that is mapped to your actual controller. However, the listing for the original controller still exists. It could be that you just need to set 'Player_1_-_4-Way_Joystick_xboxdrv' as the default player one controller.

                Sorry if this is a dumb question, but where do I set that default? Emulationstation? Xboxdrv parameter? Mame parameter? Retroarch? To a noob like me, It often seems like there are too many bases to cover... thanks.

                mediamogulM S 2 Replies Last reply Reply Quote 0
                • mediamogulM
                  mediamogul Global Moderator @PMac10000
                  last edited by mediamogul

                  @PMac10000 said in Guide: Advanced Controller Mappings:

                  It often seems like there are too many bases to cover.

                  Not a problem. It can be overwhelming for sure. To test, you can first launch 'Donkey Kong' and invoke the RetroArch menu with 'Hotkey+X'. This should put you in the quick menu. Pressing 'B' will take you one menu back. From there, move to the next menu listing to the right named 'Settings' and navigate down to 'Input'. Inside there, you should see a listing for the player one controls and the current input device can be set accordingly. You can then return to 'Donkey Kong' with 'Hotkey+X' and test to see if the ladders are now more manageable.

                  If it worked, you can set the controller as the default from the 'Configuration Editor', located in the RetroPie menu of Emulation Station. That should do the job, but if not, there's also @meleu's 'RetroPie-joystick-selection' tool. Information on its installation and use can be found here.

                  RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

                  1 Reply Last reply Reply Quote 0
                  • S
                    spud11 @PMac10000
                    last edited by spud11

                    @PMac10000 @mediamogul Also, I found it best to map MAME to keys (ie use Tab in game and change input), then map RetroArch to the same keys and do the same in xboxdrv.

                    I've got 4 Dragonrise joysticks working well in this fashion, both in 4 way and 8 way configurations, both cocktail and "normal" modes.

                    RetroPie v4.4.1 • RPi3 Model B • 5.1V 2.5A PSU • 32GB SanDisk Extreme microSD • 2TB Toshiba Canvio Basics Portable USB 3.0 hard drive • 4 x DragonRise USB Arcade joysticks • 2 x TurboTwist spinners • 1 x USB trackball • 1 x PS4 wireless • 1 x 8BitDo Zero

                    mediamogulM P 2 Replies Last reply Reply Quote 1
                    • mediamogulM
                      mediamogul Global Moderator @spud11
                      last edited by

                      @spud11 said in Guide: Advanced Controller Mappings:

                      Also, I found it best to map MAME to keys (ie use Tab in game and change input), then map RetroArch to the same keys and do the same in xboxdrv.

                      Very good advice. I do the same and haven't had any issues.

                      RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

                      S 1 Reply Last reply Reply Quote 0
                      • S
                        spud11 @mediamogul
                        last edited by

                        @mediamogul Yes, it was your advice to me 2 years ago! Best advice ever as you don't have to worry about joystick axes, changing joystick indexes and the like.

                        RetroPie v4.4.1 • RPi3 Model B • 5.1V 2.5A PSU • 32GB SanDisk Extreme microSD • 2TB Toshiba Canvio Basics Portable USB 3.0 hard drive • 4 x DragonRise USB Arcade joysticks • 2 x TurboTwist spinners • 1 x USB trackball • 1 x PS4 wireless • 1 x 8BitDo Zero

                        mediamogulM 1 Reply Last reply Reply Quote 0
                        • mediamogulM
                          mediamogul Global Moderator @spud11
                          last edited by

                          @spud11 said in Guide: Advanced Controller Mappings:

                          Yes, it was your advice to me 2 years ago! Best advice ever...

                          I'm glad it worked out. I also advised someone else to invest heavily in GameStop two years ago and now he has to use wadded up newspaper as shoes. Still, you win some and lose some.

                          RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

                          1 Reply Last reply Reply Quote 3
                          • P
                            PMac10000 @spud11
                            last edited by

                            @spud11 said in Guide: Advanced Controller Mappings:

                            @PMac10000 @mediamogul Also, I found it best to map MAME to keys (ie use Tab in game and change input), then map RetroArch to the same keys and do the same in xboxdrv.

                            I've got 4 Dragonrise joysticks working well in this fashion, both in 4 way and 8 way configurations, both cocktail and "normal" modes.

                            So to sum up, I think you're advising that I need to map individual game inputs anyway. There's no "magic wand" that's just going to launch 4-way games with an xboxdrv 4-way joystick, without additional intervention and configuration on my part.

                            That's OK if so. I think I will just launch xboxdrv 4-way in rc.local (not customizing the runcommand-onstart at all), and map 4-way games within the MAME menu to the "Retropad 3" inputs, which is the xboxdrv virtual 4-way pad. Does this sound like a good approach?

                            One potential glitch... I am noticing that in my setup, the Mame TAB menu does not always appear in all games. For example, it works in Donkey Kong and Defender, but not in Pac-Man or Ms Pac-Man. Any ideas? Thanks.

                            mediamogulM S 2 Replies Last reply Reply Quote 0
                            • mediamogulM
                              mediamogul Global Moderator @PMac10000
                              last edited by

                              @PMac10000 said in Guide: Advanced Controller Mappings:

                              Does this sound like a good approach?

                              Sounds like it could work.

                              One potential glitch... I am noticing that in my setup, the Mame TAB menu does not always appear in all games. For example, it works in Donkey Kong and Defender, but not in Pac-Man or Ms Pac-Man. Any ideas?

                              Are you sure that you're using the same emulator between all the games?

                              RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

                              1 Reply Last reply Reply Quote 0
                              • S
                                spud11 @PMac10000
                                last edited by

                                @PMac10000 In MAME's tab menu, you can set the keys via Input (General), effectively operating for every game.

                                With xboxdrv, in my runcommand-onstart, I've got a full list of every 4 way game (about 200). I'll copy the relevant code a bit later for you. The relevant 4 way xboxdrv code is invoked automatically when I start one of these games

                                This means you don't need to make individualised controls for every 4 way game.

                                RetroPie v4.4.1 • RPi3 Model B • 5.1V 2.5A PSU • 32GB SanDisk Extreme microSD • 2TB Toshiba Canvio Basics Portable USB 3.0 hard drive • 4 x DragonRise USB Arcade joysticks • 2 x TurboTwist spinners • 1 x USB trackball • 1 x PS4 wireless • 1 x 8BitDo Zero

                                P 1 Reply Last reply Reply Quote 0
                                • P
                                  PMac10000 @spud11
                                  last edited by

                                  @spud11 said in Guide: Advanced Controller Mappings:

                                  @PMac10000 In MAME's tab menu, you can set the keys via Input (General), effectively operating for every game.

                                  With xboxdrv, in my runcommand-onstart, I've got a full list of every 4 way game (about 200). I'll copy the relevant code a bit later for you. The relevant 4 way xboxdrv code is invoked automatically when I start one of these games

                                  This means you don't need to make individualised controls for every 4 way game.

                                  Thanks ! I've been working from a simplified version of your code that you posted earlier in the thread. I've been able to manually play a couple games with the 4-way code enabled, and it definitely improves the experience.

                                  However, I'm still unclear how to automate or scale it to other 4-way roms upon launch. The first problem I encounter is that these games are already mapped... for example Player 1 controls are mapped Dragonrise USB controller 0 (called "Retropad 1" by the MAME menu). So when launched with the Xboxdrv 4-way code active, now my Player 1 controls do nothing. UNLESS, I go into each game individually, and use the MAME tab menu to start remapping each Joypad direction and button to "Retropad 3", which is the new virtual 4-way controller. That works, but it seems like a cumbersome way to approach this. I suspect I'm missing a step here...

                                  P 1 Reply Last reply Reply Quote 0
                                  • P
                                    PMac10000 @PMac10000
                                    last edited by

                                    Another thing... with the Xboxdrv controller active, I seem to have lost the ability to exit games with Select + Start, even after remapping the buttons in Mame. (Man, that's a feature I've really come to rely on :-) Also, I've lost the ability to get into the RA menu via Select +X... any ideas are welcome.

                                    S 1 Reply Last reply Reply Quote 0
                                    • S
                                      spud11 @PMac10000
                                      last edited by spud11

                                      @PMac10000 I'm just wondering whether you've set up the keys in Retroarch. I have a bluetooth mini keyboard that I use to test all the keys, including the start and exit keys to make sure they work. Once I've tested these, then I make sure that MAME uses the same keys for Player 1 that I've set in Retroarch and the same keys for Player 2 that I've set in Retroarch, and then I set up xboxdrv to correspond to those keys.

                                      As @mediamogul mentioned previously, it might be worthwhile using @meleu's joystick selection tool so that you can set up the correct Dragonrise joystick for Player 1 and the correct one for Player 2. If you use it, you can set which joystick is Player 1 and which is Player 2 etc. In the /opt/retropie/configs/all folder, I have a joystick-selection.cfg with the following content:

                                      # This file was created by the joystick-selection tool.
                                      # It's recommended to NOT edit it manually.
                                      # The format is pretty simmilar to a retroarch.cfg file, but it contains only
                                      # input_player[1-4]_joypad_index, and accepts "strings" as a value.
                                      # Example:
                                      # input_playerN_joypad_index = "joystick name"
                                      # If "joystick name" is an integer, then the real joystick index is used.
                                      joystick_selection_by_name = "false"
                                      input_player1_joypad_index = "DragonRise Inc.   Generic   USB  Joystick   #3"
                                      input_player2_joypad_index = "DragonRise Inc.   Generic   USB  Joystick   #1"
                                      input_player3_joypad_index = "DragonRise Inc.   Generic   USB  Joystick   #2"
                                      input_player4_joypad_index = "DragonRise Inc.   Generic   USB  Joystick   #4"
                                      

                                      Effectively, my third Dragonrise joystick is Player 1 and my first joystick is Player 2. I'm very careful never to remove the joysticks from the USB hub I have in case the indexes change if I did that. (The order in which the joysticks are attached and the USB ports to which they are connected can make a difference.)

                                      Here is an extract of my retroarch.cfg which appears in the /opt/retropie/configs/all/ folder:

                                      ....
                                      input_player1_a = "x"
                                      input_player1_b = "z"
                                      input_player1_y = "a"
                                      input_player1_x = "s"
                                      input_player1_start = "enter"
                                      input_player1_select = "rshift"
                                      input_player1_l = "q"
                                      input_player1_r = "w"
                                      input_player1_left = "left"
                                      input_player1_right = "right"
                                      input_player1_up = "up"
                                      input_player1_down = "down"
                                      input_exit_emulator = "escape"
                                      ....
                                      input_menu_toggle = "f1"
                                      ....
                                      input_enable_hotkey = "space"
                                      ....
                                      input_player2_b = "alt"
                                      input_player2_b_btn = "5"
                                      input_player2_b_axis = "nul"
                                      input_player2_y = "shift"
                                      input_player2_y_btn = "0"
                                      input_player2_y_axis = "nul"
                                      input_player2_select = "p"
                                      input_player2_select_btn = "nul"
                                      input_player2_select_axis = "nul"
                                      input_player2_start = "i"
                                      input_player2_start_btn = "nul"
                                      input_player2_start_axis = "nul"
                                      input_player2_up = "r"
                                      input_player2_up_btn = "nul"
                                      input_player2_up_axis = "+0"
                                      input_player2_down = "f"
                                      input_player2_down_btn = "nul"
                                      input_player2_down_axis = "-0"
                                      input_player2_left = "d"
                                      input_player2_left_btn = "nul"
                                      input_player2_left_axis = "-1"
                                      input_player2_right = "g"
                                      input_player2_right_btn = "nul"
                                      input_player2_right_axis = "+1"
                                      input_player2_a = "ctrl"
                                      input_player2_a_btn = "1"
                                      input_player2_a_axis = "nul"
                                      input_player2_x = "l"
                                      input_player2_x_btn = "3"
                                      input_player2_x_axis = "nul"
                                      input_player2_l = "n"
                                      input_player2_l_btn = "2"
                                      input_player2_l_axis = "nul"
                                      input_player2_r = "m"
                                      input_player2_r_btn = "4"
                                      input_player2_r_axis = "nul"
                                      input_player2_l2 = "j"
                                      ....
                                      

                                      A few things to bear in mind.

                                      You'll see that I've set up the hotkey and the exit key. My "space" key is the hotkey. My "escape" key is the exit key.

                                      Although I have actually set up my 2 controllers via the Emulationstation configuration menu (and you'll see that because my player 2 buttons ("btn") are defined above), I don't even bother with these any longer "in game". I'm only interested in the keys as MAME (input/general) and xboxdrv all correspond to these Retroarch keys as well.

                                      Below is an extract of my runcommand-onstart.sh for my 4 way and 8 way games for lr-mame2003:

                                      #!/bin/sh
                                      
                                      ### Code begins
                                      ### Game/ROM full path
                                      rom="${3##*/}"
                                      
                                      
                                      ### ARCADE - LR-MAME2003 and LR-MAME2010 and LR-MAME2003PLUS - THIS CORE HAS ITS OWN KEYS SET UP VIA THE TAB MENU - The mappings below enable the joysticks to operate in 4-Way or 8-Way mode depending on the game.  This is a libretro core.
                                      ### First: Using the TAB menu in lr-mame2003, either make note of the default keyboard controls and map the code below accordingly or in TAB map Player 1's and Player 2's controls to the keyboard controls you want and then map the code below.
                                      ### Player1_4Way_Mame2003 and Player2_4Way_Mame2003 map Joysticks 1 and 2 with four way restriction for use with lr-mame2003.
                                      ### Start + Select (Back) is assigned to saving the saved game (F2); Select + Start is assigned to loading the saved game (F4)
                                      
                                      Player1_4Way_Mame2003="sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >> /dev/shm/runcommand.log 2>&1 \
                                      --silent \
                                      --detach-kernel-driver \
                                      --deadzone=4000 \
                                      --deadzone-trigger 15% \
                                      --force-feedback \
                                      --mimic-xpad \
                                      --trigger-as-button \
                                      --ui-buttonmap tl=void,tr=void,guide=void \
                                      --evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.3.3:1.0-event-joystick \
                                      --device-name "Player_1" \
                                      --evdev-absmap ABS_X=y1,ABS_Y=x1 \
                                      --four-way-restrictor \
                                      --evdev-keymap BTN_THUMB2=a,BTN_PINKIE=b,BTN_TRIGGER=x,BTN_THUMB=y,BTN_TOP2=lb,BTN_TOP=rb,BTN_BASE3=back,BTN_BASE6=start,BTN_BASE2=lt,BTN_BASE5=rt \
                                      --ui-axismap X1=KEY_LEFT:KEY_RIGHT,Y1=KEY_UP:KEY_DOWN \
                                      --ui-buttonmap start+back=KEY_F2,back+start=KEY_F4 \
                                      --ui-buttonmap a=KEY_LEFTCTRL,b=KEY_LEFTALT,x=KEY_SPACE,y=KEY_LEFTSHIFT,lb=KEY_UNKNOWN,rb=KEY_UNKNOWN,back=KEY_UNKNOWN,start=KEY_UNKNOWN,back+rt=KEY_SPACE+KEY_ESC,lt=KEY_5+KEY_1,rt=KEY_6+KEY_2 \
                                      --ui-buttonmap lt+rt=exec:/opt/retropie/configs/all/SoundToggle.sh"
                                      
                                      Player2_4Way_Mame2003="sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >> /dev/shm/runcommand.log 2>&1 \
                                      --silent \
                                      --detach-kernel-driver \
                                      --deadzone=4000 \
                                      --deadzone-trigger 15% \
                                      --force-feedback \
                                      --mimic-xpad \
                                      --trigger-as-button \
                                      --ui-buttonmap lb=void,rb=void,tl=void,tr=void,guide=void,lt=void,rt=void \
                                      --evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.3.1:1.0-event-joystick \
                                      --device-name "Player_2" \
                                      --evdev-absmap ABS_X=y1,ABS_Y=x1 \
                                      --four-way-restrictor \
                                      --evdev-keymap BTN_THUMB=a,BTN_TOP=b,BTN_PINKIE=x,BTN_TRIGGER=y,BTN_THUMB2=back,BTN_TOP2=start \
                                      --ui-axismap X1=KEY_D:KEY_G,Y1=KEY_R:KEY_F \
                                      --ui-buttonmap a=KEY_A,b=KEY_S,x=KEY_Q,y=KEY_W,back=KEY_6+KEY_2,start=KEY_UNKNOWN,back+start=KEY_SPACE+KEY_ESC"
                                      
                                      ### Player1_8Way_Mame2003 and Player2_8Way_Mame2003 map Joysticks 1 and 2 with no restriction for use with lr-mame2003
                                      Player1_8Way_Mame2003="sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >> /dev/shm/runcommand.log 2>&1 \
                                      --silent \
                                      --detach-kernel-driver \
                                      --deadzone=4000 \
                                      --deadzone-trigger 15% \
                                      --force-feedback \
                                      --mimic-xpad \
                                      --trigger-as-button \
                                      --ui-buttonmap tl=void,tr=void,guide=void \
                                      --evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.3.3:1.0-event-joystick \
                                      --device-name "Player_1" \
                                      --evdev-absmap ABS_X=y1,ABS_Y=x1 \
                                      --evdev-keymap BTN_THUMB2=a,BTN_PINKIE=b,BTN_TRIGGER=x,BTN_THUMB=y,BTN_TOP2=lb,BTN_TOP=rb,BTN_BASE3=back,BTN_BASE6=start,BTN_BASE2=lt,BTN_BASE5=rt \
                                      --ui-axismap X1=KEY_LEFT:KEY_RIGHT,Y1=KEY_UP:KEY_DOWN \
                                      --ui-buttonmap start+back=KEY_F2,back+start=KEY_F4 \
                                      --ui-buttonmap a=KEY_LEFTCTRL,b=KEY_LEFTALT,x=KEY_SPACE,y=KEY_LEFTSHIFT,lb=KEY_UNKNOWN,rb=KEY_UNKNOWN,back=KEY_UNKNOWN,start=KEY_UNKNOWN,back+rt=KEY_SPACE+KEY_ESC,lt=KEY_5+KEY_1,rt=KEY_6+KEY_2 \
                                      --ui-buttonmap lt+rt=exec:/opt/retropie/configs/all/SoundToggle.sh"
                                      
                                      Player2_8Way_Mame2003="sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >> /dev/shm/runcommand.log 2>&1 \
                                      --silent \
                                      --detach-kernel-driver \
                                      --deadzone=4000 \
                                      --deadzone-trigger 15% \
                                      --force-feedback \
                                      --mimic-xpad \
                                      --trigger-as-button \
                                      --ui-buttonmap lb=void,rb=void,tl=void,tr=void,guide=void,lt=void,rt=void \
                                      --evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.3.1:1.0-event-joystick \
                                      --device-name "Player_2" \
                                      --evdev-absmap ABS_X=y1,ABS_Y=x1 \
                                      --evdev-keymap BTN_THUMB=a,BTN_TOP=b,BTN_PINKIE=x,BTN_TRIGGER=y,BTN_THUMB2=back,BTN_TOP2=start \
                                      --ui-axismap X1=KEY_D:KEY_G,Y1=KEY_R:KEY_F \
                                      --ui-buttonmap a=KEY_A,b=KEY_S,x=KEY_Q,y=KEY_W,back=KEY_6+KEY_2,start=KEY_UNKNOWN,back+start=KEY_SPACE+KEY_ESC"
                                      
                                      case $2 in
                                      
                                      ### Arcade
                                      
                                      	lr-mame2003)
                                      	case $rom in
                                      			"alibaba.zip"|"amidar.zip"|"armwrest.zip"|"astinvad.zip"|"atetris.zip"|"anteater.zip"|"armorcar.zip"|"astrob.zip"|"astrof.zip"|"bagman.zip"|"ballbomb.zip"|"barrier.zip"|"blkhole.zip"|"blasto.zip"|"blockade.zip"|"btime.zip"|"carjmbre.zip"|"carnival.zip"|"cavelon.zip"|"chameleo.zip"|"checkman.zip"|"chinhero.zip"|"circusc.zip"|"ckong.zip"|"commando.zip"|"congo.zip"|"dazzler.zip"|"devilfsh.zip"|"digdug.zip"|"digdug2.zip"|"digger.zip"|"disco.zip"|"dkong.zip"|"dkong3.zip"|"dkongjr.zip"|"docastle.zip"|"dommy.zip"|"dorodon.zip"|"frogger.zip"|"galaga.zip"|"galaxian.zip"|"galxwars.zip"|"guzzler.zip"|"invrvnge.zip"|"invinco.zip"|"jjack.zip"|"joust2.zip"|"jrpacman.zip"|"jumpcoas.zip"|"jungler.zip"|"kchamp.zip"|"kicker.zip"|"kingball.zip"|"ladybug.zip"|"lasso.zip"|"levers.zip"|"lnc.zip"|"locomotn.zip"|"logger.zip"|"lrescue.zip"|"lupin3.zip"|"mappy.zip"|"marvins.zip"|"mikie.zip"|"mmonkey.zip"|"monsterb.zip"|"moonal2.zip"|"moonqsr.zip"|"mrdo.zip"|"mrflea.zip"|"mrjong.zip"|"mrtnt.zip"|"mspacman.zip"|"mystston.zip"|"naughtyb.zip"|"netwars.zip"|"olibochu.zip"|"ozmawars.zip"|"pacnpal.zip"|"pacplus.zip"|"pengo.zip"|"perestro.zip"|"pickin.zip"|"pignewt.zip"|"pisces.zip"|"pleiads.zip"|"pooyan.zip"|"popflame.zip"|"puckman.zip"|"pacman.zip"|"pulsar.zip"|"qbert.zip"|"qbertqub.zip"|"qix.zip"|"radarscp.zip"|"retofinv.zip"|"rocnrope.zip"|"route16.zip"|"samurai.zip"|"tsamurai.zip"|"scregg.zip"|"sindbadm.zip"|"solarfox.zip"|"sonofphx.zip"|"invadpt2.zip"|"panic.zip"|"shollow.zip"|"spclaser.zip"|"sqbert.zip"|"streakng.zip"|"sbagman.zip"|"superpac.zip"|"superqix.zip"|"ssi.zip"|"swat.zip"|"tactcian.zip"|"tankbatt.zip"|"taxidrvr.zip"|"elecyoyo.zip"|"theend.zip"|"timelimt.zip"|"tomahawk.zip"|"todruaga.zip"|"tranqgun.zip"|"triplep.zip"|"tutankhm.zip"|"vanvan.zip"|"volfied.zip"|"vsgongf.zip"|"wiping.zip"|"warpwarp.zip"|"zigzag.zip"|"zzyzzyxx.zip"|"alphaho.zip"|"pacnchmp.zip"|"comotion.zip"|"copsnrob.zip"|"cosmicg.zip"|"cosmos.zip"|"crash.zip"|"crush.zip"|"redufo.zip"|"diamond.zip"|"dorunrun.zip"|"dominos.zip"|"drmicro.zip"|"drgnbstr.zip"|"dremshpr.zip"|"elvactr.zip"|"eyes.zip"|"firetrap.zip"|"40love.zip"|"galpanic.zip"|"gundealr.zip"|"hardhat.zip"|"headon.zip"|"headon2.zip"|"heiankyo.zip"|"hexa.zip"|"hustle.zip"|"intrepid.zip"|"ironhors.zip"|"karianx.zip"|"kungfum.zip"|"lvgirl94.zip"|"logicpro.zip"|"logicpr2.zip"|"msjiken.zip"|"kikcubic.zip"|"mineswpr.zip"|"mtrap.zip"|"dowild.zip"|"mrgoemon.zip"|"natodef.zip"|"rallyx.zip"|"nrallyx.zip"|"pepper2.zip"|"pettanp.zip"|"popeye.zip"|"punchout.zip"|"raiders5.zip"|"rampage.zip"|"reikaids.zip"|"robby.zip"|"rthunder.zip"|"sidetrac.zip"|"schaser.zip"|"spaceinv.zip"|"spacezap.zip"|"spectar.zip"|"springer.zip"|"stratvox.zip"|"sia2650.zip"|"spnchout.zip"|"tapper.zip"|"rbtapper.zip"|"targ.zip"|"telmahjn.zip"|"theglob.zip"|"thief.zip"|"timber.zip"|"toypop.zip"|"wwjgtin.zip"|"wndrmomo.zip"|"yamyam.zip"|"zerozone.zip"|"zookeep.zip"|"pairs.zip"|"higemaru.zip"|"elecyoy2.zip"|"arkangc.zip"|"arkanoid.zip"|"arkatayt.zip"|"arkatour.zip"|"arkbl2.zip"|"arkbl3.zip"|"arkbloc2.zip"|"arkblock.zip"|"arknid2j.zip"|"arknid2u.zip"|"arknoid2.zip"|"arknoidj.zip"|"arknoidu.zip"|"arknoiuo.zip"|"arkretrn.zip"|"tempest.zip"|"tempest1.zip"|"tempest2.zip"|"tempest3.zip"|"temptube.zip") # Configuration only for these ROMs.
                                      				$xboxkill
                                      				joycommand="$Player1_4Way_Mame2003 & $Player2_4Way_Mame2003 &"
                                      				eval $joycommand
                                      			;;
                                      			*) # Configuration for every other ROM..
                                      				$xboxkill
                                      				joycommand="$Player1_8Way_Mame2003 & $Player2_8Way_Mame2003 &"
                                      				eval $joycommand
                                      			;;
                                      		esac
                                      	;;
                                      

                                      Things to note:
                                      (a) all the 4 way arcade games are listed by romname. Those games use the 4 way restricted configuration. All other games use the 8 way restricted configuration;
                                      (b) It's very important to name your xboxdrv configurations I find, so you know what joystick is Player 1 and what joystick is Player 2;
                                      (c) I've got 10 buttons on my arcade for Player 1. These buttons are mapped to keys. Because of their location, I wound up mapping the buttons I assigned to "back/select" and "right trigger" (rt) to exit - back+rt=KEY_SPACE+KEY_ESC. Note that if I press these 2 buttons together it triggers the "space" and "escape" keys which are the same keys set up in Retroarch for the hotkey and the exit button. So when I press these buttons together, the game will exit;
                                      (d) In MAME, I have made sure that movement for Player 1 is via the arrow keys. You will see that that corresponds to my Retroarch settings and also corresponds to the settings in xboxdrv - --ui-axismap X1=KEY_LEFT:KEY_RIGHT,Y1=KEY_UP:KEY_DOWN \ etc etc. In MAME, Player 2's movement keys are D, G, R and F. Again, in Retroarch you will see the same keys are set for movement and the same for xboxdrv - --ui-axismap X1=KEY_D:KEY_G,Y1=KEY_R:KEY_F \ etc etc
                                      (e) As long as everything corresponds, it should work.

                                      So, if you haven't already done so, I'd recommend either going into Retroarch and setting up the keys as I did or make a backup of your retroarch.cfg and manually changing that file. (I always do the latter using WinSCP.)

                                      Then test and see if it works.

                                      I hope this helps.

                                      RetroPie v4.4.1 • RPi3 Model B • 5.1V 2.5A PSU • 32GB SanDisk Extreme microSD • 2TB Toshiba Canvio Basics Portable USB 3.0 hard drive • 4 x DragonRise USB Arcade joysticks • 2 x TurboTwist spinners • 1 x USB trackball • 1 x PS4 wireless • 1 x 8BitDo Zero

                                      P 1 Reply Last reply Reply Quote 0
                                      • P
                                        PMac10000 @spud11
                                        last edited by

                                        @spud11 Thanks for the detailed response. I am trying to test in my simplified setup... I have only the two Dragonrise joysticks with 6-buttons + Start and Select for each player. Joystick #1 is set to Player 1, and #2 is set to Player 2 (set and confirmed by @meleu tool). Again, my only goal is to launch 4-way joystick games from ES with the 4-way driver code, and (hopefully) not change much else about my setup. Most of my arcade games utilize lr-mame2003, some others (like the Pac-Man family) from fba. That may be complicating things somewhat.

                                        I also have edited my retroarch.cfg file with the exact mappings you supplied above. Still having some trouble launching xboxdrv from your runcommand-onstart code. I can launch xboxdrv just fine from a command line, and successfully create the virtual 4-way joystick:
                                        Your Xbox/Xbox360 controller should now be available as:
                                        /dev/input/js3
                                        /dev/input/event7

                                        Whenever I try to launch xboxdrv from your runcommand-onstart.sh I get a "driver or resource busy" error, so I need to work on that a bit.

                                        I think the jist of what you're advising is that keyboard mapping is the "lowest common denominator" of the various layers that need to be aligned (Retroarch, Mame, Xboxdrv), so it makes sense to define a common keyboard map for all the buttons in Retroarch, and then configure Mame and Xboxdrv to match the keyboard. Is that right?

                                        So far though, no luck, at least in the fba games where I cannot launch the RA menu no matter what I do, when the xboxdrv is active. (without xboxdrv, I just hit Select+X) . Player 1 Joysticks and buttons don't respond at all. In the mame games, I can use the keyboard to launch the tab menu and I can make progress with the 4-way games. Below is the xboxdrv parameters I've been successfully launching manually.

                                        #!/bin/sh
                                        sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
                                         --evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.1.2:1.0-event-joystick \
                                         --silent \
                                         --detach-kernel-driver \
                                         --deadzone=4000 \
                                         --deadzone-trigger 15% \
                                         --force-feedback \
                                         --mimic-xpad \
                                         --trigger-as-button \
                                         --ui-buttonmap lb=void,rb=void,tl=void,tr=void,guide=void,lt=void,rt=void \
                                         --device-name "Player_1_-_4-Way_Joystick_xboxdrv" \
                                         --evdev-absmap ABS_X=x1,ABS_Y=y1 \
                                         --four-way-restrictor \
                                         --evdev-keymap BTN_THUMB=y,BTN_PINKIE=a,BTN_TOP2=b,BTN_TOP=rb,BTN_TRIGGER=x,BTN_THUMB2=lb,BTN_BASE2=back,BTN_BASE=start,BTN_BASE3=lt \
                                        &
                                        
                                        S 1 Reply Last reply Reply Quote 0
                                        • S
                                          spud11 @PMac10000
                                          last edited by

                                          @PMac10000 Hi. You are doing very well on this.

                                          Yes, to your question. "....so it makes sense to define a common keyboard map for all the buttons in Retroarch, and then configure Mame and Xboxdrv to match the keyboard. Is that right?" Yes.

                                          Just off to work, but things to note:

                                          (a) Not sure about the driver or resource busy error;
                                          (b) Unlike lr-mame2003, FBA doesn't use the TAB interface. With FBA, it should be enough just to map the keys in Retroarch and in xboxdrv;
                                          (b) You need to add the actual keymapping to your xboxdrv command. The 2 lines that you need (with modifications at least to the "button mapping" because you have 6 buttons whilst I have 10) are:

                                          --ui-axismap X1=KEY_LEFT:KEY_RIGHT,Y1=KEY_UP:KEY_DOWN \
                                          --ui-buttonmap a=KEY_LEFTCTRL,b=KEY_LEFTALT,x=KEY_SPACE,y=KEY_LEFTSHIFT,lb=KEY_UNKNOWN,rb=KEY_UNKNOWN,back=KEY_UNKNOWN,start=KEY_UNKNOWN,back+rt=KEY_SPACE+KEY_ESC,lt=KEY_5+KEY_1,rt=KEY_6+KEY_2 \
                                          

                                          RetroPie v4.4.1 • RPi3 Model B • 5.1V 2.5A PSU • 32GB SanDisk Extreme microSD • 2TB Toshiba Canvio Basics Portable USB 3.0 hard drive • 4 x DragonRise USB Arcade joysticks • 2 x TurboTwist spinners • 1 x USB trackball • 1 x PS4 wireless • 1 x 8BitDo Zero

                                          P 1 Reply Last reply Reply Quote 0
                                          • ?
                                            A Former User @mediamogul
                                            last edited by

                                            @mediamogul said in Guide: Advanced Controller Mappings:

                                            Something that's always bothered me about launching xboxdrv using runcommand-onstart.sh is that it makes using the Runcommand menu itself somewhat impossible. This is because the xboxdrv mapping is made active before the Runcommand menu appears, therefore interfering with the expected control scheme. Over the weekend, I've been experimenting with some ways around this.

                                            First, I tried scripting the xboxdrv command not to launch until it detected that the intended emulator/port had launched. This worked well, except the script needed the specific executable name for the software it was looking for, making everything a little more laborous to set up than I felt it needed to be. I was prepared to live with it, until I noticed that AdvanceMame refused to recognized an xboxdrv simulated mouse event unless it was present before it launched. Seeing as how I play many games that rely on analog controls, it was important enough for me to rethink the approach.

                                            What I needed was something that could be discovered from the runcommand-onstart.sh script that signals the launch of the Runcommand menu, yet yet also signals it's closing before the emulator/port software is launched. After taking a look at /opt/retropie/supplementary/runcommand/runcommand.sh, it looked as though it invoked and exited joy2key.py in exactly the way I needed. With a little more experimenting, I came up with the following that uses the xboxdrv example from the first section of my guide.

                                            if [ "$2" = "advmame" ]; then
                                            sudo killall > /dev/null 2>&1 xboxdrv
                                            j2kpid="0"
                                            until [ "$j2kpid" -gt "0" ]; do
                                            j2kpid=$(pgrep -f joy2key.py)
                                            sleep 1
                                            done
                                            while s=$(ps -p "$j2kpid" -o s=) && [ "$s" ] && [ "$s" != 'Z' ]; do
                                            sleep 1
                                            done
                                            /opt/retropie/supplementary/xboxdrv/bin/xboxdrv > /dev/null 2>&1 \
                                            	--evdev /dev/input/by-id/[•] \
                                            	--silent \
                                            	--detach-kernel-driver \
                                            	--force-feedback \
                                            	--deadzone-trigger 15% \
                                            	--deadzone 4000 \
                                            	--mimic-xpad \
                                            	--evdev-absmap ABS_[•]=x1,ABS_[•]=y1,ABS_[•]=x2,ABS_[•]=y2,ABS_[•]=lt,ABS_[•]=rt,ABS_[•]=dpad_x,ABS_[•]=dpad_y \
                                            	--evdev-keymap BTN_[•]=a,BTN_[•]=b,BTN_[•]=x,BTN_[•]=y,BTN_[•]=lb,BTN_[•]=rb,BTN_[•]=tl,BTN_[•]=tr,BTN_[•]=guide,BTN_[•]=back,BTN_[•]=start
                                            fi &
                                            
                                            

                                            This waits for joy2key.py to launch, gets it's PID and then waits for it to end before launching whatever emulator/port is being launched (advmame in this example). So, in effect, you can now launch a game, use the Runcommand window as intended if needed and xboxdrv will launch afterwards.

                                            I've talked with so many people about xboxdrv on here that, unfortunately, a lot of it runs together. However, I do remember a few interested parties looking for a way to accomplish this, so I hope it helps. Granted there might be an easier, more effective way, so if anything comes to mind, please feel free to share.

                                            Now that I'm using xboxdrv I'm noticing this as well. Can't change emulators or interrupt launching. I would have thought it was just a change of ordering (show dialog and then do the onstart), but from what you've described, it doesn't seem that straightforward.

                                            mediamogulM 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            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.