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.4k 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.
    • W
      weirdocollector @mediamogul
      last edited by weirdocollector

      @mediamogul

      Hi,

      I've tried the following:

      --ui-buttonmap du=ABS_HAT0X-, dd=ABS_HAT0X+, dl= ABS_HAT0Y-, dr=ABS_HAT0Y+

      preceded by alongside --dpad-as-button, but it still get an error.

      How can I map the hat (seen as an analog input) to the dd, du, dl, dr keys ?

      Thanks for any help.

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

        @Pyjamarama said in Guide: Advanced Controller Mappings:

        The evtest displays lots of entries when a press a button and lots lots lots

        This also happens with one of my controllers. In my case it meant that the axis input was so sensitive that it was being activated whenever any button was pressed. To prevent this from carrying over to the virtual controller, I had to add the --deadzone 4000. However, you'll still need a way to discern the actual button information from all the extra information you're given in evtest. This takes a bit of work, as you'll have to barely tap each button and then scroll up to the very top of the resulting input and see what the first listing was before all the garbage.

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

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

          @weirdocollector said in Guide: Advanced Controller Mappings:

          How can I map the hat

          Mapping the dpad hatswitch from a physical controller to the xboxdrv virtual controller is done as follows:

          --evdev-absmap ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y
          

          From there you would normally map keys to it like any other axis:

          --ui-axismap dpad_x=KEY_LEFT:KEY_RIGHT,dpad_y=KEY_UP:KEY_DOWN
          

          However, if you want to the dpad to be seen as button presses rather than an axis with the new virtual controller, you would add:

          --dpad-as-button
          

          Once this has been added you can now key-map the dpad with --ui-buttonmap such as:

          --ui-buttonmap du=KEY_UP,dd=KEY_DOWN,dl=KEY_LEFT,dr=KEY_RIGHT
          

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

          W 1 Reply Last reply Reply Quote 2
          • W
            weirdocollector @mediamogul
            last edited by weirdocollector

            @mediamogul

            Thanks mediamomogul!

            Now the script works, but I have another problem.

            If I enter the Atari5200 emulator, the controller commands doesn't work, but if I go to my SSH console and I type (in the /opt/retropie/configs/all directory) ./runcommand-onstart.sh atari800 + Return, while the emulator is running, the controller starts working as expected (yay!).

            It seems that the script is finally correct, but it doesn't seem to start when the atari emulator il launched.

            Am I forgetting something ?

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

              @weirdocollector

              I'm afraid I'll have to defer this question to @MadHorse, who has a better understanding of this area. In the mean time, go ahead and post the full contents of your runcommand-onstart.sh file and I'll see if anything jumps out.

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

              W 1 Reply Last reply Reply Quote 0
              • W
                weirdocollector @mediamogul
                last edited by weirdocollector

                @mediamogul

                Thanks !

                Here is my runcommand-onstart.sh script:

                #!/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 Configurations - Standard controller mappings
                XboxOne="/opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
                    --evdev /dev/input/by-id/usb-Microsoft_Controller_7EED8E7D89A9-event-joystick \
                    --silent \
                    --detach-kernel-driver \
                    --force-feedback \
                    --deadzone-trigger 15% \
                    --deadzone 4000 \
                    --mimic-xpad \
                    --trigger-as-button \
                    --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_RX=x2,ABS_RY=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_TR=rb,BTN_TL2=lt,BTN_TR2=rt,BTN_THUMBL=tl,BTN_THUMBR=tr,BTN_MODE=guide,BTN_SELECT=back,BTN_START=start"
                	
                ### Extended Configurations
                ### Specific emulator configuration or any other parameters you will need only for some emulators
                atari800="--axismap -Y1=Y1,-Y2=Y2 \
                	--dpad-as-button \
                	--ui-axismap X1=KEY_KP4:KEY_KP6,Y1=KEY_KP8:KEY_KP5 \
                	--ui-axismap 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_KPASTERISK:KEY_EQUAL \
                	--ui-buttonmap a=KEY_RIGHTCTRL,b=KEY_F2,x=KEY_EQUAL,y=KEY_KPASTERISK,lb=KEY_F9,rb=KEY_F5,du=KEY_KP8,dd=KEY_KP5,dl=KEY_KP4,dr=KEY_KP6,start=KEY_F4,back=KEY_F3,lt=KEY_HOME,rt=KEY_HOME,tl=KEY_HOME,tr=KEY_HOME \
                	--ui-buttonmap lt+a=KEY_ENTER,lt+b=KEY_ESC,lt+du=KEY_UP,lt+dd=KEY_DOWN,lt+dl=KEY_LEFT,lt+dr=KEY_RIGHT,lt+start=KEY_F1 \
                	--ui-axismap lt+X1=KEY_LEFT:KEY_RIGHT,lt+Y1=KEY_UP:KEY_DOWN \
                	--ui-buttonmap guide=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
                
                	atari800)
                        $xboxkill
                        joycommand="$XboxOne $atari800 &"
                        eval $joycommand
                    ;;
                
                esac
                

                Thanks for any help !

                1 Reply Last reply Reply Quote 0
                • W
                  weirdocollector
                  last edited by

                  Ok, I've found the problem...

                  The runcommand-onstart.sh script passes as first parameters ($1) the string atari5200, and not the string atari800, making the case into the script to skip the execution of the driver.

                  In my script I've changed all the occurrances of atari800 into atari5200and it now works !!

                  Thanks to everybody for all the help !

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

                    @weirdocollector

                    Well done sir! Case scripting is an area that I haven't had time to fully explore yet, so these posts are always very informative.

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

                    meleuM 1 Reply Last reply Reply Quote 0
                    • meleuM
                      meleu @mediamogul
                      last edited by meleu

                      @mediamogul sorry for acting like a lazy guy here, but can you share with us a way to set only one button to act like pressing two buttons?

                      The goal is to put a button on a bartop to do "exit emulator" function (usually start+select).

                      Thanks in advance.

                      • Useful topics
                      • joystick-selection tool
                      • rpie-art tool
                      • achievements I made
                      mediamogulM 1 Reply Last reply Reply Quote 1
                      • mediamogulM
                        mediamogul Global Moderator @meleu
                        last edited by mediamogul

                        @meleu

                        Not a problem. Let's say that the keyboard key you're looking to map to 'start+select' is the 'Escape' key. Also, we'll assume that 'Back' is being used as a stand-in for 'Select', due to the lack of a 'Select' button option on the virtual XBox controller. The mapping would read as:

                        --ui-buttonmap back+start=KEY_ESC
                        

                        If you ever run into software that uses a key combination to exit, such as 'ctrl+escape', the alteration is nothing more complicated than:

                        --ui-buttonmap back+start=KEY_LEFTCTRL+KEY_ESC
                        

                        or possibly:

                        --ui-buttonmap back+start=KEY_RIGHTCTRL+KEY_ESC
                        

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

                        1 Reply Last reply Reply Quote 2
                        • P
                          PolluxNL
                          last edited by

                          -Is it possible to use xboxdrv with a PS3 controller?
                          -Should I disable/remove PS3 Bluetooth driver?
                          -Should I try configuring it wireless or connected?

                          And "ls /dev/input/by-id/" doesn't work.

                          Any help is welcome.

                          Thanks in advance!

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

                            @PolluxNL said in Guide: Advanced Controller Mappings:

                            -Is it possible to use xboxdrv with a PS3 controller?

                            It is indeed.

                            -Should I disable/remove PS3 Bluetooth driver?

                            I can't really say, but it's likely that it will conflict otherwise.

                            -Should I try configuring it wireless or connected?

                            I believe problems arise when configured wirelessly, due to the bluetooth connection being dropped when sleeping.

                            And "ls /dev/input/by-id/" doesn't work.

                            you can also use it's joystick event number at /dev/input/jsX, where x is likely to be 0.

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

                            1 Reply Last reply Reply Quote 0
                            • Capt_MorganCreekC
                              Capt_MorganCreek
                              last edited by

                              Hi mediamogul!
                              Your guide is really comprehensive, thank you!

                              I got the basics, but xboxdrv gives me trouble using the calibration parameter.

                              If I don't calibrate my controller the output from the control stick is to low to be useful.

                              If I use --calibration x1=40:128:207,y1=50:128:207 \ (in my case an adapted N64 controller) the stick returns higher values, but it almost behaves like a button jumping between the min and max values (32767/-32767) with nothing inbetween.

                              Is there another way to increase the analog output? Maybe just multipling the original values by a factor of 2 would do the trick but I have no idea how to approach this idea and I can't get my head around the filtering concept.

                              I'm really looking forward to a solution, this is really a showstopper for my usecase.

                              These are my settings:

                              sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv
                              --evdev /dev/input/event2
                              --silent
                              --detach-kernel-driver
                              --force-feedback
                              --deadzone-trigger 15%
                              --deadzone 15%
                              --device-name "N64 Player 1"
                              --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_RZ=x2,ABS_Z=y2,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y
                              --evdev-keymap BTN_THUMB=a,BTN_THUMB2=b,BTN_BASE=lb,BTN_BASE2=rb,BTN_BASE3=tl,BTN_BASE4=start
                              --ui-axismap lt=void,rt=void
                              --ui-buttonmap tr=void,guide=void,back=void,x=void,y=void
                              --calibration x1=40:128:207,y1=50:128:207 \

                              RetroPie64 - My Nintendo 64 conversion: https://retropie.org.uk/forum/post/55927

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

                                @Capt_MorganCreek

                                Unfortunately, this is a situation I've never run into personally. The few controllers that I've had to use this on seemed to come into line immediately. I like your idea about multiplying the values and I'm curious myself to see what effect that would have. Also, it might be worth trying the widest possible range of values as well by adjusting the config to:

                                --calibration x1=-32768:0:32767,y1=-32768:0:32767 \
                                

                                Definitely keep me updated.

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

                                Capt_MorganCreekC 1 Reply Last reply Reply Quote 0
                                • Capt_MorganCreekC
                                  Capt_MorganCreek @mediamogul
                                  last edited by Capt_MorganCreek

                                  @mediamogul

                                  Thanks for pointing me to a solution!

                                  I tried this calibration before, but the values were still too low. The x and y output needs to be in the 30000 range to be correctly registered. With this calibration they were around 18000 which is much better than the former ~200.
                                  Through trial and error I figured out if you use

                                  --calibration x1=-16384:0:16384,y1=-16384:0:16384 \
                                  

                                  you get really usable results in the 32000 range and everything works fine in the emulationstation controller-configuration GUI and retroarch.

                                  So my configuration for a real N64 controller using the HiuJia usb adapter looks like this (the deadzone probably still needs some tweaking) :

                                  sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
                                  	--evdev /dev/input/event2  \
                                  	--silent \
                                  	--detach-kernel-driver \
                                  	--force-feedback \
                                  	--deadzone-trigger 15% \
                                  	--deadzone 15% \
                                  	--device-name "N64 Player 1" \
                                  	--evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_RZ=x2,ABS_Z=y2,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y \
                                  	--evdev-keymap BTN_THUMB=a,BTN_THUMB2=b,BTN_BASE=lb,BTN_BASE2=rb,BTN_BASE3=tl,BTN_BASE4=start \
                                  	--ui-axismap lt=void,rt=void \
                                  	--ui-buttonmap tr=void,guide=void,back=void,x=void,y=void \
                                  	--calibration x1=-16384:0:16384,y1=-16384:0:16384 \
                                  

                                  Thanks again for the awesome controller guide!

                                  RetroPie64 - My Nintendo 64 conversion: https://retropie.org.uk/forum/post/55927

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

                                    @Capt_MorganCreek

                                    Not a problem. Thank you for posting your findings. I'm glad it's working well now.

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

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

                                      I removed all references to altering emulator.cfg files for key-mapping a system/port in favor of an easily sustainable and much simpler approach using a basic if/else statement. Anyone having trouble with this in the past may wish to reexamine the process. @MadHorse's more advanced case statement technique remains the same.

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

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

                                        do you need to have the latest kernel installed.
                                        i have kernel 4.1.21-v7+. per Xbox360 wireless controllers - receiver connectivity issues

                                        im also have a 8bitdo. I know that Rion had problems with getting his to work.

                                        im just starting out some where

                                        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 .

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

                                          @ExarKunIv

                                          I believe that's only necessary when using xboxdrv as a driver for an actual Xbox controller. I've never had to worry about a particular kernel version myself.

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

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

                                            ok cool.

                                            one less thing for me to worry about.
                                            guess it is just in my coding.

                                            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.