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 479.9k 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.
    • G
      grant2258 Banned @mediamogul
      last edited by

      @mediamogul said in Guide: Advanced Controller Mappings:

      @grant2258 said in Guide: Advanced Controller Mappings:

      so if you go right then press right/up you will keep on going right )or last direction pressed until you commit to another direction.

      This seems like a perfectly reasonable solution, but for whatever reason, the xboxdrv 4-way restriction doesn't seem to behave this way. With it, control is very precise on quick turns without any necessary forethought on how to to adapt to a new control behavior. The result feels very close to an actual restriction plate. All that said, I have no idea what is used in xboxdrv to accomplish this.

      Your probably using it on an analog stick. try it on a none analog device analog is easier to track. digital only has 8 positions so this analog logic won't work on a sanwa or dpad tgat is what mame addresses

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

        @grant2258 said in Guide: Advanced Controller Mappings:

        Your probably using it on an analog stick.

        I am indeed and you're completely right. I don't remember if it's come up in conversation before, but MAME actually had it's own implementation of software 4-way restriction at one time. I believe the reason for its removal was that no one could agree on the best way to implement it effectively. While it might not be perfect, you're solution may very well be the best solution for most situations.

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

        G 1 Reply Last reply Reply Quote 0
        • G
          grant2258 Banned @mediamogul
          last edited by

          @mediamogul the biggest problem is people using a square 8 way restriction plate that why i use circular one now less throw for shoot em ups as well. so you use the joystick rather than ride the restrictor. I would recommend a hexagonal you need help with finding you up/right ect. It is personal preference at the end of the day.

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

            @spud11
            Hard to say exactly where it went wrong, but I had modified so many scripts, cfg files, and parameters (xboxdrv, retroarch, mame) that I had to surrender and start over. I'll have a go again with a clean slate, and lean on your troubleshooting skills. Would it help to know how my particular buttons are wired as xboxdrv sees them? for example I can correlate THUMB2 with jstest value with X/Y/A/B, and so on...

            Since your setup is so similar to mine, I'm wondering if you've had a chance to try out the built-in 4-way emulation in lrmame2003, and compare and contrast the gameplay experience with the xboxdrv approach. Thanks

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

              @mediamogul Hi mediamogul. I've come across a problem I haven't been able to solve. I've manually compiled/installed the GSplus emulator (Apple IIGS) for my Jessie-based Rpi3B. GSPlus's internal joystick configuration doesn't work well, but most games have keyboard commands. I'm using xboxdrv to "tie" my DragonRise arcade joysticks to the keyboard. However, Gauntlet, for example, uses 8 keys for 8 directions (including diagonals). I'm not sure how to replicate that with xboxdrv. At present, I can only move left/right/up/down, not diagonally. I wonder whether you could help please.

              Is there a way to get --ui-axismap X1=KEY_LEFT:KEY_RIGHT,Y1=KEY_UP:KEY_DOWN \ to reflect diagonal directions too?

              Thanks.

              Player1_appleIIGS="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 \
              --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 \
              --ui-axismap X1=KEY_LEFT:KEY_RIGHT,Y1=KEY_UP:KEY_DOWN \
              --evdev-keymap BTN_THUMB2=a,BTN_PINKIE=b,BTN_BASE3=back,BTN_BASE6=start,BTN_BASE5=rt \
              --ui-buttonmap a=KEY_OPTION,b=KEY_KPDOT,x=KEY_UNKNOWN,y=KEY_UNKNOWN,back=KEY_UNKNOWN,start=KEY_UNKNOWN,rt=KEY_ENTER,rt+back=KEY_F4 \
              --ui-buttonmap back+rt=exec:/opt/retropie/configs/all/gsplus_exit.sh \
              --ui-buttonmap lt+rt=exec:/opt/retropie/configs/all/SoundToggle.sh"
              

              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

                I'm pretty sure axis input can't be mapped in that way. To my understanding, you could really only map eight arbitrary keys to a DPad, making use of the --dpad-as-button argument and then combo mappings such as du+dl=KEY_W.

                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 spud11

                  @mediamogul Thanks for that. That puts me on the right track. This zero delay arcade encoder has a "mode" button which apparently switches the joystick from analog to digital. I hadn't bothered to hook up a button to "mode" so far, so I'll investigate that and see whether I can get the joystick into digital mode and then have a crack with those xboxdrv settings you have suggested.

                  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 mediamogul

                    @spud11
                    One other thing worth mentioning is that you might want to map the two possible combinations for all four diagonals to avoid any dead input. So if you mapped du+dl=KEY_W, you would also map dl+du=KEY_W. That way, no matter which direction you happened to hit first in the combo, the intended action would still take place.

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

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

                      @mediamogul Thanks for that. That really helped. I attached a button to the "mode" port and, using xboxdrv, I can now switch between analog and digital on the fly with the code being:

                      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 x=void,y=void,lb=void,rb=void,tl=void,tr=void,guide=void,lt=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 \
                      --ui-axismap X1=KEY_LEFT:KEY_RIGHT,Y1=KEY_UP:KEY_DOWN \
                      --evdev-absmap ABS_HAT0X=dpad_y,ABS_HAT0Y=dpad_x \
                      --dpad-as-button \
                      --evdev-keymap BTN_THUMB2=a,BTN_PINKIE=b,BTN_BASE3=back,BTN_BASE6=start,BTN_BASE5=rt \
                      --ui-buttonmap du=KEY_M,dd=KEY_I,dl=KEY_J,dr=KEY_L,du+dl=KEY_N,dl+du=KEY_N,du+dr=KEY_COMMA,dr+du=KEY_COMMA,dd+dr=KEY_O,dr+dd=KEY_O,dd+dl=KEY_U,dl+dd=KEY_U,a=KEY_OPTION,b=KEY_SPACE,x=KEY_UNKNOWN,y=KEY_UNKNOWN,back=KEY_UNKNOWN,start=KEY_UNKNOWN,rt=KEY_ENTER,rt+back=KEY_F4 \
                      --ui-buttonmap back+rt=exec:/opt/retropie/configs/all/gsplus_exit.sh \
                      --ui-buttonmap lt+rt=exec:/opt/retropie/configs/all/SoundToggle.sh
                      

                      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

                        Very nice.

                        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 spud11

                          @mediamogul Hi. I was wondering please whether you could help. I've got what I thought would be a fairly simple problem, but can't find a solution. For my various MAME setups, I press the lt button on my arcade and it will effectively press the 5and 1 keys and start a single player game. If I press the rt button, it presses the 6 and 2 keys and starts a 2 player game. It's a nice and simple setup.

                          I'm trying to do the same with the libretro FBA cores using the back button, but for some reason, it will not work. Pressing the back button should insert Coin 1 (right shift) and start Player 1 (enter) automatically. However, I find that I have to press the back button twice to achieve this instead of only once.

                          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.2:1.0-event-joystick \
                          --device-name "Player_3" \
                          --evdev-absmap ABS_X=x1,ABS_Y=y1 \
                          --evdev-keymap BTN_THUMB=a,BTN_TOP=b,BTN_PINKIE=x,BTN_TRIGGER=y,BTN_THUMB2=back,BTN_TOP2=start \
                          --ui-axismap X1=KEY_DOWN:KEY_UP,Y1=KEY_RIGHT:KEY_LEFT \
                          --ui-buttonmap a=KEY_Z,b=KEY_X,x=KEY_S,y=KEY_A,back=KEY_RIGHTSHIFT+KEY_ENTER,start=KEY_P+KEY_I,start+back=KEY_SPACE+KEY_F1,back+start=KEY_SPACE+KEY_ESC \
                          

                          I've also tried using a macro instead using

                          --ui-buttonmap back=macro:/opt/retropie/configs/all/fba_start_player1.macro \
                          

                          and the macro:

                          send KEY_RIGHTSHIFT 1
                          wait 500
                          send KEY_ENTER 1
                          

                          Strangely, the macro produces no result at all when I press the back button.

                          Would you have any idea please what might be the problem or other things I could try?

                          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

                            I'm not sure if I've ever run into that exact specific issue myself, but I seem to remember that assigning a hotkey combo shared with the 'insert coin' function could get a bit squirrely with some of my various arcade setups in the past. I don't think I ever overcame the issue, as none of my current setups include 'insert coin' in a key combo.

                            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 spud11

                              @mediamogul said in Guide: Advanced Controller Mappings:

                              @spud11 said in Guide: Advanced Controller Mappings:

                              One other possibility I was thinking...

                              I'm almost certain xboxdrv can't bind keyboard keys with other keys/key combinations, but if you could find an outside solution to handle that part, it should work well.

                              I thought I'd let you know that I finally figured out how to exit Moonlight at both ends using xboxdrv - server and client side. (It may be that Moonlight has been updated since I last posted on this so this is now a non-issue, but my version of Moonlight and Retropie are quite old).

                              I've got a macro set up in my xboxdrv configuration:

                              --ui-buttonmap back+rt=macro:/home/pi/RetroPie/roms/steam/MS_exit.macro \
                              

                              The macro has the following content:

                              wait 100
                              send KEY_ESC 1
                              wait 100
                              send KEY_ESC 0
                              
                              
                              send KEY_LEFTSHIFT 1
                              send KEY_LEFTALT 1
                              send KEY_LEFTCTRL 1
                              send KEY_Q 1
                              wait 100
                              send KEY_LEFTSHIFT 0
                              send KEY_LEFTALT 0
                              send KEY_LEFTCTRL 0
                              send KEY_Q 0
                              

                              This first sends the ESC key and then sends Shift+CTRL+ALT+Q to fully exit Moonlight, on both client and server sides, effectively using one button press instead of the 2 we were using when using the "cycling" technique.

                              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

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

                                @mediamogul I've also solved my problem with the libretro FBA cores by using a similar technique. I can press 1 button and it will both insert a coin and start the game without having to press a second time. The macro looks like this:

                                wait 100
                                send KEY_RIGHTSHIFT 1
                                wait 100
                                send KEY_RIGHTSHIFT 0
                                wait 100
                                send KEY_ENTER 1
                                wait 100
                                send KEY_ENTER 0
                                

                                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

                                1 Reply Last reply Reply Quote 0
                                • D
                                  daanv98
                                  last edited by daanv98

                                  I have an arcade cabinet with 2 zero-delay encoders, containing a total of 16 buttons and 2 joysticks, and I am trying to use dosbox without needing a keyboard nor a mouse. With the default dosbox-mapper, multiple buttons have been set up as standard keyboard buttons and there is a dedicated exit button. Also 1 joystick functions as the arrow keys. By using xboxdrv I am trying to let the second joystick function as a mouse and to let 2 buttons function as mouse presses. I did evtest to write down all the button events. I made a file in /opt/retropie/configs/all/ called runcommand-onstart.sh and started with

                                  if [ "$1" = "dosbox" ]
                                  then
                                  sudo killall >> /dev/shm/runcommand.log 2>&1 xboxdrv
                                  sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >> /dev/shm/runcommand.log 2>&1 \
                                     --evdev /dev/input/event[1] \
                                  

                                  However I am stuck after this part. Can anyone help me with setting up the mapping file further? If possible only mouse-movement and a left- and rightclick must be added, as the rest of the buttons is already mapped with the default dosbox mapper. Thank you in advance!

                                  ExarKunIvE 1 Reply Last reply Reply Quote 0
                                  • ExarKunIvE
                                    ExarKunIv @daanv98
                                    last edited by

                                    @daanv98

                                    if you add this to what you have posted (of course change to match your system)

                                    if [ "$3" = "/home/pi/RetroPie/roms/pc/Shadow Warrior.sh" ]
                                    then
                                    sudo killall > /dev/null 2>&1 xboxdrv
                                    sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv > /dev/null 2>&1 \
                                        --evdev /dev/input/event4 \
                                    	--silent \
                                    	--detach-kernel-driver \
                                    	--force-feedback \
                                    	--mimic-xpad \
                                    	--dpad-as-button \
                                    	--deadzone 4000 \
                                    	--trigger-as-button \
                                    	--evdev-no-grab \
                                    	--evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RZ=y2,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y \
                                    	--evdev-keymap KEY_#304=a,KEY_#305=b,KEY_#307=x,KEY_#308=y,KEY_#312=lt,KEY_#313=rt,KEY_#310=lb,KEY_#311=rb,KEY_#317=tl,KEY_#318=tr,KEY_#314=back,KEY_#315=start \
                                    	--axismap -Y1=Y1,-Y2=Y2 \
                                    	--ui-axismap x2=REL_X:09,y2=REL_Y:09 \
                                    	--ui-axismap x1=REL_X:07,y1=REL_Y:07 \
                                    	--ui-buttonmap rt=BTN_LEFT,lt=BTN_RIGHT,start=KEY_ENTER,back=KEY_ESC,tl=KEY_SPACE,lb=KEY_E,a=KEY_SEMICOLON,b=KEY_APOSTROPHE,x=KEY_LEFTBRACE,y=KEY_RIGHTBRACE,tr=KEY_LEFTCTRL \
                                    	--ui-buttonmap guide=void \
                                    	--ui-axismap x1=KEY_A:KEY_D,Y1=KEY_W:KEY_S \
                                    &
                                    fi
                                    

                                    and make sure you have a runcommand-onend.sh as the guide says. you should be good

                                    RPi3B+ / 200GB/ RetroPie v4.5.14, RPi4 Model B 4gb / 256gb / RetroPie 4.8.2
                                    RPi5 4gb / 512gb / RetroPie 4.8.9 -Basic
                                    Maintainer of RetroPie-Extra .

                                    D 1 Reply Last reply Reply Quote 0
                                    • D
                                      daanv98 @ExarKunIv
                                      last edited by

                                      @ExarKunIv thank you! I assume this mapping file is written for a computer keyboard, so all I have to change is the event number and the button names? If I see correctly, the line starting with evdev-absmap assigns the mouse movement to button presses, but can you also tell me where the mouse clicks are assigned to a button?

                                      ExarKunIvE 1 Reply Last reply Reply Quote 0
                                      • ExarKunIvE
                                        ExarKunIv @daanv98
                                        last edited by

                                        @daanv98

                                        these are from the controller.

                                        --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RZ=y2,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y \
                                        	--evdev-keymap KEY_#304=a,KEY_#305=b,KEY_#307=x,KEY_#308=y,KEY_#312=lt,KEY_#313=rt,KEY_#310=lb,KEY_#311=rb,KEY_#317=tl,KEY_#318=tr,KEY_#314=back,KEY_#315=start \
                                        	--axismap -Y1=Y1,-Y2=Y2 \
                                        

                                        these are what you want the button presses to do

                                        --ui-axismap x2=REL_X:09,y2=REL_Y:09 \
                                        	--ui-axismap x1=REL_X:07,y1=REL_Y:07 \
                                        	--ui-buttonmap rt=BTN_LEFT,lt=BTN_RIGHT,start=KEY_ENTER,back=KEY_ESC,tl=KEY_SPACE,lb=KEY_E,a=KEY_SEMICOLON,b=KEY_APOSTROPHE,x=KEY_LEFTBRACE,y=KEY_RIGHTBRACE,tr=KEY_LEFTCTRL \
                                        	--ui-buttonmap guide=void \
                                        	--ui-axismap x1=KEY_A:KEY_D,Y1=KEY_W:KEY_S \
                                        

                                        and these are your mouse buttons

                                        --ui-buttonmap rt=BTN_LEFT,lt=BTN_RIGHT
                                        

                                        i have gotten away from doing my mapping this way since is was confusing even for me
                                        but if you only need it for one system it works great

                                        RPi3B+ / 200GB/ RetroPie v4.5.14, RPi4 Model B 4gb / 256gb / RetroPie 4.8.2
                                        RPi5 4gb / 512gb / RetroPie 4.8.9 -Basic
                                        Maintainer of RetroPie-Extra .

                                        D 1 Reply Last reply Reply Quote 0
                                        • D
                                          daanv98 @ExarKunIv
                                          last edited by

                                          @ExarKunIv Ah I think I understand now! I will try it soon. One last question: if except for the mouse and its buttons all other buttons are already assigned via the dosbox mapper. Can I just leave those buttons away, or won't they work untill I add them to this mapping file?

                                          ExarKunIvE 1 Reply Last reply Reply Quote 0
                                          • ExarKunIvE
                                            ExarKunIv @daanv98
                                            last edited by

                                            @daanv98 i not sure if the dos box mapping will override xboxdrv or work with it.
                                            from my understanding of it. ( which is not that much) i think xboxdrv will override everything.

                                            now there might be a way for you to unbind the buttons that are mapped with dosbox, but i cant remember if i got that to work or not.

                                            RPi3B+ / 200GB/ RetroPie v4.5.14, RPi4 Model B 4gb / 256gb / RetroPie 4.8.2
                                            RPi5 4gb / 512gb / RetroPie 4.8.9 -Basic
                                            Maintainer of RetroPie-Extra .

                                            D 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.