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 495.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.
    • J
      javisousa20 @mediamogul
      last edited by

      @mediamogul
      Thanks for de reply. Of course I know the difficulties of creating something like that, and I know that it isn't the best controller, but I want to use it to travel or occasional plays.
      I've tried to follow your last message without success, I used the following code:

      sudo killall xboxdrv
      
      sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
       --evdev /dev/input/event1 \
       --silent \
       --mimic-xpad \
       --evdev-keymap BTN_LEFT=rb,BTN_RIGHT=lb \
       --ui-axismap x1=REL_X,y1=REL_Y \
      

      I tried again more times with different configurations but I can not find the problem so that Retropie recognizes the right and left buttons, the axis of the joystick does not seem to work either.
      I used trigger-as-button iterating configurations and I thought it worked because it showed the name (end of section 3A of the guide), but at the time of mapping, it didn't recognize the same buttons either.
      Although I do not expect to get it, thanks for the help!

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

        @javisousa20

        Try and see if all the buttons and axis are registering in the newly created joystick with jstest. The command would be:

        jstest /dev/input/jsX
        

        Where 'X' is the number of the xboxdrv-created controller.

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

        J 1 Reply Last reply Reply Quote 0
        • J
          javisousa20 @mediamogul
          last edited by

          @mediamogul
          It give me this back

          Joystick (Xbox Gamepad (userspace driver)) has 6 axes (X, Y, Rx, Ry, Hat0X, Hat0Y)
          and 13 buttons (BtnX, BtnY, BtnTL, BtnTR, BtnTR2, BtnSelect, BtnStart, BtnMode, BtnThumbL, BtnThumbR, ?, ?, ?).
          Testing ... (interrupt to exit)
          Axes:  0:     0  1:     0  2:     0  3:     0  4:     0  5:     0 
          Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off 10:off 11:off 12:off
          

          And nothing testing, neither evtest.
          What that it means?

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

            @javisousa20

            So, while the testing interface was up, you didn't get any response from using the touchpad, or from pressing the buttons?

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

            J 1 Reply Last reply Reply Quote 0
            • J
              javisousa20 @mediamogul
              last edited by

              @mediamogul
              Exactly, I don't get any reponse. I have tested with all the controllers that enable xboxdrv without success.

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

                @javisousa20

                I'm afraid that may mean it's not going to work. Usually, if there's an issue, xboxdrv will simply refuse to create the virtual controller and throw an error. The fact that it is created, but has no response likely means there's nothing to troubleshoot and that the two are just not compatible.

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

                J 1 Reply Last reply Reply Quote 0
                • J
                  javisousa20 @mediamogul
                  last edited by

                  @mediamogul
                  Well, thanks for the answer, I'll try to do some tests even though we can not do anything. The best way to test the changes is as follows?

                  sudo killall xboxdrv
                  sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv ((...changes...))
                  reboot
                  

                  Thanks for the help!

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

                    @javisousa20 said in Guide: Advanced Controller Mappings:

                    The best way to test the changes is as follows?

                    On something like this, the best advice I can give is to keep throwing ideas at the problem as you have them. Whenever I find myself in uncharted territory, trial and error is often the mother of resolution.

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

                    J 1 Reply Last reply Reply Quote 0
                    • J
                      javisousa20 @mediamogul
                      last edited by javisousa20

                      @mediamogul
                      Hi, I think the problem is when I reboot to initialize xboxdrv. I have tried to use the following code

                      sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv 
                       --evdev /dev/input/event1 
                       --evdev-debug 
                       --evdev-keymap BTN_LEFT=LB,BTN_RIGHT=RB
                      

                      It give me this back when I press the BTN_LEFT, also with BTN_RIGHT

                      EV_KEY BTN_LEFT 1
                      X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:1 RB:0  LT:  0 RT:  0
                      EV_KEY BTN_LEFT 0
                      X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
                      EV_KEY BTN_LEFT 1
                      X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:1 RB:0  LT:  0 RT:  0
                      

                      It seems that the emulation to the LB button works, but when I restart to initialize xboxdrv, the result is lost:

                      sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv 
                       --evdev /dev/input/event1 
                       --evdev-debug
                      EV_KEY BTN_LEFT 1
                      X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
                      EV_KEY BTN_LEFT 0
                      X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
                      

                      There may be something that I am doing wrong, Do I have to write it in rc.local?

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

                        @javisousa20

                        I believe you're right. xboxdrv is allowing the map to happen without error, but when the virtual controller is produced, those buttons don't seem to be communicating as they should. If I had to guess, it may be because you're mapping a mouse event. I've never done that myself and while it's technically possible and xboxdrv doesn't complain, it's just not communicating for some reason.

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

                        J 1 Reply Last reply Reply Quote 0
                        • J
                          javisousa20 @mediamogul
                          last edited by javisousa20

                          @mediamogul
                          Is there any way to start xboxdrv without rebooting? Or what is the way to start the configuration of xboxdrv at start? Is it to write the code in rc.local? Because I'm having troubles in that case

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

                            @javisousa20

                            You can always kill it at any time with

                            sudo killall xboxdrv
                            

                            When testing, you can just created a script, say in your home folder and launch it to see if it's working. If not, kill it, alter it and launch it again.

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

                            J 1 Reply Last reply Reply Quote 0
                            • J
                              javisousa20 @mediamogul
                              last edited by

                              @mediamogul said in Guide: Advanced Controller Mappings:

                              @javisousa20

                              You can always kill it at any time with

                              sudo killall xboxdrv
                              

                              When testing, you can just created a script, say in your home folder and launch it to see if it's working. If not, kill it, alter it and launch it again.

                              It would not work for what I try to get, xboxdrv does not modify the first virtual event (ex: event2, js0) if I have not used killall before, either through rc.local or a script or directly from the xboxdrv command, but that creates a new event (and new js) that does not appear in /dev /input because it always exceeds the limit of defined controllers for the driver. The problem was that I could not run xboxdrv after I had used the killall command, only if I rebooted... or I don't know how.
                              But I think I've got it, I should try a script like you said, but for now I've managed to make it work by making the following change in rc.local:

                              
                              sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
                               --evdev /dev/input/event1 \
                               --silent \
                               --mimic-xpad \
                               --trigger-as-button \
                               --evdev-keymap BTN_LEFT=LB,BTN_RIGHT=RB,KEY_CONFIG=LT,KEY_SEARCH=RT,KEY_PLAYPAUSE=A,KEY_PREVIOUSSONG=X,KEY_NEXTSONG=B,KEY_VOLUMEUP=Y,KEY_VOLUMEDOWN=back
                              
                              "/opt/retropie/supplementary/xboxdrv/bin/xboxdrv" --daemon --detach --dbus disabled --detach-kernel-driver --id 0 --led 2 --deadzone 4000 --silent --trigger-as-button --next-controller --id 1 --led 3 --deadzone 4000 --silent --trigger-as-button
                              
                              exit 0
                              

                              The first call is my design for xboxdrv and the second one is the default one when enabling the driver from retropie config.
                              The problem with this method now comes from that to include that code in rc.local, when loading backpieces at the beginning, instead of entering emulationstation runs xboxdrv as expected from command line, but remains stopped in its last sentence:

                              Your Xbox/Xbox360 controller should now be available as:
                               /dev/input/js0
                               /dev/input/event2
                              
                              Press Ctrl-C to quit
                              

                              But I can't do nothing to quit, skip or enter in emulationstation directamente. (Or I may not know how)
                              I can only enter emulationstation using SSH. There I can map all the keys and buttons without problems (although I still have to try the touchpad as a joystick).
                              It is an advance, I would like to take advantage of your knowledge in programming that I don't have to finish polishing it, there may be more interested people.

                              J 1 Reply Last reply Reply Quote 0
                              • J
                                javisousa20 @javisousa20
                                last edited by javisousa20

                                @javisousa20 said in Guide: Advanced Controller Mappings:

                                But I can't do nothing to quit, skip or enter in emulationstation directly. (Or I may not know how)

                                Ok sorry, I forgot the &. Now it's working well!
                                When I want to use lxde desktop I can't use the keyboard or mouse, how can I end the xboxdrv process automatically when I want to access the desktop and restart it when I go back to retropie?

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

                                  @javisousa20

                                  So the virtual controller is preventing you from using a mouse and keyboard in lxde?

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

                                  J 1 Reply Last reply Reply Quote 0
                                  • J
                                    javisousa20 @mediamogul
                                    last edited by

                                    @mediamogul
                                    Yes, if I run killall xboxdrv, I can control it normally again

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

                                      @javisousa20

                                      Well, as you know, the guide covers a method for starting and stopping xboxdrv maps using the runcommand-onstart/end scripts, but I don't think they come into play for lxde. I've never enabled lxde on my own setup, but I assume a script is created to launch it, located in the RetroPie menu. Making sure to work from a copy of that, you could try altering it to kill xboxdrv at the beginning of the script and relaunching it at the end.

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

                                      J 1 Reply Last reply Reply Quote 0
                                      • J
                                        javisousa20 @mediamogul
                                        last edited by

                                        @mediamogul
                                        Thanks, I got what I wanted!
                                        This is for runcommand-onstart.sh

                                        #!/bin/sh
                                        
                                        ### Set variables for your joypad and emulator
                                        ### Basic Configuraions - Standard controller mappings
                                        
                                        minikbd="sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
                                        --evdev /dev/input/by-id/usb-6901_2701-if01-event-mouse \
                                        --silent \
                                        --mimic-xpad \
                                        --trigger-as-button \
                                        --evdev-keymap BTN_LEFT=LB,BTN_RIGHT=RB,KEY_CONFIG=LT,KEY_SEARCH=RT,KEY_PLAYPAUSE=A,KEY_PREVIOUSSONG=X,KEY_NEXTSONG=B,KEY_VOLUMEUP=Y,KEY_VOLUMEDOWN=back \"
                                        
                                        ### 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
                                                emulationstation)
                                                        $xboxkill
                                                        joycommand="$minikbd &"
                                                        eval $joycommand
                                                ;;
                                                kodi)
                                                        $xboxkill
                                                ;;
                                        
                                                lxde)
                                                        $xboxkill
                                                ;;
                                        
                                        esac
                                        

                                        And this one for runcommand-onend.sh

                                        #!/bin/sh
                                        sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >/dev/null \
                                        --evdev /dev/input/by-id/usb-6901_2701-if01-event-mouse \
                                        --silent \
                                        --mimic-xpad \
                                        --trigger-as-button \
                                        --evdev-keymap BTN_LEFT=LB,BTN_RIGHT=RB,KEY_CONFIG=LT,KEY_SEARCH=RT,KEY_PLAYPAUSE=A,KEY_PREVIOUSSONG=X,KEY_NEXTSONG=B,KEY_VOLUMEUP=Y,KEY_VOLUMEDOWN=back \
                                        &
                                        

                                        I would like to start from Kodi or Desktop, but if I delete the xboxdrv configuration in rc.local, I can not start xboxdrv when I press exit to enter in emulationstation. It does not work either leaving it in rc.local because it starts desktop/kodi with xboxdrv and does not allow me to use normal controls. Is there any chance of making a change in autostart.sh or in runcommand-onstart.sh to autostart running through runcommand?

                                        On the other hand, I can't emulate the axes of the joystick, the REL_X / Y events go approximately from -60 to 60 depending on the speed with which I move on the touchpad, but I can not get them to work either by calibration, can it be a problem defining them using --ui-axismap?

                                        Thank you very much!

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

                                          @javisousa20 said in Guide: Advanced Controller Mappings:

                                          I can not start xboxdrv when I press exit to enter in emulationstation.

                                          I suppose you could create a script that can be selected from within lxde that would kill the desktop environment and launch xboxdrv, as well as Emulation Station if necessary. The same can actually be done from within Kodi but it's not as straightforward. You'll need to do some research on script addons, or even ways to add scripts as menu items.

                                          On the other hand, I can't emulate the axes of the joystick, the REL_X / Y events go approximately from -60 to 60 depending on the speed with which I move on the touchpad, but I can not get them to work either by calibration, can it be a problem defining them using --ui-axismap?

                                          I believe defining the outer deadzones as defined in the guide should take care of that. Have you given that a go?

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

                                          J 1 Reply Last reply Reply Quote 0
                                          • J
                                            javisousa20 @mediamogul
                                            last edited by

                                            @mediamogul said in Guide: Advanced Controller Mappings:

                                            I believe defining the outer deadzones as defined in the guide should take care of that. Have you given that a go?

                                            Yes, I tried to do it but I do not get anything
                                            This is the code I use

                                            sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
                                            --evdev /dev/input/by-id/usb-6901_2701-if01-event-mouse \
                                            --mimic-xpad \
                                            --dpad-as-button \
                                            --trigger-as-button \
                                            --deadzone 3
                                            --evdev-keymap BTN_LEFT=LB,BTN_RIGHT=RB,KEY_CONFIG=LT,KEY_SEARCH=RT,KEY_PLAYPAUSE=A,KEY_PREVIOUSSONG=dl,KEY_NEXTSONG=dr,KEY_VOLUMEUP=du,KEY_VOLUMEDOWN=dd,KEY_MAIL=back,KEY_HOMEPAGE=start,KEY_MIN_INTERESTING=B,KEY_WWW=guide \
                                            --ui-axismap x2=REL_X,y2=REL_Y \
                                            --calibration x2=-150:0:150,y2=-150:0:150 \
                                            --evdev-debug
                                            

                                            And here part of the test

                                            EV_REL REL_X 10
                                            EV_REL REL_Y -26
                                            X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
                                            EV_REL REL_X 6
                                            EV_REL REL_Y -14
                                            X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
                                            EV_REL REL_X 2
                                            EV_REL REL_Y -6
                                            X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
                                            EV_REL REL_X 4
                                            EV_REL REL_Y -4
                                            X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
                                            EV_REL REL_X 2
                                            EV_REL REL_Y -4
                                            X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
                                            EV_REL REL_X 2
                                            EV_REL REL_Y -2
                                            X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
                                            EV_REL REL_Y -2
                                            X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
                                            EV_REL REL_X -2
                                            X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
                                            EV_REL REL_X -2
                                            EV_REL REL_Y 4
                                            X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
                                            EV_REL REL_X -4
                                            EV_REL REL_Y 4
                                            X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
                                            EV_REL REL_X -4
                                            EV_REL REL_Y 10
                                            X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
                                            EV_REL REL_X -8
                                            EV_REL REL_Y 30
                                            X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
                                            

                                            It can be seen that in this case xboxdrv is not reading the REL axes, but I don't know why

                                            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.