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 465.1k 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 @MadHorse
      last edited by

      @MadHorse

      I'm glad it's working. Tell Threepwood he fights like a dairy farmer.

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

      1 Reply Last reply Reply Quote 0
      • M
        MadHorse
        last edited by MadHorse

        How appropriate! I fight like a cow! :D

        Thank you again.

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

          For anyone interested, I posted an example of an Atari800/5200 mapping here.

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

          1 Reply Last reply Reply Quote 1
          • P
            Pyjamarama
            last edited by

            @mediamogul you have been making an epic tutorial here...

            I d love to see a 4way restrictions tutorial for games like PacMan in FBA and ΜΑΜΕ

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

              @Pyjamarama

              I'm glad it's been helpful. Restricting the direction to four ways can be done by just adding the variable line below to any xboxdrv command. I've been meaning to edit the first section to make mention of it, but I'll post it here also.

              --four-way-restrictor
              

              If you're formatting the command the way I've been illustrating so far, you'd of course add a space and backslash afterward to allow a carriage return to the next line:

              --four-way-restrictor \
              

              The difference this makes when playing something like 'Pac-Man' or 'Burger Time' is huge and allows for a much tighter and more authentic control scheme.

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

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

                @mediamogul Sorry for the possible silly post that follows :)

                So...lets say my rom is called pacman.zip

                If I create a pacman.zip.cfg file that contains only

                --four-way-restrictor

                and put it where my roms are, will be enough?

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

                  @Pyjamarama

                  I'm afraid not. It can be added to any xboxdrv command, but it's exclusive to xboxdrv. I was a bit unclear in my wording above. I'll change for posterity.

                  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
                    Pyjamarama @mediamogul
                    last edited by

                    @mediamogul I think that I am on xboxdrv. How can I check that it is working? (except from playing experience)

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

                      @Pyjamarama

                      You can check to see if you've installed it previously by going into RetroPie-Setup > Manage Packages > Manage Driver Packages. It will read "installed" next to the xboxdrv entry.

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

                      1 Reply Last reply Reply Quote 1
                      • M
                        MadHorse
                        last edited by

                        Hello again mediamogul,

                        i'm here again begging for your help.
                        I'm trying to switch the mouse control from the left stick to the right stick, so i change the configuracion from --ui-axismap x1=REL_X:10,y1=REL_Y:-10 to --ui-axismap x2=REL_X:10,y2=REL_Y:-10 but it doesen't seems to work correctly, i can use the right stick just to move left and right but not up and down, and the left stick is still active but doesen't move the pointer, just make it disappear like if it is going out of the screen.
                        My full configuration is the following

                        sudo killall >/dev/null xboxdrv
                        /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
                                >/dev/null \
                                --evdev /dev/input/event2 \
                                --silent \
                                --detach-kernel-driver \
                                --force-feedback \
                                --deadzone-trigger 15% \
                                --deadzone 1000 \
                                --mimic-xpad \
                                --dpad-as-button \
                                --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RZ=y2,ABS_#48=lt,ABS_#49=rt \
                                --evdev-keymap KEY_#302=a,KEY_#301=b,BTN_DEAD=x,KEY_#300=y,BTN_THUMB=tl,BTN_THUMB2=tr,BTN_BASE5=lb,BTN_BASE6=rb,BTN_TRIGGER=back,KEY_#720=guide,BTN_TOP=start,BTN_TOP2=du,BTN_PINKIE=dr,BTN_BASE=dd,BTN_BASE2=dl \
                                --calibration x1=-32767:0:32767,y1=-32767:0:32767,x2=-32767:0:32767,y2=-32767:0:32767 \
                                --ui-axismap x2=REL_X:10,y2=REL_Y:-10 \
                                --ui-buttonmap b=BTN_LEFT,a=BTN_RIGHT,start=KEY_F5,back=KEY_ESC,y=KEY_SPACE \
                                --ui-buttonmap guide=void,x=void,lb=void,rb=void,tl=void,tr=void,lt=void,rt=void,back=void \
                                -- \
                        

                        Do you think you can help me?
                        Please :)

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

                          @MadHorse

                          Everything looks to be correct at face value. I just tried switching one of my own mouse maps over to the right thumbstick and it worked. It could be that ABS_RZ=y2is incorrectly mapped on the--evdev-absmap line. Perhaps the Y2 axis has a different ABS name other than RZ. You might try retracing your steps there.

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

                          1 Reply Last reply Reply Quote 0
                          • M
                            MadHorse
                            last edited by

                            Doh!, me dumb, you are absolutely right, ABS_RZis wrong, the correct one is ABS_RX. Now the right stick is working correctly, the strange thing is that the left stick still acting strange making the pointer disappear. Adding --ui-axismap x1=void,y1=void at the bottom of my configuration doesen't change anything.
                            Any other advise ?

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

                              @MadHorse

                              That is strange. So, the left stick makes the cursor disappear when nudged? Does it disappear for good? Since, you've already tried voiding it, you could try mapping it to an unused key to see how it behaves. Something like --ui-axismap x1=KEY_HOME:KEY_HOME,y1=KEY_HOME would be worth trying. Also, not mapping the left stick at all under --evdev-absmap might give you the desired effect as well.

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

                              1 Reply Last reply Reply Quote 0
                              • M
                                MadHorse
                                last edited by

                                @mediamogul
                                Thank you for your fast reply, it seems to disappear when i move the left stick and reappear always at the top left when i move back to center.
                                Yes you are right, if i map the left stick to --ui-axismap x1=KEY_LEFT:KEY_RIGHT,y1=KEY_DOWN:KEY_UP stop acting strange and work like the arrow keys.
                                You are also right, if i don't map the left stick under --evdev-absmap it disable the left stick.
                                I will use one of the solution as a workaround but i will try to investigate futher on why is acting like this.
                                Thank you very much

                                1 Reply Last reply Reply Quote 0
                                • M
                                  MadHorse
                                  last edited by

                                  Hello again,
                                  i have another questions about joypad configuration for individual emulators.
                                  For emulators that start using a shell script like scummVM and amiga it's easy, but for others emulators like for example jzintv what should i do?
                                  The emulators.cfg is

                                  jzintv="/opt/retropie/emulators/jzintv/bin/jzintv -p /home/pi/RetroPie/BIOS -q %ROM%"
                                  default="jzintv"
                                  

                                  I should create a shell script like scummVM and change emulators.cfg to point the the script or there is an easy way ?
                                  Thank you for any help.

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

                                    @MadHorse

                                    There's really no one right answer to that. Sometimes you can just add the xboxdrv command to the emulators.cfg and others by pointing to a shell script.

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

                                    1 Reply Last reply Reply Quote 0
                                    • M
                                      MadHorse
                                      last edited by

                                      Hi all,

                                      i'm just making some test but it's seems to work well.
                                      Create a runcommand-onstart.sh

                                      nano /opt/retropie/configs/all/runcommand-onstart.sh
                                      

                                      the script will contain a casestatement where it will execute the xboxdrv configuration according to the emulator launched.
                                      The following is just an example, everyone should change the configuration based on their own controller

                                      #!/bin/sh
                                      case $1 in
                                              fba)
                                                      ;;
                                              daphne)
                                                      ;;
                                              scummvm)
                                                      sudo killall >/dev/null xboxdrv
                                                      /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
                                                              >/dev/null \
                                                              --evdev /dev/input/event2 \
                                                              --silent \
                                                              --detach-kernel-driver \
                                                              --force-feedback \
                                                              --mimic-xpad \
                                                              --dpad-as-button \
                                                              --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RX=y2 \
                                                              --evdev-keymap KEY_#302=a,KEY_#301=b,BTN_DEAD=x,KEY_#300=y,BTN_THUMB=tl,BTN_THUMB2=tr,BTN_BASE5=lb,BTN_BASE6=rb,BTN_TRIGGER=back,KEY_#720=guide,BTN_TOP=start,BTN_TOP2=du,BTN_PINKIE=dr,BTN_BASE=dd,BTN_BASE2=dl,BTN_BASE3=lt,BTN_BASE4=rt \
                                                              --calibration x1=-32767:0:32767,y1=-32767:0:32767,x2=-32767:0:32767,y2=-32767:0:32767 \
                                                              --axismap -Y1=Y1,-Y2=Y2 \
                                                              --ui-axismap x1=REL_X:10,y1=REL_Y:10 \
                                                              --ui-buttonmap b=BTN_LEFT,a=BTN_RIGHT,start=KEY_F5 \
                                                              --ui-buttonmap guide=void,x=void,y=void,lb=void,rb=void,tl=void,tr=void,lt=void,rt=void,back=void \
                                                              --ui-axismap x2=void \
                                                              &
                                                      ;;
                                              intellivision)
                                                      sudo killall >/dev/null xboxdrv
                                                      /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
                                                              >/dev/null \
                                                              --evdev /dev/input/event2 \
                                                              --detach-kernel-driver \
                                                              --force-feedback \
                                                              --dpad-as-button \
                                                              --trigger-as-button \
                                                              --deadzone-trigger 15% \
                                                              --deadzone 4000 \
                                                              --silent \
                                                              --axismap -Y1=Y1,-Y2=Y2 \
                                                              --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RX=y2,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y \
                                                              --evdev-keymap BTN_THUMB2=a,BTN_THUMB=b,BTN_TOP=x,BTN_TRIGGER=y,BTN_BASE3=back,BTN_BASE4=start,BTN_TOP2=lb,BTN_PINKIE=rb,BTN_BASE5=tl,BTN_BASE6=tr,BTN_BASE=lt,BTN_BASE2=rt \
                                                              --ui-axismap X1=KEY_S:KEY_D,Y1=KEY_E:KEY_X,X2=KEY_1:KEY_2,Y2=KEY_3:KEY_4,lt+X2=KEY_5:KEY_6,lt+Y2=KEY_7:KEY_8,rt+X2=KEY_9:KEY_0,rt+Y2=KEY_MINUS:KEY_EQUAL \
                                                              --ui-buttonmap a=KEY_LEFTSHIFT,b=KEY_HOME,x=KEY_LEFTCTRL,y=KEY_LEFTALT,lb=KEY_F1,rb=KEY_F12,lt=KEY_HOME,rt=KEY_HOME,tl=KEY_HOME,tr=KEY_HOME,du=KEY_E,dd=KEY_X,dl=KEY_S,dr=KEY_D,start=KEY_PAUSE \
                                                              --ui-buttonmap back=cycle-key:KEY_F6:KEY_F5 \
                                                              --ui-buttonmap guide=void \
                                                              &
                                                      ;;
                                      esac
                                      

                                      Make the script exacutable

                                      sudo chmod +x /opt/retropie/configs/all/runcommand-onstart.sh
                                      

                                      Now we need to create the onend script to kill the xboxdrv, otherwise when we exit the emulator the driver remain active

                                      nano /opt/retropie/configs/all/runcommand-onend.sh
                                      
                                      #!/bin/sh
                                      sudo killall >/dev/null xboxdrv
                                      
                                      sudo chmod +x /opt/retropie/configs/all/runcommand-onend.sh
                                      

                                      I have to do some more test, and maybe create a more complex script with a base configuration for all the emulators and the just the different configuration specific for every emulators.
                                      Also i think it will be possible to create a specific configuration not only for the emulator used but also for the games.
                                      Will share any new info, maybe next week.
                                      Now i need to rest, it was a very long day.

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

                                        @MadHorse

                                        What a great idea! It's a mark improvement over editing each run command. I look forward to trying this out later.

                                        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
                                          Pyjamarama
                                          last edited by

                                          You guys are making wonders here. You take ES to next level of functionality

                                          1 Reply Last reply Reply Quote 1
                                          • M
                                            MadHorse
                                            last edited by MadHorse

                                            Hello everybody,

                                            i made some more test and it seems to work very well.
                                            All the xboxdrv parameters are assigned to variables, this way the case statement is more readable.
                                            Create the runcommand-onstart.sh

                                            nano /opt/retropie/configs/all/runcommand-onstart.sh
                                            

                                            This is my configuration used for test

                                            #!/bin/sh
                                            ## Uncomment one or all of the following if you need to find some information about the emulator or roms
                                            ## Name of the emulator
                                            #echo $1 >> /dev/shm/runcommand.log
                                            
                                            ## Name of the software used for running the emulation
                                            #echo $2 >> /dev/shm/runcommand.log
                                            
                                            ## Name of the rom
                                            #echo $3 >> /dev/shm/runcommand.log
                                            
                                            ##Executed command line
                                            #echo $4 >> /dev/shm/runcommand.log
                                            
                                            
                                            ### The FUN begins
                                            #Get ROM name striping full path
                                            rom="${3##*/}"
                                            
                                            ### Set variables for your joypad and emulator
                                            ### Basic Configuraions - Standard controller mappings 
                                            basicPS3="/opt/retropie/supplementary/xboxdrv/bin/xboxdrv >/dev/null \
                                            	--evdev /dev/input/event2 \
                                            	--silent \
                                            	--detach-kernel-driver \
                                            	--force-feedback \
                                            	--mimic-xpad \
                                            	--dpad-as-button \
                                            	--trigger-as-button \
                                            	--evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RX=y2 \
                                            	--evdev-keymap KEY_#302=a,KEY_#301=b,BTN_DEAD=x,KEY_#300=y,BTN_THUMB=tl,BTN_THUMB2=tr,BTN_BASE5=lb,BTN_BASE6=rb,BTN_BASE3=lt,BTN_BASE4=rt,BTN_TRIGGER=back,BTN_TOP=start,BTN_SOUTH=guide,BTN_TOP2=du,BTN_PINKIE=dr,BTN_BASE=dd,BTN_BASE2=dl
                                            	--calibration x1=-32767:0:32767,y1=-32767:0:32767,x2=-32767:0:32767,y2=-32767:0:32767"
                                            
                                            
                                            ### Extended Configurations
                                            ### Specific emulator configuration or any other parameters you will need only for some emulators
                                            scummVM="--axismap -Y1=Y1,-Y2=Y2 \
                                            	--ui-axismap x1=REL_X:10,y1=REL_Y:10 \
                                            	--ui-buttonmap a=BTN_LEFT,b=BTN_RIGHT,start=KEY_F5,back=KEY_ESC \
                                            	--ui-buttonmap guide=void,x=void,y=void,lb=void,rb=void,tl=void,tr=void,lt=void,rt=void,back=void \
                                            	--ui-axismap x2=void"
                                            
                                            amiga="--axismap -Y1=Y1,-Y2=Y2 \
                                            	--ui-axismap x2=REL_X:1,y2=REL_Y:1 \
                                            	--ui-axismap x1=KEY_LEFT:KEY_RIGHT,y1=KEY_DOWN:KEY_UP \
                                            	--ui-buttonmap du=KEY_UP,dd=KEY_DOWN,dl=KEY_LEFT,dr=KEY_RIGHT \
                                            	--ui-buttonmap lt=BTN_LEFT,rt=BTN_RIGHT,start=KEY_ESC,back=KEY_LEFTCTRL,y=KEY_SPACE,a=KEY_LEFTCTRL,b=KEY_LEFTALT,x=KEY_LEFTSHIFT \
                                            	--ui-buttonmap guide=void,tl=void,lt=void,rt=void,back=void \
                                            	--ui-axismap x2=void"
                                            
                                            fourway="--four-way-restrictor"
                                            
                                            invert="--ui-buttonmap du=KEY_DOWN,dd=KEY_UP"
                                            
                                            ### Kill Command
                                            xboxkill="sudo killall >/dev/null xboxdrv"
                                            
                                            ### Execute the driver with the configuration you need
                                            # $1 is the name of the emulation, not the name of the software used
                                            # it is intellivision not jzintv
                                            case $1 in
                                            
                                            	mame-libretro)
                                            	;;
                                            
                                            	fba)
                                            		case $rom in
                                            			"amidar.zip"|"atetris.zip"|"puckman.zip") # Configuration used only for these ROMs
                                            				$xboxkill
                                            				joycommand="$basicPS3 $fourway &"
                                            				eval $joycommand
                                            			;;
                                            			*) # Configuration for every other ROMs on this emulator
                                            				$xboxkill
                                            				joycommand="$basicPS3 &"
                                            				eval $joycommand
                                            			;;
                                            		esac
                                            	;;
                                            
                                            	daphne)
                                            	;;
                                            
                                            	scummvm)
                                            		$xboxkill
                                            		joycommand="$basicPS3 $scummVM &"
                                            		eval $joycommand
                                            	;;
                                            
                                            	amiga)
                                            		$xboxkill
                                            		joycommand="$basicPS3 $amiga &"
                                            		eval $joycommand
                                            	;;
                                            
                                            	intellivision)
                                            	;;
                                            esac
                                            

                                            We assign to the joycommand variable, the list of variables that contains the parameters we need for example joycommand="BasicVAR var1 var2 var3 $". The Basic variables must be the first, and & must be the last.
                                            Make the script executable

                                            sudo chmod +x /opt/retropie/configs/all/runcommand-onstart.sh
                                            

                                            For some emulators we could face some problem, i have a PS3 controller recognized as input device event2, when i execute xboxdrv the controller is recognized as input device event3. The system now see 2 controller device, the PS3 as controller with id 0 and an Xbox360 controller with id 1, for the emulator you are now using the controller for player2 and this will cause some problem, for example you can only start a 2 players game, you can't quit the emulation pushing select+start. To solve the problem we have to specify on retroarch.cfg the id of the controller used by player1 and player2.
                                            This is the configuration for Final Burn Alpha, we have to add input_playerx_joypad_index = "x" for every controller between input_remapping_directory = "/opt/retropie/configs/fba/" and #include "/opt/retropie/configs/all/retroarch.cfg" where the first X is the player number, and the secon X is the controller ID

                                            
                                            # Settings made here will only override settings in the global retroarch.cfg if placed above the #include line
                                            
                                            input_remapping_directory = "/opt/retropie/configs/fba/"
                                            
                                            input_player1_joypad_index = "1"
                                            input_player2_joypad_index = "0"
                                            input_player2_analog_dpad_mode = 1
                                            
                                            #include "/opt/retropie/configs/all/retroarch.cfg"
                                            

                                            If you want this configuration for every retroarch emulators, you have to edit nano /opt/retropie/configs/all/retroarch.cfg

                                            Now we need to kill xboxdrv when we exit from the emulator, we do this with the onend script

                                            nano /opt/retropie/configs/all/runcommand-onend.sh
                                            
                                            #!/bin/sh
                                            sudo killall >/dev/null xboxdrv
                                            

                                            and make it executable

                                            sudo chmod +x /opt/retropie/configs/all/runcommand-onend.sh
                                            

                                            Sorry for my english, let me know if something is unclear, i will try to explain better, and if you are trying it, please let me know if it's working.
                                            Hope you find it usefull.

                                            @mediamogul
                                            If you think it could be of help, maybe you could add it to the first post.

                                            mediamogulM meleuM J 4 Replies Last reply Reply Quote 3
                                            • 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.