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

    Mapping a keypress to a joystick (Fuse/others)

    Scheduled Pinned Locked Moved Help and Support
    controlsmappingfuseretroarchkeyboard
    14 Posts 4 Posters 2.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      SpudsMcToole Banned
      last edited by

      I've searched high and low and found lots of people asking a variant on this question, but no actual answers.

      In the Spectrum emulator Fuse, I've got a game that doesn't support any joysticks. What I want to do is map the Q and A keys on the Spectrum keyboard - FOR THIS GAME ONLY, NOT THE ENTIRE CORE OR THE WHOLE OF RETROARCH - to Up and Down on my joystick, and the P and M keys to two fire buttons.

      That seems like it ought to be a fairly simple task but I'm blowed if I can find out how, and as people will know, once you start messing around with Retropie's nest of inputs things can go very pear-shaped very fast.

      S mediamogulM 2 Replies Last reply Reply Quote 0
      • S
        SpudsMcToole Banned @SpudsMcToole
        last edited by

        @spudsmctoole

        The first thing I've tried was making a text file in the same folder as the ROM, called [GAMENAME.TAP].CFG, with the following entries:

        input_player1_a = "p"
        input_player1_b = "m"
        input_player1_up = "q"
        input_player1_down = "a"

        But that's done nothing.

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

          @spudsmctoole

          You can use the xboxdrv guide and then set a condition for just one or multiple games. I'll post an example below for advmame that allows for 4-way restricted controls for two Pac-Man titles that will fall back to the original control scheme if those titles are not detected.

          This example differs somewhat from other examples in the guide, as it also has the benefit of making the Runcommand menu fully usable and all errors from xboxdrv are logged to /dev/shm/runcommand.log, which should make troubleshooting a lot easier. Sometime soon, I plan on updating the guide to include these.

          ##Set base ROM name from the full path of $3
          ROMNAME="${3##*/}"
          
          
          if [ "$ROMNAME" = "pacman.zip" ] || [ "$ROMNAME" = "mspacman.zip" ] && [ "$2" = "advmame" ]; then
          sudo killall >> /dev/shm/runcommand.log 2>&1 xboxdrv
          until [ -n "$J2KPID" ]; do
          J2KPID=$(pgrep -f joy2key.py)
          sleep 1
          done
          until [ -z "$J2KPID" ]; do
          J2KPID=$(pgrep -f joy2key.py)
          sleep .25
          done
          ##Insert xboxdrv command for 4-way restricted advmame games here
          elif [ "$2" = "advmame" ]; then
          sudo killall >> /dev/shm/runcommand.log 2>&1 xboxdrv
          until [ -n "$J2KPID" ]; do
          J2KPID=$(pgrep -f joy2key.py)
          sleep 1
          done
          until [ -z "$J2KPID" ]; do
          J2KPID=$(pgrep -f joy2key.py)
          sleep .25
          done
          ##Insert xboxdrv command for normal advmame games here
          fi &
          

          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
          • D
            dudleydes @SpudsMcToole
            last edited by

            @spudsmctoole For Spectrum games that don't support a joystick, I use ZEsarUX which can be installed in the optional packages in the setup script.

            Remapping involves creating a text file with your config. You can find an example using Chuckie Egg at https://dosonthepi.blogspot.co.uk/2015/08/mapping-keys-to-game-controllers-in.html.

            You can find the default mappings for ZEsarUX here.

            1 Reply Last reply Reply Quote 1
            • S
              SpudsMcToole Banned @mediamogul
              last edited by

              @mediamogul Ha, I forgot to include my standard "please don't mention the absolutely terrifying xboxdrv" disclaimer :D

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

                @spudsmctoole

                Understandable. I might be confusing you with someone else I've spoken to in the past, but I thought I remembered you being pretty proficient with it. The learning curve can indeed be pretty steep.

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

                  @mediamogul No, that definitely wasn't me :D

                  S 1 Reply Last reply Reply Quote 0
                  • S
                    SpudsMcToole Banned @SpudsMcToole
                    last edited by

                    @spudsmctoole So I guess from the lack of answers (and going by similar previous threads), this is a thing that basically just can't be done. What a weird thing to omit in a platform as endlessly configurable as Retropie/Retroarch - you'd think mapping controls to buttons would be the first thing anyone would ever want to do. Oh well, thanks for the replies anyway.

                    S mediamogulM 2 Replies Last reply Reply Quote 0
                    • S
                      spud11 @SpudsMcToole
                      last edited by

                      @spudsmctoole @mediamogul It was me, I reckon!

                      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

                      S mediamogulM 2 Replies Last reply Reply Quote 2
                      • S
                        SpudsMcToole Banned @spud11
                        last edited by

                        @spud11 What? We look NOTHING alike! :D

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

                          @spud11 said in Mapping a keypress to a joystick (Fuse/others):

                          It was me, I reckon!

                          Hey, there you are! I was about to chalk you up to a hallucination, or the Mandela effect. I'm working on solving a few big things with xboxdrv right now. First, is allowing control of the Runcommand menu on launch, which only needs a little more testing. Second is much bigger and involves getting the exec mapping command to work in xboxdrv when executed as root.

                          This would open the door for a million use cases, as it could launch any bash script from a button command. Two examples off hand are universal screen shot capabilities using Raspi2PNG and the ability change your entire controller mapping on the fly with a simple button press or combo. The latter could be put to great use for changing a joystick from digital to analog on the fly, or 8-way direction to 4-way restricted. In effect, one map that called two others could be used universally throughout the entire MAME library. Keen stuff.

                          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
                          • mediamogulM
                            mediamogul Global Moderator @SpudsMcToole
                            last edited by mediamogul

                            @spudsmctoole said in Mapping a keypress to a joystick (Fuse/others):

                            you'd think mapping controls to buttons would be the first thing anyone would ever want to do.

                            When I was setting up RetroPie for the first time, this was exactly the problem I ran into over and over. I had six other emulation rigs on various platforms prior to this and was used to a level of control over input that I wasn't finding in RetroPie as a whole. This is not the fault of the RetroPie project itself mind you. It's simply a side-effect of having the option to run so many different software solutions in one package. Rather than throw my hands up and admit defeat, I sought out external mapping solutions, which ultimately led me to xboxdrv.

                            Since there were no guides available at the time, it took me THREE MONTHS of on and off experimenting to come up with a work flow that would mesh with RetroPie. I've heard you mention several times about being "terrified" at learning various control schemes, but I think you're expecting that you should understand it all immediately and that can indeed be terrifying. Why not start small and just work on this one issue as you have time. The success and failures you have will in-turn give you the knowledge to solve other issues that might arise.

                            So I guess from the lack of answers... this is a thing that basically just can't be done.

                            @dudleydes gave you a software alternative for ZX Spectrum emulation that has mapping capabilities and I offered a solution that can be used universally. However, both might depend on exactly what kind of joystick you're using. If you could post the model, it might help.

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

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

                              @mediamogul That would be very useful. My runcommand-onstart file is now 113Kb in size, but I've found it has to be devoted purely to xboxdrv and case $2. If I try to add anything else to it with more general application like trying to invoke a bash script unrelated to xboxdrv, runcommand-onstart just doesn't work.

                              Also, because I'm using $2, it's got to the point where I've found myself regularly having to copy binaries like advmame, rename them to something else like "cocktail" (for vertical/cocktail oriented games) and then create a whole new xboxdrv command in runcommand-onstart just to cater for those roms.

                              It would be handy to have a bit more flexibility in runcommand-onstart indeed.

                              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 said in Mapping a keypress to a joystick (Fuse/others):

                                My runcommand-onstart file is now 113Kb in size, but I've found it has to be devoted purely to xboxdrv and case $2. If I try to add anything else to it with more general application like trying to invoke a bash script unrelated to xboxdrv, runcommand-onstart just doesn't work.

                                I run 26 systems that make use of xboxdrv, sometimes having several dozen exceptions made for individual games. I've managed to keep the size of my runcommand-onstart.sh down to 39.9k by offloading the execution of xboxdrv itself to separate scripts. All the if/then stuff is still there, but once the conditions are met, it launches an outside script with the xboxdrv command. That may help to alleviate your situation.

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

                                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.