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.7k 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.
    • P
      PMac10000 @PMac10000
      last edited by

      Another thing... with the Xboxdrv controller active, I seem to have lost the ability to exit games with Select + Start, even after remapping the buttons in Mame. (Man, that's a feature I've really come to rely on :-) Also, I've lost the ability to get into the RA menu via Select +X... any ideas are welcome.

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

        @PMac10000 I'm just wondering whether you've set up the keys in Retroarch. I have a bluetooth mini keyboard that I use to test all the keys, including the start and exit keys to make sure they work. Once I've tested these, then I make sure that MAME uses the same keys for Player 1 that I've set in Retroarch and the same keys for Player 2 that I've set in Retroarch, and then I set up xboxdrv to correspond to those keys.

        As @mediamogul mentioned previously, it might be worthwhile using @meleu's joystick selection tool so that you can set up the correct Dragonrise joystick for Player 1 and the correct one for Player 2. If you use it, you can set which joystick is Player 1 and which is Player 2 etc. In the /opt/retropie/configs/all folder, I have a joystick-selection.cfg with the following content:

        # This file was created by the joystick-selection tool.
        # It's recommended to NOT edit it manually.
        # The format is pretty simmilar to a retroarch.cfg file, but it contains only
        # input_player[1-4]_joypad_index, and accepts "strings" as a value.
        # Example:
        # input_playerN_joypad_index = "joystick name"
        # If "joystick name" is an integer, then the real joystick index is used.
        joystick_selection_by_name = "false"
        input_player1_joypad_index = "DragonRise Inc.   Generic   USB  Joystick   #3"
        input_player2_joypad_index = "DragonRise Inc.   Generic   USB  Joystick   #1"
        input_player3_joypad_index = "DragonRise Inc.   Generic   USB  Joystick   #2"
        input_player4_joypad_index = "DragonRise Inc.   Generic   USB  Joystick   #4"
        

        Effectively, my third Dragonrise joystick is Player 1 and my first joystick is Player 2. I'm very careful never to remove the joysticks from the USB hub I have in case the indexes change if I did that. (The order in which the joysticks are attached and the USB ports to which they are connected can make a difference.)

        Here is an extract of my retroarch.cfg which appears in the /opt/retropie/configs/all/ folder:

        ....
        input_player1_a = "x"
        input_player1_b = "z"
        input_player1_y = "a"
        input_player1_x = "s"
        input_player1_start = "enter"
        input_player1_select = "rshift"
        input_player1_l = "q"
        input_player1_r = "w"
        input_player1_left = "left"
        input_player1_right = "right"
        input_player1_up = "up"
        input_player1_down = "down"
        input_exit_emulator = "escape"
        ....
        input_menu_toggle = "f1"
        ....
        input_enable_hotkey = "space"
        ....
        input_player2_b = "alt"
        input_player2_b_btn = "5"
        input_player2_b_axis = "nul"
        input_player2_y = "shift"
        input_player2_y_btn = "0"
        input_player2_y_axis = "nul"
        input_player2_select = "p"
        input_player2_select_btn = "nul"
        input_player2_select_axis = "nul"
        input_player2_start = "i"
        input_player2_start_btn = "nul"
        input_player2_start_axis = "nul"
        input_player2_up = "r"
        input_player2_up_btn = "nul"
        input_player2_up_axis = "+0"
        input_player2_down = "f"
        input_player2_down_btn = "nul"
        input_player2_down_axis = "-0"
        input_player2_left = "d"
        input_player2_left_btn = "nul"
        input_player2_left_axis = "-1"
        input_player2_right = "g"
        input_player2_right_btn = "nul"
        input_player2_right_axis = "+1"
        input_player2_a = "ctrl"
        input_player2_a_btn = "1"
        input_player2_a_axis = "nul"
        input_player2_x = "l"
        input_player2_x_btn = "3"
        input_player2_x_axis = "nul"
        input_player2_l = "n"
        input_player2_l_btn = "2"
        input_player2_l_axis = "nul"
        input_player2_r = "m"
        input_player2_r_btn = "4"
        input_player2_r_axis = "nul"
        input_player2_l2 = "j"
        ....
        

        A few things to bear in mind.

        You'll see that I've set up the hotkey and the exit key. My "space" key is the hotkey. My "escape" key is the exit key.

        Although I have actually set up my 2 controllers via the Emulationstation configuration menu (and you'll see that because my player 2 buttons ("btn") are defined above), I don't even bother with these any longer "in game". I'm only interested in the keys as MAME (input/general) and xboxdrv all correspond to these Retroarch keys as well.

        Below is an extract of my runcommand-onstart.sh for my 4 way and 8 way games for lr-mame2003:

        #!/bin/sh
        
        ### Code begins
        ### Game/ROM full path
        rom="${3##*/}"
        
        
        ### ARCADE - LR-MAME2003 and LR-MAME2010 and LR-MAME2003PLUS - THIS CORE HAS ITS OWN KEYS SET UP VIA THE TAB MENU - The mappings below enable the joysticks to operate in 4-Way or 8-Way mode depending on the game.  This is a libretro core.
        ### First: Using the TAB menu in lr-mame2003, either make note of the default keyboard controls and map the code below accordingly or in TAB map Player 1's and Player 2's controls to the keyboard controls you want and then map the code below.
        ### Player1_4Way_Mame2003 and Player2_4Way_Mame2003 map Joysticks 1 and 2 with four way restriction for use with lr-mame2003.
        ### Start + Select (Back) is assigned to saving the saved game (F2); Select + Start is assigned to loading the saved game (F4)
        
        Player1_4Way_Mame2003="sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >> /dev/shm/runcommand.log 2>&1 \
        --silent \
        --detach-kernel-driver \
        --deadzone=4000 \
        --deadzone-trigger 15% \
        --force-feedback \
        --mimic-xpad \
        --trigger-as-button \
        --ui-buttonmap tl=void,tr=void,guide=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 \
        --four-way-restrictor \
        --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 \
        --ui-axismap X1=KEY_LEFT:KEY_RIGHT,Y1=KEY_UP:KEY_DOWN \
        --ui-buttonmap start+back=KEY_F2,back+start=KEY_F4 \
        --ui-buttonmap a=KEY_LEFTCTRL,b=KEY_LEFTALT,x=KEY_SPACE,y=KEY_LEFTSHIFT,lb=KEY_UNKNOWN,rb=KEY_UNKNOWN,back=KEY_UNKNOWN,start=KEY_UNKNOWN,back+rt=KEY_SPACE+KEY_ESC,lt=KEY_5+KEY_1,rt=KEY_6+KEY_2 \
        --ui-buttonmap lt+rt=exec:/opt/retropie/configs/all/SoundToggle.sh"
        
        Player2_4Way_Mame2003="sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >> /dev/shm/runcommand.log 2>&1 \
        --silent \
        --detach-kernel-driver \
        --deadzone=4000 \
        --deadzone-trigger 15% \
        --force-feedback \
        --mimic-xpad \
        --trigger-as-button \
        --ui-buttonmap lb=void,rb=void,tl=void,tr=void,guide=void,lt=void,rt=void \
        --evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.3.1:1.0-event-joystick \
        --device-name "Player_2" \
        --evdev-absmap ABS_X=y1,ABS_Y=x1 \
        --four-way-restrictor \
        --evdev-keymap BTN_THUMB=a,BTN_TOP=b,BTN_PINKIE=x,BTN_TRIGGER=y,BTN_THUMB2=back,BTN_TOP2=start \
        --ui-axismap X1=KEY_D:KEY_G,Y1=KEY_R:KEY_F \
        --ui-buttonmap a=KEY_A,b=KEY_S,x=KEY_Q,y=KEY_W,back=KEY_6+KEY_2,start=KEY_UNKNOWN,back+start=KEY_SPACE+KEY_ESC"
        
        ### Player1_8Way_Mame2003 and Player2_8Way_Mame2003 map Joysticks 1 and 2 with no restriction for use with lr-mame2003
        Player1_8Way_Mame2003="sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >> /dev/shm/runcommand.log 2>&1 \
        --silent \
        --detach-kernel-driver \
        --deadzone=4000 \
        --deadzone-trigger 15% \
        --force-feedback \
        --mimic-xpad \
        --trigger-as-button \
        --ui-buttonmap tl=void,tr=void,guide=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 \
        --ui-axismap X1=KEY_LEFT:KEY_RIGHT,Y1=KEY_UP:KEY_DOWN \
        --ui-buttonmap start+back=KEY_F2,back+start=KEY_F4 \
        --ui-buttonmap a=KEY_LEFTCTRL,b=KEY_LEFTALT,x=KEY_SPACE,y=KEY_LEFTSHIFT,lb=KEY_UNKNOWN,rb=KEY_UNKNOWN,back=KEY_UNKNOWN,start=KEY_UNKNOWN,back+rt=KEY_SPACE+KEY_ESC,lt=KEY_5+KEY_1,rt=KEY_6+KEY_2 \
        --ui-buttonmap lt+rt=exec:/opt/retropie/configs/all/SoundToggle.sh"
        
        Player2_8Way_Mame2003="sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >> /dev/shm/runcommand.log 2>&1 \
        --silent \
        --detach-kernel-driver \
        --deadzone=4000 \
        --deadzone-trigger 15% \
        --force-feedback \
        --mimic-xpad \
        --trigger-as-button \
        --ui-buttonmap lb=void,rb=void,tl=void,tr=void,guide=void,lt=void,rt=void \
        --evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.3.1:1.0-event-joystick \
        --device-name "Player_2" \
        --evdev-absmap ABS_X=y1,ABS_Y=x1 \
        --evdev-keymap BTN_THUMB=a,BTN_TOP=b,BTN_PINKIE=x,BTN_TRIGGER=y,BTN_THUMB2=back,BTN_TOP2=start \
        --ui-axismap X1=KEY_D:KEY_G,Y1=KEY_R:KEY_F \
        --ui-buttonmap a=KEY_A,b=KEY_S,x=KEY_Q,y=KEY_W,back=KEY_6+KEY_2,start=KEY_UNKNOWN,back+start=KEY_SPACE+KEY_ESC"
        
        case $2 in
        
        ### Arcade
        
        	lr-mame2003)
        	case $rom in
        			"alibaba.zip"|"amidar.zip"|"armwrest.zip"|"astinvad.zip"|"atetris.zip"|"anteater.zip"|"armorcar.zip"|"astrob.zip"|"astrof.zip"|"bagman.zip"|"ballbomb.zip"|"barrier.zip"|"blkhole.zip"|"blasto.zip"|"blockade.zip"|"btime.zip"|"carjmbre.zip"|"carnival.zip"|"cavelon.zip"|"chameleo.zip"|"checkman.zip"|"chinhero.zip"|"circusc.zip"|"ckong.zip"|"commando.zip"|"congo.zip"|"dazzler.zip"|"devilfsh.zip"|"digdug.zip"|"digdug2.zip"|"digger.zip"|"disco.zip"|"dkong.zip"|"dkong3.zip"|"dkongjr.zip"|"docastle.zip"|"dommy.zip"|"dorodon.zip"|"frogger.zip"|"galaga.zip"|"galaxian.zip"|"galxwars.zip"|"guzzler.zip"|"invrvnge.zip"|"invinco.zip"|"jjack.zip"|"joust2.zip"|"jrpacman.zip"|"jumpcoas.zip"|"jungler.zip"|"kchamp.zip"|"kicker.zip"|"kingball.zip"|"ladybug.zip"|"lasso.zip"|"levers.zip"|"lnc.zip"|"locomotn.zip"|"logger.zip"|"lrescue.zip"|"lupin3.zip"|"mappy.zip"|"marvins.zip"|"mikie.zip"|"mmonkey.zip"|"monsterb.zip"|"moonal2.zip"|"moonqsr.zip"|"mrdo.zip"|"mrflea.zip"|"mrjong.zip"|"mrtnt.zip"|"mspacman.zip"|"mystston.zip"|"naughtyb.zip"|"netwars.zip"|"olibochu.zip"|"ozmawars.zip"|"pacnpal.zip"|"pacplus.zip"|"pengo.zip"|"perestro.zip"|"pickin.zip"|"pignewt.zip"|"pisces.zip"|"pleiads.zip"|"pooyan.zip"|"popflame.zip"|"puckman.zip"|"pacman.zip"|"pulsar.zip"|"qbert.zip"|"qbertqub.zip"|"qix.zip"|"radarscp.zip"|"retofinv.zip"|"rocnrope.zip"|"route16.zip"|"samurai.zip"|"tsamurai.zip"|"scregg.zip"|"sindbadm.zip"|"solarfox.zip"|"sonofphx.zip"|"invadpt2.zip"|"panic.zip"|"shollow.zip"|"spclaser.zip"|"sqbert.zip"|"streakng.zip"|"sbagman.zip"|"superpac.zip"|"superqix.zip"|"ssi.zip"|"swat.zip"|"tactcian.zip"|"tankbatt.zip"|"taxidrvr.zip"|"elecyoyo.zip"|"theend.zip"|"timelimt.zip"|"tomahawk.zip"|"todruaga.zip"|"tranqgun.zip"|"triplep.zip"|"tutankhm.zip"|"vanvan.zip"|"volfied.zip"|"vsgongf.zip"|"wiping.zip"|"warpwarp.zip"|"zigzag.zip"|"zzyzzyxx.zip"|"alphaho.zip"|"pacnchmp.zip"|"comotion.zip"|"copsnrob.zip"|"cosmicg.zip"|"cosmos.zip"|"crash.zip"|"crush.zip"|"redufo.zip"|"diamond.zip"|"dorunrun.zip"|"dominos.zip"|"drmicro.zip"|"drgnbstr.zip"|"dremshpr.zip"|"elvactr.zip"|"eyes.zip"|"firetrap.zip"|"40love.zip"|"galpanic.zip"|"gundealr.zip"|"hardhat.zip"|"headon.zip"|"headon2.zip"|"heiankyo.zip"|"hexa.zip"|"hustle.zip"|"intrepid.zip"|"ironhors.zip"|"karianx.zip"|"kungfum.zip"|"lvgirl94.zip"|"logicpro.zip"|"logicpr2.zip"|"msjiken.zip"|"kikcubic.zip"|"mineswpr.zip"|"mtrap.zip"|"dowild.zip"|"mrgoemon.zip"|"natodef.zip"|"rallyx.zip"|"nrallyx.zip"|"pepper2.zip"|"pettanp.zip"|"popeye.zip"|"punchout.zip"|"raiders5.zip"|"rampage.zip"|"reikaids.zip"|"robby.zip"|"rthunder.zip"|"sidetrac.zip"|"schaser.zip"|"spaceinv.zip"|"spacezap.zip"|"spectar.zip"|"springer.zip"|"stratvox.zip"|"sia2650.zip"|"spnchout.zip"|"tapper.zip"|"rbtapper.zip"|"targ.zip"|"telmahjn.zip"|"theglob.zip"|"thief.zip"|"timber.zip"|"toypop.zip"|"wwjgtin.zip"|"wndrmomo.zip"|"yamyam.zip"|"zerozone.zip"|"zookeep.zip"|"pairs.zip"|"higemaru.zip"|"elecyoy2.zip"|"arkangc.zip"|"arkanoid.zip"|"arkatayt.zip"|"arkatour.zip"|"arkbl2.zip"|"arkbl3.zip"|"arkbloc2.zip"|"arkblock.zip"|"arknid2j.zip"|"arknid2u.zip"|"arknoid2.zip"|"arknoidj.zip"|"arknoidu.zip"|"arknoiuo.zip"|"arkretrn.zip"|"tempest.zip"|"tempest1.zip"|"tempest2.zip"|"tempest3.zip"|"temptube.zip") # Configuration only for these ROMs.
        				$xboxkill
        				joycommand="$Player1_4Way_Mame2003 & $Player2_4Way_Mame2003 &"
        				eval $joycommand
        			;;
        			*) # Configuration for every other ROM..
        				$xboxkill
        				joycommand="$Player1_8Way_Mame2003 & $Player2_8Way_Mame2003 &"
        				eval $joycommand
        			;;
        		esac
        	;;
        

        Things to note:
        (a) all the 4 way arcade games are listed by romname. Those games use the 4 way restricted configuration. All other games use the 8 way restricted configuration;
        (b) It's very important to name your xboxdrv configurations I find, so you know what joystick is Player 1 and what joystick is Player 2;
        (c) I've got 10 buttons on my arcade for Player 1. These buttons are mapped to keys. Because of their location, I wound up mapping the buttons I assigned to "back/select" and "right trigger" (rt) to exit - back+rt=KEY_SPACE+KEY_ESC. Note that if I press these 2 buttons together it triggers the "space" and "escape" keys which are the same keys set up in Retroarch for the hotkey and the exit button. So when I press these buttons together, the game will exit;
        (d) In MAME, I have made sure that movement for Player 1 is via the arrow keys. You will see that that corresponds to my Retroarch settings and also corresponds to the settings in xboxdrv - --ui-axismap X1=KEY_LEFT:KEY_RIGHT,Y1=KEY_UP:KEY_DOWN \ etc etc. In MAME, Player 2's movement keys are D, G, R and F. Again, in Retroarch you will see the same keys are set for movement and the same for xboxdrv - --ui-axismap X1=KEY_D:KEY_G,Y1=KEY_R:KEY_F \ etc etc
        (e) As long as everything corresponds, it should work.

        So, if you haven't already done so, I'd recommend either going into Retroarch and setting up the keys as I did or make a backup of your retroarch.cfg and manually changing that file. (I always do the latter using WinSCP.)

        Then test and see if it works.

        I hope this helps.

        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

        P 1 Reply Last reply Reply Quote 0
        • P
          PMac10000 @spud11
          last edited by

          @spud11 Thanks for the detailed response. I am trying to test in my simplified setup... I have only the two Dragonrise joysticks with 6-buttons + Start and Select for each player. Joystick #1 is set to Player 1, and #2 is set to Player 2 (set and confirmed by @meleu tool). Again, my only goal is to launch 4-way joystick games from ES with the 4-way driver code, and (hopefully) not change much else about my setup. Most of my arcade games utilize lr-mame2003, some others (like the Pac-Man family) from fba. That may be complicating things somewhat.

          I also have edited my retroarch.cfg file with the exact mappings you supplied above. Still having some trouble launching xboxdrv from your runcommand-onstart code. I can launch xboxdrv just fine from a command line, and successfully create the virtual 4-way joystick:
          Your Xbox/Xbox360 controller should now be available as:
          /dev/input/js3
          /dev/input/event7

          Whenever I try to launch xboxdrv from your runcommand-onstart.sh I get a "driver or resource busy" error, so I need to work on that a bit.

          I think the jist of what you're advising is that keyboard mapping is the "lowest common denominator" of the various layers that need to be aligned (Retroarch, Mame, Xboxdrv), so it makes sense to define a common keyboard map for all the buttons in Retroarch, and then configure Mame and Xboxdrv to match the keyboard. Is that right?

          So far though, no luck, at least in the fba games where I cannot launch the RA menu no matter what I do, when the xboxdrv is active. (without xboxdrv, I just hit Select+X) . Player 1 Joysticks and buttons don't respond at all. In the mame games, I can use the keyboard to launch the tab menu and I can make progress with the 4-way games. Below is the xboxdrv parameters I've been successfully launching manually.

          #!/bin/sh
          sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
           --evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.1.2:1.0-event-joystick \
           --silent \
           --detach-kernel-driver \
           --deadzone=4000 \
           --deadzone-trigger 15% \
           --force-feedback \
           --mimic-xpad \
           --trigger-as-button \
           --ui-buttonmap lb=void,rb=void,tl=void,tr=void,guide=void,lt=void,rt=void \
           --device-name "Player_1_-_4-Way_Joystick_xboxdrv" \
           --evdev-absmap ABS_X=x1,ABS_Y=y1 \
           --four-way-restrictor \
           --evdev-keymap BTN_THUMB=y,BTN_PINKIE=a,BTN_TOP2=b,BTN_TOP=rb,BTN_TRIGGER=x,BTN_THUMB2=lb,BTN_BASE2=back,BTN_BASE=start,BTN_BASE3=lt \
          &
          
          S 1 Reply Last reply Reply Quote 0
          • S
            spud11 @PMac10000
            last edited by

            @PMac10000 Hi. You are doing very well on this.

            Yes, to your question. "....so it makes sense to define a common keyboard map for all the buttons in Retroarch, and then configure Mame and Xboxdrv to match the keyboard. Is that right?" Yes.

            Just off to work, but things to note:

            (a) Not sure about the driver or resource busy error;
            (b) Unlike lr-mame2003, FBA doesn't use the TAB interface. With FBA, it should be enough just to map the keys in Retroarch and in xboxdrv;
            (b) You need to add the actual keymapping to your xboxdrv command. The 2 lines that you need (with modifications at least to the "button mapping" because you have 6 buttons whilst I have 10) are:

            --ui-axismap X1=KEY_LEFT:KEY_RIGHT,Y1=KEY_UP:KEY_DOWN \
            --ui-buttonmap a=KEY_LEFTCTRL,b=KEY_LEFTALT,x=KEY_SPACE,y=KEY_LEFTSHIFT,lb=KEY_UNKNOWN,rb=KEY_UNKNOWN,back=KEY_UNKNOWN,start=KEY_UNKNOWN,back+rt=KEY_SPACE+KEY_ESC,lt=KEY_5+KEY_1,rt=KEY_6+KEY_2 \
            

            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

            P 1 Reply Last reply Reply Quote 0
            • ?
              A Former User @mediamogul
              last edited by

              @mediamogul said in Guide: Advanced Controller Mappings:

              Something that's always bothered me about launching xboxdrv using runcommand-onstart.sh is that it makes using the Runcommand menu itself somewhat impossible. This is because the xboxdrv mapping is made active before the Runcommand menu appears, therefore interfering with the expected control scheme. Over the weekend, I've been experimenting with some ways around this.

              First, I tried scripting the xboxdrv command not to launch until it detected that the intended emulator/port had launched. This worked well, except the script needed the specific executable name for the software it was looking for, making everything a little more laborous to set up than I felt it needed to be. I was prepared to live with it, until I noticed that AdvanceMame refused to recognized an xboxdrv simulated mouse event unless it was present before it launched. Seeing as how I play many games that rely on analog controls, it was important enough for me to rethink the approach.

              What I needed was something that could be discovered from the runcommand-onstart.sh script that signals the launch of the Runcommand menu, yet yet also signals it's closing before the emulator/port software is launched. After taking a look at /opt/retropie/supplementary/runcommand/runcommand.sh, it looked as though it invoked and exited joy2key.py in exactly the way I needed. With a little more experimenting, I came up with the following that uses the xboxdrv example from the first section of my guide.

              if [ "$2" = "advmame" ]; then
              sudo killall > /dev/null 2>&1 xboxdrv
              j2kpid="0"
              until [ "$j2kpid" -gt "0" ]; do
              j2kpid=$(pgrep -f joy2key.py)
              sleep 1
              done
              while s=$(ps -p "$j2kpid" -o s=) && [ "$s" ] && [ "$s" != 'Z' ]; do
              sleep 1
              done
              /opt/retropie/supplementary/xboxdrv/bin/xboxdrv > /dev/null 2>&1 \
              	--evdev /dev/input/by-id/[•] \
              	--silent \
              	--detach-kernel-driver \
              	--force-feedback \
              	--deadzone-trigger 15% \
              	--deadzone 4000 \
              	--mimic-xpad \
              	--evdev-absmap ABS_[•]=x1,ABS_[•]=y1,ABS_[•]=x2,ABS_[•]=y2,ABS_[•]=lt,ABS_[•]=rt,ABS_[•]=dpad_x,ABS_[•]=dpad_y \
              	--evdev-keymap BTN_[•]=a,BTN_[•]=b,BTN_[•]=x,BTN_[•]=y,BTN_[•]=lb,BTN_[•]=rb,BTN_[•]=tl,BTN_[•]=tr,BTN_[•]=guide,BTN_[•]=back,BTN_[•]=start
              fi &
              
              

              This waits for joy2key.py to launch, gets it's PID and then waits for it to end before launching whatever emulator/port is being launched (advmame in this example). So, in effect, you can now launch a game, use the Runcommand window as intended if needed and xboxdrv will launch afterwards.

              I've talked with so many people about xboxdrv on here that, unfortunately, a lot of it runs together. However, I do remember a few interested parties looking for a way to accomplish this, so I hope it helps. Granted there might be an easier, more effective way, so if anything comes to mind, please feel free to share.

              Now that I'm using xboxdrv I'm noticing this as well. Can't change emulators or interrupt launching. I would have thought it was just a change of ordering (show dialog and then do the onstart), but from what you've described, it doesn't seem that straightforward.

              mediamogulM 1 Reply Last reply Reply Quote 0
              • mediamogulM
                mediamogul Global Moderator @A Former User
                last edited by mediamogul

                @telengard said in Guide: Advanced Controller Mappings:

                from what you've described, it doesn't seem that straightforward.

                To change the order of events more efficiently would require changing runcommand.sh which isn't recommended. I still have the above solution in place and while it's a bit hacky on its face, it works very well. I believe the only thing I added was a final check to see if xboxdrv was active while runcommand.sh isn't. If that particular case ever proves true, then xboxdrv is shutdown, as it means that a gaming session is not active for whatever reason.

                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
                  PMac10000 @spud11
                  last edited by

                  @spud11 @Riverstorm
                  Long story short... I gave up on getting the xboxdrv 4-way selective-driver method described here working. I took @Riverstorm 's advice and compiled the lr-mame2003-plus package, which has a convenient 4-way joystick flag that can be enabled for these games.

                  I verified the 4-way option is present using RA Quick menu. Great! (unfortunately, I'm still having no luck mapping inputs while using lr-mame2003-plus... no buttons or keyboard inputs work, nor TAB for Mame menu. Separate problem...)

                  In any case, while troubleshooting, I used the standard lr-mame2003 package to launch some 4-way games, and noticed that the 4-way joystick option was also present in the RA Quick Menu! I believe it's only shown as an option when running a 4-way game. I can find no documentation of lr-mame2003 supporting this 4-way flag on GitHub. But yet, there it is...

                  I've found that gameplay with lr-mame2003 4-way mode enabled has proven a little challenging in Pac-Man style games, and it will take some getting used to. For example... Instead of Pac-Man taking unwanted turns like in 8-way mode, he often just stops at an intersection, unless I've clearly anticipated the turn.

                  I'm curious if anyone else here has used the 4-way joystick mode in either lr-mame2003 or lr-mame2003-plus, and can compare the gameplay to the xboxdrv method. Thanks!

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

                    @PMac10000 said in Guide: Advanced Controller Mappings:

                    I'm curious if anyone else here has used the 4-way joystick mode in either lr-mame2003 or lr-mame2003-plus, and can compare the gameplay to the xboxdrv method. Thanks!

                    I can't compare the two, as I haven't tested the feature in libretro, but I can say that no such issue exists with the xboxdrv method. Also, seeing as how the directional dropout issue exists on a surprising amount of arcade console ports as well, having an outside universal solution up your sleeve can be very beneficial. For example, my favorite 'Pac-Man' variant is 'Jr. Pac-Man', specifically for the Atari 2600, due to its incredible breakneck pacing. Without a solution for four-way restriction, you'd be hard pressed to ever complete a level.

                    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

                      @PMac10000 - I don't know anyone that has tried both methods to compare (I always had to same question :) and you're correct 4-way is not documented in mame2003.

                      It was originally developed in mame2003-plus and the devs ported many of features and updates over to mame2003 just recently. They are very similar right now except for a few features and exclusive games that were added to Plus only. It should be pretty easy to test now that it's in 2 cores if anyone has the xboxdrv method setup.

                      I think I know what you're talking about and occasionally get stuck/stopped turning on ladders in Donkey Kong or get a millisecond lag still but could never quite know for sure and as you said you adapt to it but it doesn't feel 100% correct until you accept it as normal. Funny how the mind works.

                      Now that others are experiencing some of those same anomalies it might help looking into the issue. The dev @grant2258 that developed the feature loosely calls it "last direction" I believe. He tried a few methods and decided on this one.

                      Basically the character will continue in the same direction (up, down, left, right) until a new direction (up, down, left, right) is pressed. I think that might leave a bit of room on the stick for a dead spots but I am not 100% sure.

                      I think of it this way. There's 4 switches that equate to 8 directions. Which are up, down, left and right. The four angle directions are due to two switches being pressed simultaneously like up/right, up/left, down/right and down/left.

                      When you're moving right in Pac-Man and decide to go up at a corner but instead you hit right/up vs up only I don't think it will make the turn until it's up only. I don't know if that makes sense but I wonder if that's where potential dead spot might be introduced. In true 4-way there is no angle only the four directions which leaves no dead spot.

                      All this is just theory on my part but the dev that programmed the code would be able to answer it for sure.

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

                        @PMac10000 - I don't if it will help but go into RA and then Quick Menu -> Options. Near the bottom set Input Interface to simultaneous and Legacy Remapping to enabled. Then your TAB key should work the same as mame2003 and hopefully allow you to map inputs in m3plus.

                        1 Reply Last reply Reply Quote 0
                        • G
                          grant2258 Banned
                          last edited by grant2258

                          Mame2003-plus has become very difficult for people to understand due to none legacy mode. First thing you want to do in mame2003 plus is update to the latest. Then you need to fix the input changes by deleting mame2003-plus/cfg contents.

                          the next step is to choose you controller type
                          options -> Control mapping ; analog_and_digital|digital (directions on lstick or dpad )
                          if you undestand how mame works this sets you input general too use directions default on dhat or lstick)

                          to make mame work like you are used to set the following
                          options Input interface -> simultaneous (i named this mame and mark changed it back to simultaneous)

                          no allow the mame mapping if you want to access the tab menu
                          Legacy Remapping (restart) -> enabled

                          restart you controls will work.

                          I cant really speak for mame2003 havent tested the feauture on there mark ported it there works like is should in plus.

                          1 Reply Last reply Reply Quote 0
                          • G
                            grant2258 Banned
                            last edited by

                            on another not just tested the latest mame2003 you will need to delete the mame2003/cfg dir as well the latest updates mark made requires it

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

                              @grant2258 - I think he was more focused on this statement:

                              I've found that gameplay with lr-mame2003 4-way mode enabled has proven a little challenging in Pac-Man style games, and it will take some getting used to. For example... Instead of Pac-Man taking unwanted turns like in 8-way mode, he often just stops at an intersection, unless I've clearly anticipated the turn.

                              so I replied with this:

                              I think I know what you're talking about and occasionally get stuck/stopped turning on ladders in Donkey Kong or get a millisecond lag still but could never quite know for sure and as you said you adapt to it but it doesn't feel 100% correct until you accept it as normal. Funny how the mind works.

                              Now that others are experiencing some of those same anomalies it might help looking into the issue. The dev @grant2258 that developed the feature loosely calls it "last direction" I believe. He tried a few methods and decided on this one.

                              Basically the character will continue in the same direction (up, down, left, right) until a new direction (up, down, left, right) is pressed. I think that might leave a bit of room on the stick for a dead spots but I am not 100% sure.

                              I think of it this way. There's 4 switches that equate to 8 directions. Which are up, down, left and right. The four angle directions are due to two switches being pressed simultaneously like up/right, up/left, down/right and down/left.

                              When you're moving right in Pac-Man and decide to go up at a corner but instead you hit right/up vs up only I don't think it will make the turn until it's up only. I don't know if that makes sense but I wonder if that's where potential dead spot might be introduced. In true 4-way there is no angle only the four directions which leaves no dead spot.

                              All this is just theory on my part but the dev that programmed the code would be able to answer it for sure.

                              I can't fully explain how the 4-way mode works or if there's any room for improvement but it seems there's some dead spots in using Pac-Man in his example.

                              1 Reply Last reply Reply Quote 0
                              • G
                                grant2258 Banned
                                last edited by

                                well need to fix the input issues with the latest mame2003 and plus needs the cfgs deleted because of changes. The latest mame2003 requires the same (i never changed anything on 2003). Since the input cfg files are important that needs dealt with because it can cause issues in itself. He can clarify after he updates.

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

                                  @grant2258 - I am on the current build, I've wiped all cfg files and see the same issues as he explained above with 4-way but waiting for him to verify is fine, thanks.

                                  1 Reply Last reply Reply Quote 0
                                  • G
                                    grant2258 Banned
                                    last edited by grant2258

                                    well its simple a 4 way doesnt have a 8 directions it only has 4. so if you go right then press right/up you will keep on going right )or last direction pressed until you commit to another direction.

                                    you cant play 4 way like a 8way the directions simply dont exist. If you want 100% 4 way get a restriction even on a way pressing up/right is a 50/50 what way it will go depending on what way you hold a joystick and how hard you press it. There is no point in prediction it just produces bad directions randomly. Most people seem happy with it but id be happy to remove it if you think its not working. I only added it on request

                                    https://retropie.org.uk/forum/topic/17766/mame2003-plus-hundreds-of-new-games-improved-input-features-new-bugs-now-with-runahead-support/877

                                    the code is here if anyone fancied modding it feel free prs are very welcome.

                                    https://github.com/libretro/mame2003-plus-libretro/blob/0e1506554cc752e814a5b0d493dbf54b396fc238/src/inptport.c#L2665-L2737

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

                                      @grant2258 said in Guide: Advanced Controller Mappings:

                                      Most people seem happy with it but id be happy to remove it if you think its not working.

                                      Removing the 4-way feature entirely? That sounds a bit extreme, kind of like throwing the baby out with the bath water. He is experiencing dead spots turning corners in Pac-Man. I think he was wondering if there was any improvements that could be made to address the issue and he also asked how the 4-way compared to the xboxdrv method.

                                      1 Reply Last reply Reply Quote 0
                                      • G
                                        grant2258 Banned
                                        last edited by

                                        it already been discussed here we are using digital not analog(xbox drive is probably using analog to digital ) no need to repeat what we have discussed earlier. Mame 4 way has to do digital for it to work for people with none analog pads.

                                        https://github.com/libretro/mame2003-plus-libretro/issues/380

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

                                          @grant2258 - Thanks for the link so we may submit PRs for coding a fix ourselves. I have no idea what could be done to improve it. If I did I wouldn't know how to code it anyway and you know it. You do that all the time to people on the forums here. Linking us to code we don't know how to modify.

                                          Putting your sarcasm aside, I don't believe @PMac10000 listed what type of controller he's using. It might actually help to wait for him to respond before making a bunch of assumptions as he might have some useful information that might help uncover an unknown issue or possible improvement to the existing 4-way code.

                                          P 1 Reply Last reply Reply Quote 0
                                          • P
                                            PMac10000 @Riverstorm
                                            last edited by

                                            @Riverstorm @grant2258
                                            Wow, quite a few responses. @grant2258 first of all, thanks for your coding work and in no way am I trying to complain. Rather, I'm happy to do any testing and submit any PRs that may help.

                                            I'm using a Dragonrise USB controller (standard cabinet build with 8-way native joystick, 6 buttons per player). Very similar to @spud11 's setup, who has been very helpful... but I just can't seem to get his xboxdrv 4-way approach configured correctly. Everyone seems to agree xboxdrv 4-way logic is a huge improvement for old-school gameplay.

                                            But the lr-mame2003-plus option seems much more user-friendly to me, if it accomplishes the same thing. I only want to use it for a few old-school games with 4-way joysticks, for better control and less frustration.

                                            I understand the predicament of predictive vs last-direction, when the inputs don't exist... in my current gameplay... using lr-mame2003 (not plus) with the 4-way emulation active, I'm often finding (for example) Pac-Man coming to a complete stop at an "L" or "T" shaped junction, when it "feels" like I made the choice to go in a certain direction before I got there. I guess you'd call it a dead spot. I'll keep playing a few different games and provide feedback. I also need to make the cfg deletions and legacy remapping described above, before proceeding

                                            Thanks all for their contributions.

                                            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.