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

    After xboxdrv mapping, controller isn't recognized by emulator

    Scheduled Pinned Locked Moved Help and Support
    xboxdrvatari800runcommandretroarch
    21 Posts 5 Posters 2.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.
    • L
      Lummox JR
      last edited by

      I've been configuring my new RetroPie for several emulators. The Atari 800 emulator has given me the most trouble. What I need to do is map the buttons on a standard RetroPad to the various keys.

      I followed the steps outlined in this thread and in the guide posted by @mediamogul, so that xboxdrv only gets the configuration set when starting "atari800" emulation. I also ran evtest on the command I'm using and confirmed that the virtual pad created by xboxdrv (it creates /dev/input/js1 and /dev/input/event3) is in fact working and mapping buttons to keys the way it should.

      Problem: The Atari 800 emulator (lr-atari800) isn't seeing this at all. Once I setup the virtual gamepad via xboxdrv, the emulator acts as if I have no gamepad whatsoever. The key mapping doesn't do a thing, the Dpad doesn't work, or anything. I have to step out of it using F9 on a keyboard.

      What am I doing wrong? Here is my runcommand-onstart.sh file. (I'm typing this in via my main system while viewing the file on my TV, so please forgive any typos) Please note the gamepad I'm using has no analog sticks, and only one shoulder button per side; it is a bare-bones RetroPad.

      #!/bin/sh
      
      # Get ROM name stripping full path
      rom="${3##*/}"
      
      # The ID below is the same as using /dev/input/event2 but I want to support
      # multiple controllers eventually
      retropad="sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >/dev/null \
      	--evdev /dev/input/by-id/usb-0079_USB_Gamepad-event-joystick \
      	--silent \
      	--detach-kernel-driver \
      	--force-feedback \
      	--deadzone-trigger 15% \
      	--deadzone 4000 \
      	--mimic-xpad \
      	--evdev-absmap ABS_X=dpad_x,ABS_Y=dpad_y \
      	--evdev-keymap BTN_THUMB=b,BTN_THUMB2=a,BTN_TRIGGER=y,BTN_TOP=x,BTN_BASE4=start,BTN_BASE3=back,BTN_TOP2=lb,BTN_PINKIE=rb \
      	--dpad-only \
      	--ui-axismap lt=void,rt=void \
      	--ui-buttonmap tl=void,tr=void,guide=void"
      
      atari800="--ui-buttonmap a=KEY_RIGHTCTRL,b=KEY_F2,x=KEY_EQUAL,y=KEY_KPASTERISK,lb=KEY_F9,rb=KEY_F5,du=KEY_KP8,dd=KEY_KP5,dl=KEY_KP4,dr=KEY_KP6,back=KEY_F3,start=KEY_F4"
      
      # Kill command
      xboxkill="sudo killall >>/dev/shm/runcommand.log xboxdrv"
      
      ### Execute the driver with the configuration you need.
      # $1 is the name of the emulation, not the name of the software used.
      
      case $1 in
      	atari800)
      		$xboxkill
      		joycommand="$retropad $atari800 &"
      		eval $joycommand
      	;;
      esac
      

      If I run runcommand-onstart.sh atari800 from the command line, I am getting correct results from evtest /dev/input/event3. It's just that the emulator can't see it. I'm running the emulator BTW by starting emulationstation back up and going to Atari 800, then selecting the game.

      Also of special note: If for any reason the xboxdrv command fails, like for instance when I was first setting it up and had loads of typos, the controller works normally in the emulator--but obviously without the key mapping I want.

      S 2 Replies Last reply Reply Quote 0
      • S
        spud11 @Lummox JR
        last edited by

        @lummox-jr I've noticed one thing. You need an extra &:

        joycommand="$retropad & $atari800 &"
        

        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
        • S
          spud11 @Lummox JR
          last edited by

          @lummox-jr I'd also suggest replacing >/dev/null \ with >> /dev/shm/runcommand.log 2>&1 \

          Any errors will appear in /dev/shm/runcommand.log so you can see what the problem is easily.

          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
          • L
            Lummox JR
            last edited by

            I did have the logging going to runcommand.log initially to suss out any errors, and only changed it to /dev/null after those got fixed.

            As for the extra & I don't think that's correct. The original guide doesn't show such a thing. The $atari800 variable isn't a command unto itself but more arguments appended to the main command.

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

              @lummox-jr

              I'm assuming that if you use the full command on the commandline, it works?

              A couple of years ago when I tried to split my code in runcommand-onstart.sh similar to the way you've done it, I couldn't get it to work. I couldn't figure out why. It just wouldn't work.

              I wound up having entirely separate code for each emulator like this:

              Player1_Coleco="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 a=KEY_SPACE,b=KEY_M,x=KEY_1,y=KEY_2,lb=KEY_3,rb=KEY_4,back=KEY_0,start=KEY_UNKNOWN,lt=KEY_1,rt=KEY_5,back+rt=KEY_LEFTCTRL+KEY_ESC \
              --ui-buttonmap lt+rt=exec:/opt/retropie/configs/all/SoundToggle.sh"
              
              Player1_c64="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 x=void,y=void,lb=void,rb=void,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 \
              --ui-axismap X1=KEY_A:KEY_D,Y1=KEY_W:KEY_S \
              --evdev-keymap BTN_THUMB2=a,BTN_PINKIE=b,BTN_BASE3=back,BTN_BASE6=start,BTN_BASE2=lt,BTN_BASE5=rt \
              --ui-buttonmap a=KEY_F,b=KEY_W,lt=KEY_ESC,rt=KEY_SPACE+KEY_ENTER \
              --ui-buttonmap back=KEY_Y+KEY_1,start=KEY_N+KEY_2,lt=KEY_F1,rt=KEY_F2,rt+back=KEY_F12,back+rt=KEY_LEFTALT+KEY_Q \
              --ui-buttonmap lt+rt=exec:/opt/retropie/configs/all/SoundToggle.sh"
              

              So each emulator was effectively separate. It does mean that runcommand-onstart.sh can get very large, but I didn't care because it worked.

              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

              L 1 Reply Last reply Reply Quote 1
              • L
                Lummox JR @spud11
                last edited by

                When I run the full xboxdrv command from the command line, it "works" in the sense that xboxdrv creates the virtual controller and I can see it pressing keys when I run evtest. My problem is the Atari 800 emulator simply stops seeing the joystick at all.

                I haven't tried running the Atari 800 emulator from the command line yet because I don't know the command I'd need to do so (I'd have to look that up), only through EmulationStation. But I can tell that the runcommand-onstart script runs because when I don't use the special xboxdrv setup or deliberately add a typo to make the command fail, the Atari 800 emulator sees my joystick the way it normally would.

                To be thorough, I will try doing the whole command from scratch tonight in runcommand-onstart instead of piecing together a main command with extra arguments, just to see what happens. I would expect to see no difference, but there's no harm in trying. I'll give that a shot tonight. Meanwhile I'm hoping @mediamogul takes notice and can offer some guidance too.

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

                  @lummox-jr said in After xboxdrv mapping, controller isn't recognized by emulator:

                  Meanwhile I'm hoping @mediamogul takes notice and can offer some guidance too.

                  Sure. I've been using the Atari800 emulator quite a bit here recently between 'Last Starfighter', 'Montezuma's Revenge' and 'Pac-Man' (I really like the unpredictable ghost AI).

                  My problem is the Atari 800 emulator simply stops seeing the joystick at all.

                  Seeing as how you're key-mapping, the emulator shouldn't be looking for a controller at all, but rather the keyboard. Are you sure you have the emulator set to use the 'Keyboard Maps' for controller input?

                  One piece of advice you can take or leave is to key-map your entire controller. An example of this using the default Atari800 key-mappings would look like.

                  --ui-buttonmap b=KEY_RIGHTCTRL,a=KEY_RIGHTSHIFT,x=KEY_UNKNOWN,y=KEY_UNKNOWN,lb=KEY_UNKNOWN,rb=KEY_UNKNOWN,du=KEY_KP8,dd=KEY_KP5,dl=KEY_KP4,dr=KEY_KP6,start=KEY_F4,back=KEY_P,lt=KEY_UNKNOWN,rt=KEY_UNKNOWN,tl=KEY_UNKNOWN,tr=KEY_UNKNOWN
                  

                  You'll notice that only 'up', 'down', 'left', 'right', 'a', 'b', 'back' and 'start' are mapped which covers the directions, both action buttons and the start and pause functions. The rest are all mapped as 'KEY_UNKNOWN'. I do this to give myself placeholders for remapping Atari 5200 keypad input to the controller's face buttons for certain games.

                  Also, any button left unmapped will produce input from the virtual xboxdrv controller rather than the virtual keyboard, which can have undesired effects in a few emulators. That said, it can also be handy sometimes to mix keyboard input with controller input. The great part about xboxdrv its versatility for just about any use case.

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

                  1 Reply Last reply Reply Quote 0
                  • L
                    Lummox JR
                    last edited by

                    @mediamogul said in After xboxdrv mapping, controller isn't recognized by emulator:

                    Seeing as how you're key-mapping, the emulator shouldn't be looking for a controller at all, but rather the keyboard. Are you sure you have the emulator set to use the 'Keyboard Maps' for controller input?

                    I do not. Where would I change that setting? I tried looking it up but it's Google-proof.

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

                      @lummox-jr

                      I'm not near my Pi at the moment, but after invoking the options menu, it should be labeled something like 'Controller Input Settings'. From there, the option should be in one of the pull-down menus.

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

                      L 1 Reply Last reply Reply Quote 0
                      • L
                        Lummox JR @mediamogul
                        last edited by

                        @mediamogul Which options menu do you mean? There's the Retroarch RGUI (which I can't open with the joystick set the way it is), the Atari 800 emulator options via F1 (I don't see an option by that name there), or do you mean a different menu like in EmulationStation?

                        I don't see anything that has the name "Controller input settings" anywhere that I've been looking.

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

                          @lummox-jr said in After xboxdrv mapping, controller isn't recognized by emulator:

                          In the standalone Atari800 emulator, you invoke the options menu with 'F1' and then navigate to the 'Controller Configuration' menu. From there, you'll see 'Enable Keyboard Joystick' and 'Define Layout of Keyboard Joystick'. Between those two settings you'll be able to enable and map accordingly. You'll notice that there's no input setting for the second action button, necessary for some games. For some reason this is hard-coded into the emulator to be the 'Right Shift' key for both player one and two. Using xboxdrv, you can map the 'Right Shift' key using KEY_RIGHTSHIFT to whatever button you like and you should be good to go.

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

                          L 1 Reply Last reply Reply Quote 0
                          • L
                            Lummox JR @mediamogul
                            last edited by Lummox JR

                            @mediamogul The emulator I'm using is lr-atari800. When I go to "Controller configuration" in the F1 menu, I see these options:

                            Joystick autofire: No
                            Enable MultiJoy4: No
                            Mouse device: None
                            Mouse port: 1
                            Mouse speed: 3
                            

                            There is no option to enable a keyboard joystick.

                            If I change the emulator to just plain atari800, I do see that option. However, the colors of the non-lr atari800 emulator are totally messed up, so that the default colors instead of being white on blue are very light blue on white, and the game looks all wrong.

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

                              @lummox-jr said in After xboxdrv mapping, controller isn't recognized by emulator:

                              However, the colors of the non-lr atari800 emulator are totally messed up, so that the default colors instead of being white on blue are very light blue on white, and the game looks all wrong.

                              Believe it or not, this is meant to better simulate how the games would actually look on original hardware. In the Options menu, you can set it to use true black and vibrant colors, which is probably the way lr-atari800 is set by default.

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

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

                                @mediamogul I'm using the atari800 emulator too. @Lummox-JR As mediamogul says, mapping to the keys generally works better than other methods.

                                If you can't get lr-atari800 to work properly, in atari800's GUI (entered with F1), go to "controller configuration" and define the joystick keys for both joysticks 1 and 2. For example, I mapped joystick 1/player 1 up/down/left/right to W, S, A and D etc. My xboxdrv configuration looks like this:

                                Player1_atari800="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 b=void,x=void,y=void,lb=void,rb=void,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 \
                                --ui-axismap X1=KEY_A:KEY_D,Y1=KEY_W:KEY_S \
                                --evdev-keymap BTN_THUMB2=a,BTN_BASE3=back,BTN_BASE6=start,BTN_BASE2=lt,BTN_BASE5=rt \
                                --ui-buttonmap a=KEY_F \
                                --ui-buttonmap back=KEY_UNKNOWN,start=KEY_UNKNOWN,rt+back=KEY_F1,back+rt=KEY_F9,lt=KEY_F4,rt=KEY_SPACE \
                                --ui-buttonmap lt+rt=exec:/opt/retropie/configs/all/SoundToggle.sh"
                                

                                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 1
                                • L
                                  Lummox JR @mediamogul
                                  last edited by Lummox JR

                                  @mediamogul Thank you! I finally got all this working!

                                  The only question I have left is that if I have a .bin file that I'm loading, is there any way to tell the emulator what cartridge type is being loaded so I don't have to manually select that (with the keyboard) each time? (Also, is there a way to choose to load BASIC with certain images? There were lots of BASIC games I used to play from Compute! magazine.)

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

                                    @lummox-jr said in After xboxdrv mapping, controller isn't recognized by emulator:

                                    is there any way to tell the emulator what cartridge type is being loaded so I don't have to manually select that (with the keyboard) each time? (Also, is there a way to choose to load BASIC with certain images? There were lots of BASIC games I used to play from Compute! magazine.)

                                    Both can be accomplished by first selecting the right cartridge type or to load with BASIC and then save the ROM out through the options menu using the cartridge management menu. I would recommend saving them to a separate location, rather than saving over the existing files, then archive the originals and finally move the newly saved ROMs into place.

                                    Edit: Come to think of it, I don't believe you can specify BASIC this way, but cartridge types will definitely work.

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

                                    L 1 Reply Last reply Reply Quote 0
                                    • L
                                      Lummox JR @mediamogul
                                      last edited by Lummox JR

                                      @mediamogul I found a solution to running BASIC games (these being in .atr files created by basic2boot). This is what the relevant part of my runcommand-onstart.sh file looks like now:

                                      	# In the case statement
                                      	atari800)
                                      		eval $xboxkill
                                      		joycommand="$retropad $atari800 &"
                                      		eval $joycommand
                                      		basicregex='basic\.atr$'
                                      		if [[ $rom =~ $basicregex ]]; then
                                      			newcmd=`echo $4 | sed 's/\(atari800 \)/\1-basic -xl /'`
                                      			echo >>/dev/shm/runcommand.log "Execute: $newcmd"
                                      			# Launch the game with altered params
                                      			eval >>/dev/shm/runcommand.log $newcmd
                                      			eval $xboxkill
                                      			# Kill the calling script so it doesn't launch the game
                                      			kill $(ps ex | grep runcommand.sh | grep bash | awk '{print $1}')
                                      		fi
                                      	;;
                                      

                                      I thought that might be pretty useful for others looking to run BASIC games when the emulator is configured to leave BASIC off by default. In my case it was Gold Rush from the Compute! magazine. The filename is "goldrush -basic.atr". I haven't figured out yet how to get the i flag into the regex I'm using in the if statement (this is largely cobbled together via a lot of Google fu and trial and error) but I'm otherwise happy with it.

                                      L 1 Reply Last reply Reply Quote 1
                                      • L
                                        Lummox JR @Lummox JR
                                        last edited by

                                        Darn it, I'm trying to edit my post but the stupid spam filter isn't letting me.

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

                                          @lummox-jr

                                          It should let you edit it now that some time has passed. If not, I'll delete it and you can post your revision below. In any event, thanks for posting your solution. I don't currently have any games in mind that this would apply to, but I'm sure I'll run across some eventually and I'll give this a shot.

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

                                          cheesymonkeyC 1 Reply Last reply Reply Quote 0
                                          • cheesymonkeyC
                                            cheesymonkey @mediamogul
                                            last edited by

                                            Six years later, I’m on 4.8.8 on a Pi 5 and I too cannot get the standalone emulator to work with my controller (8BitDo Pro 2). Have followed all the steps, but nothing.

                                            Well, almost nothing…

                                            If I start emulationstation under tmux directly on the Pi, then log into the same tmux session via SSH on my laptop, I can see the remapped button values (‘4’ when I D-Pad left, ‘6’ when right, etc.) which possibly means xboxdrv is being loaded correctly, the remapping is working but atari800 cannot ‘see’ this.

                                            I’m connecting by Bluetooth and xboxdrv assigns a different event handler to that it initially connects on. The guide is unclear on having to remap the controller once it is being handled by xboxdrv. I had to quit out of ES with F4, then run the xboxdrv command in the background, restart ES and remap. Is thia how it should be done? I’m not starting xboxdrv through rc.local as a) Bluetooth and b) I only want to use this method for this emulator, particularly to remap number keys for games like Miner 2049er.

                                            mituM 1 Reply Last reply Reply Quote 0
                                            • mituM mitu locked this topic on
                                            • 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.