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 480.2k 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.
    • 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
                  • D
                    daanv98 @ExarKunIv
                    last edited by

                    @ExarKunIv I made a mapping file and tried it in dosbox, however it doesn't seem to do anything. Here is my mapping:

                    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[4] \
                    	--silent \
                    	--detach-kernel-driver \
                    	--force-feedback \
                    	--mimic-xpad \
                    	--dpad-as-button \
                    	--deadzone 4000 \
                    	--trigger-as-button \
                    	--evdev-no-grab \
                    	--device-name "Player Red" \
                    	--evdev-absmap ABS_X=x1,ABS_Y=y1 \
                    	--evdev-keymap BTN_TOP=a,BTN_PINKIE=b,BTN_THUMB2=x,BTN_TOP2=y,BTN_TRIGGER=lt,BTN_THUMB=rt,BT_BASE4=start,BTN_BASE3=back \
                    	--ui-axismap x1=REL_X:07,y1=REL_Y:-07 \
                    	--ui-buttonmap rt=BTN_LEFT,lt=BTN_RIGHT,start=KEY_ENTER,back=KEY_ESC,a=KEY_SEMICOLON,b=KEY_APOSTROPHE,x=KEY_LEFTBRACE,y=KEY_RIGHTBRACE \
                    	--ui-buttonmap guide=void \
                    &
                    fi
                    

                    I opened the runcommand.log and there is a weird error:

                    /opt/retropie/configs/all/runcommand-onstart.sh: line 20: syntax error near unexpected token `&'
                    /opt/retropie/configs/all/runcommand-onstart.sh: line 20: `&'
                    Parameters: 
                    Executing: bash "/home/pi/RetroPie/roms/pc/+Start DOSBox.sh"
                    Requested buffer size 32768, fragment size 8192
                    ALSA pcm 'default' set buffer size 32768, period size 8192 bytes
                    TiMidity starting in ALSA server mode
                    Opening sequencer port: 128:0 128:1 128:2 128:3
                    Requested buffer size 32768, fragment size 8192
                    ALSA pcm 'default' set buffer size 32768, period size 8192 bytes
                    

                    Do you see what is wrong?

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

                      @daanv98 nothing is jumping out at me.

                      i need to look back at my old comments and see what you need to paste in the ssh once your game is going, when you do that, it helps find the error.

                      well it did for me

                      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 .

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

                        @daanv98 you should try running it from the command line. just to see if it works,
                        it would be (start the game first )

                        sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv
                        	--evdev /dev/input/event[4] \
                        	--silent \
                        	--detach-kernel-driver \
                        	--force-feedback \
                        	--mimic-xpad \
                        	--dpad-as-button \
                        	--deadzone 4000 \
                        	--trigger-as-button \
                        	--evdev-no-grab \
                        	--device-name "Player Red" \
                        	--evdev-absmap ABS_X=x1,ABS_Y=y1 \
                        	--evdev-keymap BTN_TOP=a,BTN_PINKIE=b,BTN_THUMB2=x,BTN_TOP2=y,BTN_TRIGGER=lt,BTN_THUMB=rt,BT_BASE4=start,BTN_BASE3=back \
                        	--ui-axismap x1=REL_X:07,y1=REL_Y:-07 \
                        	--ui-buttonmap rt=BTN_LEFT,lt=BTN_RIGHT,start=KEY_ENTER,back=KEY_ESC,a=KEY_SEMICOLON,b=KEY_APOSTROPHE,x=KEY_LEFTBRACE,y=KEY_RIGHTBRACE \
                        	--ui-buttonmap guide=void \
                        

                        if everything work it will work. if not then a error will pop up and you can go from there

                        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 Apparently the weird error was because of some empty line I added in the mapping file accidentally. However the controls still don't work. By running

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

                          from the command line (in PuTTY), I get an error which says:
                          No Xbox or Xbox360 controller found

                          Did I forget to set anything up?

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

                            @daanv98 you need to put everything that is in the box i posted

                            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 2 Replies Last reply Reply Quote 0
                            • D
                              daanv98 @ExarKunIv
                              last edited by

                              @ExarKunIv I did, but after the first line it gives the error.

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

                                @ExarKunIv I added \n after the first line and then it works. There was an error which told me that BT_BASE4 doesn't exist. I fixed that to BTN_BASE4. Now its says this: putty1.JPG

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

                                  @daanv98

                                   /dev/input/js2
                                   /dev/input/event5
                                  

                                  means that the mapping it working

                                  your error is something with the game and/or it working with xboxdrv

                                  sadly i dont have any dosgames on my system. i messed it up while messing with compiling other ports. so i cant help much.
                                  and i have gotten away from using that mapping style.

                                  # DOS configuration of Abuse for 8bitDo
                                  # ==================================================
                                  #
                                  # This configuration file is for use with Abuse, a DOS game.
                                  
                                  [xboxdrv]
                                  silent = true
                                  detach-kernel-driver = true
                                  deadzone-trigger = 15%
                                  deadzone = 4000
                                  mimic-xpad = true
                                  dpad-as-button = true
                                  trigger-as-button = true
                                  
                                  [evdev-absmap]
                                  ABS_X=x1
                                  ABS_Y=y1
                                  ABS_Z=x2
                                  ABS_RZ=y2
                                  ABS_HAT0X=dpad_x
                                  ABS_HAT0Y=dpad_y
                                  
                                  [evdev-keymap]
                                  BTN_SOUTH=a
                                  BTN_EAST=b
                                  BTN_NORTH=x
                                  BTN_WEST=y
                                  BTN_TL=lb
                                  BTN_TL2=lt
                                  BTN_TR=rb
                                  BTN_TR2=rt
                                  BTN_SELECT=back
                                  BTN_START=start
                                  BTN_THUMBL=tl
                                  BTN_THUMBR=tr
                                  
                                  [calibration]
                                  x1 = -32767:0:32767
                                  y1 = -32767:0:32767
                                  x2 = -32767:0:32767
                                  y2 = 32767:0:-32767
                                  
                                  [ui-axismap]
                                  x1=KEY_LEFT:KEY_RIGHT
                                  y1=KEY_DOWN:KEY_UP
                                  x2=REL_X:13
                                  y2=REL_Y:13
                                  
                                  [ui-buttonmap]
                                  rt=BTN_LEFT
                                  b=BTN_RIGHT
                                  x=KEY_ENTER
                                  back=KEY_F5
                                  start=KEY_ESC
                                  lt=KEY_LEFTCTRL
                                  
                                  # EC #
                                  

                                  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 .

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

                                    this way just seemed easyer for me and it was easy to get it to launch with the games

                                    #!/bin/bash
                                    
                                    sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >> /dev/shm/runcommand.log 2>&1 --evdev /dev/input/event0 --config /opt/retropie/configs/all//xdrive/abuse.cfg &
                                    
                                    "/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "abuse" ""
                                    
                                    

                                    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 daanv98

                                      @ExarKunIv I finally got it to work!! First i tried this in the command line:

                                      sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \--evdev /dev/input/event4 \--silent \--detach-kernel-driver \--force-feedback \--mimic-xpad \--dpad-as-button \--deadzone 4000 \--trigger-as-button \--evdev-no-grab \--device-name "Player Red" \--evdev-absmap ABS_X=x1,ABS_Y=y1 \--evdev-keymap BTN_TOP=a,BTN_PINKIE=b,BTN_THUMB2=x,BTN_TOP2=y,BTN_TRIGGER=lt,BTN_THUMB=rt,BTN_BASE4=start,BTN_BASE3=back \--ui-axismap x1=REL_X:-3,y1=REL_Y:3 \--ui-buttonmap rt=BTN_LEFT,lt=BTN_RIGHT,start=KEY_ENTER,back=KEY_ESC,a=KEY_SEMICOLON,b=KEY_APOSTROPHE,x=KEY_LEFTBRACE,y=KEY_RIGHTBRACE \--ui-buttonmap guide=void \
                                      
                                      

                                      Notice that there are no spaces between \ and --. This worked right away!

                                      Then I started looking at the runcommand-onstart file. I noticed that the first line referred to 'dosbox'. I changed it to 'pc'. And it works now! My file now looks like this:

                                      if [ "$1" = "pc" ]
                                      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/event4 \
                                        --silent \
                                        --detach-kernel-driver \
                                        --force-feedback \
                                        --mimic-xpad \
                                        --dpad-as-button \
                                        --deadzone 4000 \
                                        --trigger-as-button \
                                        --evdev-no-grab \
                                        --device-name "Player Red" \
                                        --evdev-absmap ABS_X=x1,ABS_Y=y1 \
                                        --evdev-keymap BTN_TOP=a,BTN_PINKIE=b,BTN_THUMB2=x,BTN_TOP2=y,BTN_TRIGGER=lt,BTN_THUMB=rt,BTN_BASE4=start,BTN_BASE3=back \
                                        --ui-axismap x1=REL_X:-07,y1=REL_Y:07 \
                                        --ui-buttonmap rt=BTN_LEFT,lt=BTN_RIGHT,start=KEY_ENTER,back=KEY_ESC,a=KEY_SEMICOLON,b=KEY_APOSTROPHE,x=KEY_LEFTBRACE,y=KEY_RIGHTBRACE \
                                        --ui-buttonmap guide=void \
                                      &
                                      fi
                                      

                                      Huge thanks for your time! I appreciate it.

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

                                        @daanv98 glad you got it working, happy i could help out

                                        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 .

                                        1 Reply Last reply Reply Quote 0
                                        • J
                                          jaamulberry
                                          last edited by

                                          Is there an updated link as the github link ends up at a dead page?

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

                                            @jaamulberry here it was moved to the main Docs page

                                            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 .

                                            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.