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 481.0k 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 @guydot
      last edited by

      @guydot said in Guide: Advanced Controller Mappings:

      Is there any performance impact to using xboxdrv for all games?

      None that I've noticed. I usually launch two instances for player one and two controls and have never had a problem.

      Thoughts?

      No, not really. That's more or less how I use it myself.

      Disclaimer: newbie, limited programming skills, haven't tested it for long enough :-)

      You're doing pretty good. Most people, including myself, struggle with this in the beginning. It really does pay off though. Games like Pac-Man just can't be played well with more than four available directions. Sure, you can boot them up and show them off, but you'll never get very far without the restriction.

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

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

        @mediamogul I was too happy too soon. It is not working consistently. I am almost ready to give up. The driver works well first time I launch a game (creates JS2 and JS3), but in subsequent launches I noticed that the driver creates JS4 and the game does not respond. I wonder if anybody has been successful with Contronlblock + xboxdrv...

        The one thing that I noticed, but I am not sure if it has any significance, is that the Controlblock joystics are not listed in /dev/input/by-id/

        In the xboxdrv command line I used the (controlblock joysticks) event numbers.

        Not sure if it makes sense...

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

          @guydot said in Guide: Advanced Controller Mappings:

          in subsequent launches I noticed that the driver creates JS4 and the game does not respond.

          It could be that the previous instances of xboxdrv are not being killed when the emulator/port exits. Looking back over your previous post, I don't see you mention a command to killall xboxdrv in the runcommand-onend script. If it is in fact there, make sure you're using sudo before the killall command. Otherwise it won't have the proper permissions.

          I am not sure if it has any significance, is that the Controlblock joystics are not listed in /dev/input/by-id/

          You might also try looking at /dev/input/by-path/.

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

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

            @mediamogul Hi. I'm having a few problems with ScummVM and mapping my joystick 1 to operate like a mouse.

            I have a bluetooth keyboard which has a built in touchpad and I can use that to navigate in game perfectly. My joystick 2 is also natively working as a joystick, albeit the axes are mixed up.

            I've followed the guide, but I think I've got myself confused. This is the first time I've tried to mimic a mouse.

            Do I need to start from scratch and determine what event number is the keyboard/touchpad and go from there (using cat /proc/bus/input/devices)?

            So far I have:

            Player1_ScummVM="sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv > /dev/null 2>&1 \
            --silent \
            --detach-kernel-driver \
            --deadzone=4000 \
            --deadzone-trigger 15% \
            --force-feedback \
            --mimic-xpad \
            --trigger-as-button \
            --ui-buttonmap x=void,y=void,lb=void,rb=void,tl=void,tr=void,guide=void,lt=void \
            --evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.3.3:1.0-event-joystick \
            --device-name "Player_1" \
            --evdev-absmap ABS_X=y1,ABS_Y=x1 \
            --evdev-keymap BTN_THUMB2=a,BTN_PINKIE=b,BTN_TRIGGER=x,BTN_THUMB=y,BTN_TOP2=lb,BTN_TOP=rb,BTN_BASE3=back,BTN_BASE6=start,BTN_BASE2=lt,BTN_BASE5=rt \
            --axismap -Y1=Y1,-Y2=Y2 \
            --ui-axismap X1=REL_X:10,Y1=REL_Y:10 \
            --ui-buttonmap a=BTN_LEFT,b=BTN_RIGHT,back=KEY_UNKNOWN,start=KEY_UNKNOWN,rt=KEY_F5,back+rt=KEY_LEFTALT+KEY_X"
            

            And

            
            	scummvm)
            		$xboxkill
            		joycommand="$clear & $Player1_ScummVM & $silence &"
            		eval $joycommand
            	;
            

            This code doesn't work at all at present. Thanks for any help you can provide.

            RetroPie v4.4.1 • RPi3 Model B • 5.1V 2.5A PSU • 32GB SanDisk Extreme microSD • 2TB Toshiba Canvio Basics Portable USB 3.0 hard drive • 4 x DragonRise USB Arcade joysticks • 2 x TurboTwist spinners • 1 x USB trackball • 1 x PS4 wireless • 1 x 8BitDo Zero

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

              @spud11

              Does xboxdrv throw up any errors? At some point I changed the guide to suggest redirecting all errors to the Runcommand log rather than /dev/null. That might be helpful here. Just replace:

              > /dev/null 2>&1
              

              with

              >> /dev/shm/runcommand.log 2>&1
              

              As long as you have an otherwise working xboxdrv command, the following two lines should be all that's required to add full mouse control to whatever the first axis is on the controller you're trying to map, with buttons 'A' and 'B' acting as left/right click..

              --ui-axismap X1=REL_X:10,Y1=REL_Y:10 \
              --ui-buttonmap a=BTN_LEFT,b=BTN_RIGHT
              

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

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

                @mediamogul Thanks. You were 100% right. I found an error - just a missing ; which I've added back in. Thanks again.

                RetroPie v4.4.1 • RPi3 Model B • 5.1V 2.5A PSU • 32GB SanDisk Extreme microSD • 2TB Toshiba Canvio Basics Portable USB 3.0 hard drive • 4 x DragonRise USB Arcade joysticks • 2 x TurboTwist spinners • 1 x USB trackball • 1 x PS4 wireless • 1 x 8BitDo Zero

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

                  @spud11

                  Not a problem.

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

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

                    @mediamogul said in Guide: Advanced Controller Mappings:

                    @guydot said in Guide: Advanced Controller Mappings:
                    I don't see you mention a command to killall xboxdrv in the runcommand-onend script. If it is in fact there, make sure you're using sudo

                    I changed the logic to use xboxdrv for all games in "Arcade" - some with 4-way restriction and some without. It is launched by runcommand-onstart and killed by runcommand-onend. I do use sudo. The issue that I am still having is that (and I am not sure what the sequence is to reproduce,) the order of joysticks changes: first few times, when a game starts I see the yellow text on the bottom of the screen showing the mapped controllers and the Controlblock joystics map to #0 and #1 and xbox to #2 and #3. Then at some point, xboxdrv maps to #0 and #1 and Controlblock to #2 and #3 and the game does not respond (because the arcade folder retroarch.cfg maps 2 and 3 to player 1 and 2 and the Controlblock joystick is not active anymore.)

                    You might also try looking at /dev/input/by-path/.

                    It does not show my Controlblock joysticks, just like /dev/input/by-id/

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

                      @guydot

                      Have you updated RetroArch in a while? This may not be the issue, but recently a fix was implemented to avoid controller ordering based on detection. Before hand this was messing with tools like joystick selection utility. If you haven't already, try updating and see if the behavior continues.

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

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

                        @mediamogul said in Guide: Advanced Controller Mappings:

                        @guydot

                        Have you updated RetroArch in a while?

                        I did a Retroarch update but it did not solve the issue. I am running RPi3 B+/Stretch/RetroPie 4.4, so it is a very recent image.

                        At some point, Retroarch (yellow text on bottom just before the game starts) shows an incorrect port joystick mapping and the game does not work. Killing xboxdrive restores the use of Controlblock to exit the game, but Retroarch would not get the right mapping if I launch a new game unless I reboot. Frustrating.

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

                          @guydot

                          This may be able to be sorted out as-is, but if you're open to an alternative, let me suggest something more reliable. I avoid the uncertainty of these particular situations by having a keyboard map set for players one and two in RetroArch. To correspond with this, I also have my two controllers fully key-mapped with xboxdrv to match. Once everything is launched, it really doesn't matter which controller RetroArch tries to grab hold of, because it'll be acknowledging the keyboard map regardless.

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

                          S G 2 Replies Last reply Reply Quote 0
                          • S
                            spud11 @mediamogul
                            last edited by

                            @mediamogul @guydot I agree 100% with this approach. Mediamogul put me onto this method about 2 years ago and it just works. 99% of cores and emulators have keyboard mapping. I've only struggled with one or two eg reicast; otherwise, all good.

                            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
                            • G
                              guydot @mediamogul
                              last edited by guydot

                              @mediamogul I will give it a shot, as all other methods failed. The closest I got was with Joystick Selection "by name" method: the games work well even when Retroarch shuffled the ports, but Emulationstation crashes when I exit a "port-confused" game.

                              If I understand the method correctly - I will have to change Controlblock to "MAME" mode = keyboard emulation and then run 2 xboxdrv configured to match the keys generated by my controllers. Correct?

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

                                @guydot said in Guide: Advanced Controller Mappings:

                                If I understand the method correctly - I will have to change Controlblock to "MAME" mode = keyboard emulation and then run 2 xboxdrv configured to match the keys generated by my controllers. Correct?

                                Actually, you would just change your xboxdrv maps to be complete key-mappings of the Controlblock. From there, you'd assign those keys to players one and two in RetroArch.

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

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

                                  @mediamogul @spud11 I am missing something here.

                                  Right now:
                                  (1) Controlbox is creating 2 joypads: JS0/JS1 and event 2/3
                                  (2) I use 2 xboxdrv commands, each has --evdev-absmap and --evdev-keymap that correspond to a joypad joystick + buttons
                                  (3) In Retroarch.cfg, I tried to use input_player1_joypad_index = "2" and input_player2_joypad_index = "3" to map

                                  Is proposed method to add --ui-buttonmap to map xboxdrv to keyboard keys? I guess I need more steps... Thanks for all your help!

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

                                    @guydot said in Guide: Advanced Controller Mappings:

                                    Is proposed method to add --ui-buttonmap to map xboxdrv to keyboard keys?

                                    It is, yes. As an example, below is an excerpt from my retroarch.cfg file where I've mapped my desired keyboard inputs for player one. Below that is a 4-way strict xboxdrv map that corresponds to those keys.

                                    retroarch.cfg excerpt:

                                    # Keyboard input, Joypad and Joyaxis will all obey the "nul" bind, which disables the bind completely, 
                                    # rather than relying on a default.
                                    input_player1_a = "a"
                                    input_player1_b = "b"
                                    input_player1_y = "y"
                                    input_player1_x = "x"
                                    input_player1_start = "t"
                                    input_player1_select = "e"
                                    input_player1_l = "l"
                                    input_player1_r = "r"
                                    input_player1_left = "left"
                                    input_player1_right = "right"
                                    input_player1_up = "up"
                                    input_player1_down = "down"
                                    input_player1_l2 = "d"
                                    input_player1_r2 = "f"
                                    input_player1_l3 = "c"
                                    input_player1_r3 = "v"
                                    

                                    4-way strict xboxdrv command:

                                    sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
                                    	--evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.2:1.0-event-joystick \
                                    	--detach-kernel-driver \
                                    	--dpad-as-button \
                                    	--trigger-as-button \
                                    	--deadzone-trigger 15% \
                                    	--deadzone 4000 \
                                    	--device-name "Logitech Rumblepad 2 (xboxdrv)" \
                                    	--silent \
                                    	--four-way-restrictor \
                                    	--axismap -Y1=Y1,-Y2=Y2 \
                                    	--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_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_LEFT:KEY_RIGHT,Y1=KEY_UP:KEY_DOWN,X2=KEY_1:KEY_2,Y2=KEY_3:KEY_4 \
                                    	--ui-buttonmap a=KEY_A,b=KEY_B,x=KEY_X,y=KEY_Y,lb=KEY_L,rb=KEY_R,lt=KEY_D,rt=KEY_F,tl=KEY_C,tr=KEY_V,du=KEY_UP,dd=KEY_DOWN,dl=KEY_LEFT,dr=KEY_RIGHT,start=KEY_T,back=KEY_E \
                                    	--ui-buttonmap guide=void \
                                    	&
                                    

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

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

                                      @mediamogul I think I had my aha! moment :-) I am away but will test in a week or so and report back. Thanks!!!

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

                                        @guydot

                                        Not a problem. Let us know how it works out.

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

                                        1 Reply Last reply Reply Quote 0
                                        • RiverstormR
                                          Riverstorm
                                          last edited by Riverstorm

                                          @mediamogul - Post 534...action...wow long thread! ;) I was wondering if I could get your help with setting up XBOX 360 controllers if possible, please, when/if you have time. I am in no hurry but not quite sure what to do next once I get the controllers setup.

                                          I have four XBOX 360 controllers using a wireless dongle. I use the Arcade folder running mame2003, FBA and Advmame for about 300 games. Basically I just want to break down the games for 4/8-way restriction. Good 4-way games are lost to simple mistakes of not hitting that ladder squarely in Donkey Kong, etc. using controllers.

                                          I am running RP 4.3 on a Pi 3 updated to the latest RetroPie script as of yesterday. My cores are recent from source and Advmame is on 3.8.

                                          I went through the tutorial and here's what I ended up with but I had a few questions. For calibration axis name. Do I use the output from evtest /dev/input/event[event1] and add it 3 times as shown below?

                                          evtest output for 360 controller:

                                          A = BTN_SOUTH = 304
                                          B = BTN_EAST = 305
                                          X = BTN_NORTH = 307
                                          Y = BTN_WEST = 308
                                          LB = BTN_TL = 310
                                          RB = BTN_TR = 311
                                          LT = BTN_TL2 = 312
                                          RT = BTN_TR2 = 313
                                          BACK = BTN_SELECT = 314
                                          START = BTN_START = 315
                                          GUIDE = BTN_MODE = 316
                                          TL = BTN_THUMBL = 317
                                          TR = BTN_THUMBR = 318
                                          X1/Y1 = ABS_X (UP/DOWN) | ABS_Y (LEFT/RIGHT)
                                          X2/Y2 = ABS_RX (UP/DOWN) | ABS_RY (LEFT/RIGHT)
                                          DPAD_Y/DPAD_X = ABS_HAT0Y (UP/DOWN) | ABS_HAT0X (LEFT/RIGHT)
                                          

                                          Also with a 360 controller I didn't get output for rt/lt or at least I assigned them to buttons TL2 & TR2 as they aren't an axis? So I have two fields below still using asterisks.

                                          Lastly should I use the option to make the triggers into buttons on a 360 controller. I added the option below.

                                          Lastly, lastly do I need to use the rename parameter for each controller as I have 4 but they are all the same. Well they are 2 different models among the 4 but they are all detected as the same. Do I need to define 4 controllers in the rc.local file?

                                          If I get this first step implemented correctly is there a guide restricting games to 4/8 way? Disclosure I didn't read all 533 posts so if there's a relevant section I can read through or a link to what steps I should think about next. Thanks Media for all this information, it's pretty incredible stuff. I wish 4/8 restriction was a controller feature as it's kind of relevant-ish to good gaming.

                                          sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
                                          	--evdev /dev/input/by-id/[usb-©Microsoft_Xbox_360_Wireless_Receiver_for_Windows_E0C26450-event-joystick] \
                                          	--silent \
                                          	--detach-kernel-driver \
                                          	--force-feedback \
                                          	--deadzone-trigger 15% \
                                          	--deadzone 4000 \
                                          	--calibration X=-32767:0:32767,Y=-32767:0:32767 \
                                          	--calibration RX=-32767:0:32767,RY=-32767:0:32767 \
                                          	--calibration HAT0Y=-32767:0:32767,HAT0X=-32767:0:32767 \
                                          	--trigger-as-button \
                                          	--mimic-xpad \
                                          	--evdev-absmap ABS_[X]=x1,ABS_[Y]=y1,ABS_[RX]=x2,ABS_[RY]=y2,ABS_[•]=lt,ABS_[•]=rt,ABS_[HAT0Y]=dpad_x,ABS_[HAT0X]=dpad_y \
                                          	--evdev-keymap BTN_[SOUTH]=a,BTN_[EAST]=b,BTN_[NORTH]=x,BTN_[WEST]=y,BTN_[TL]=lb,BTN_[TR]=rb,BTN_[TL2]=tl,BTN_[TR2]=tr,BTN_[MODE]=guide,BTN_[SELECT]=back,BTN_[START]=start \
                                          	&
                                          
                                          mediamogulM 1 Reply Last reply Reply Quote 0
                                          • RiverstormR
                                            Riverstorm
                                            last edited by Riverstorm

                                            Also something odd is it seems the X/Y axis is "inverted" on the d-pad vs. the left/right stick on a 360 controller using evtest /dev/input/event[event1] so in the script above I have HAT0Y as X and HAT0X as Y.

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