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

    xboxdrv remapping in atari800 emulator not working?

    Scheduled Pinned Locked Moved Help and Support
    xboxdrvruncommandatari800xpadneoremap
    11 Posts 2 Posters 388 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.
    • mituM
      mitu Global Moderator
      last edited by mitu

      You should first start xboxdrv without anything loaded (i.e. exit EmulationStation) and check with evtest that it's outputting/translating the correct values. xboxdrv creates a (user space) input device and it should be detected by both emulators and EmulationStation, but you since you intend to use xboxdrv only for certain remapping configurations (emulators and/or game), there's no need to re-configure it in EmulationStation - xboxdrvwill not be active when EmulationStation runs, only during gameplay.

      2nd, remove the complicated controllerX detection since you have just one gamepad, there's no need to all those commands - just point xboxdrv at /dev/input/js0, where the 1st gamepad inode is created.

      Check the emulator log in /dev/shm/runcommand.log and see if xboxdrv is started correctly and doesn't give an error (it shouldn't , if you 1st step has been succesfull).

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

        Accessing through ssh, Emulation Station is not currently loaded, but Kodi is. Controller is accessible at /dev/input/event0

        evtest tests

        With xboxdev not loaded

        • evtest /dev/input/event0
          • Works, all buttons report as expected
        • evtest /dev/input/js0
          • Errors out: evtest: can't get version: Invalid argument

        With xboxdev loaded

        As xboxdrv not in my $PATH, setting alias xboxdrv="sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv" for sanity.

        xboxdrv --evdev /dev/input/event0

        xboxdrv own output is one line per button press/axis push, but event output is 0 across the board:

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

        Setting to background and silencing the event output with xboxdrv --evdev /dev/input/event0 --silent &, then running… [xboxdrv reports back in this case its event output is available on event 1 and js1]

        • evtest /dev/input/event0
          • Errors out, saying that This device is grabbed by another process…
        • evtest /dev/input/event1
          • Running, but no button presses are resistered on screen at all – probably to do with no (re)mappings in the xboxdrv command given
        • evtest /dev/input/js0
          • Errors out with evtest: can't get version: Invalid argument, as expected
        • evtest /dev/input/js1
          • Errors out with evtest: can't get version: Invalid argument, not as expected
        xboxdrv --evdev /dev/input/event0 --evdev-absmap ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y,ABS_X=x1,ABS_Y=y1,ABS_RX=x2,ABS_RY=y2,ABS_Z=lt,ABS_RZ=rt --evdev-keymap BTN_A=a,BTN_B=b,BTN_X=x,BTN_Y=y,BTN_TL=lb,BTN_TR=rb,BTN_THUMBL=tl,BTN_THUMBR=tr,BTN_SELECT=back,BTN_START=start,BTN_MODE=guide

        We now have full event output, so now to push it into the background run evtest again on event1 and js1:

        • `evtest /dev/input/event1
          • Runs, displaying all event outputs almost as expected, with the addition of the Mode/Guide button also responding. Almost, as the triggers display ABS_BRAKE and ABS_GAS instead of ABS_Z and ABS_RZ for some reason.
        • evtest /dev/input/js1
          • Again, errors out with evtest: can't get version: Invalid argument

        Running atari800 – output of /dev/shm/runcommand.log (running Donkey Kong)

        Emulator: atari800
        Software: atari800
        Game/rom: /home/pi/RetroPie/roms/atari800/Donkey Kong (1983).car
        CLI: /opt/retropie/emulators/atari800/atari800.sh "/home/pi/RetroPie/roms/atari800/Donkey Kong (1983).car"
        Rom: Donkey Kong (1983).car
        controller1: event9
        Running xboxdrv for atari800
        xboxdrv: no process found
        xboxdrv 0.8.8 - http://pingus.seul.org/~grumbel/xboxdrv/
        Copyright © 2008-2011 Ingo Ruhnke <grumbel@gmail.com>
        Licensed under GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
        This program comes with ABSOLUTELY NO WARRANTY.
        This is free software, and you are welcome to redistribute it under certain
        conditions; see the file COPYING for details.
        
        Your Xbox/Xbox360 controller should now be available as:
          /dev/input/js1
          /dev/input/event10
        
        Press Ctrl-C to quit
        Parameters:
        Executing: LD_PRELOAD="/opt/retropie/supplementary/sdl12-compat/libSDL-1.2.so.0" /opt/retropie/emulators/atari800/atari800.sh "/home/pi/RetroPie/roms/atari800/Donkey Kong (1983).car"
        Unsupported archive: /home/pi/RetroPie/roms/atari800/Donkey Kong (1983).car
        Using Atari800 config file: /home/pi/.atari800.cfg
        Created by Atari 800 Emulator, Version 5.2.0
        
        Keyboard mapped to emulated joystick 0
        Keyboard mapped to emulated joystick 1
        Joystick 0 mapped to emulated joystick 0
        Joystick 1 mapped to emulated joystick 1
        Video Mode: 1920x1080x32 fullscreen, pixel format: BGRA32
        OpenGL initialized successfully. Version: 3.1 Mesa 23.2.1-1~bpo12+rpt3
        OpenGL Pixel Buffer Objects available.
        ~
        Shutdown complete
        
        1 Reply Last reply Reply Quote 0
        • mituM
          mitu Global Moderator
          last edited by

          Ok, so the driver works for atari800 and it's seen by the emulator (according to the start message - Joystick 1 mapped to emulated joystick 1), maybe additional configuration needs to be done inside the emulator for the mapping ?

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

            It looks as if the key/button presses are being passed to the console and being displayed there but not further passed on to the emulator. I can't see any suitable options to change in atari800 – the internal keyboard mapping matches the external mapping and the Use real joysticks option is for period-appropriate hardware? I'm at work so I can't check right now, but I'm going to assume when applied to another emulator (I'll try later with ScummVM as per the original guide) the same issue will occur. As I'm using a Pi 5, could it be something to do with the manual (and sort-of unofficial) nature of the Retropie install itself?

            mituM 1 Reply Last reply Reply Quote 0
            • mituM
              mitu Global Moderator @cheesymonkey
              last edited by

              @cheesymonkey said in xboxdrv remapping in atari800 emulator not working?:

              It looks as if the key/button presses are being passed to the console and being displayed there but not further passed on to the emulator.

              Not really, the emulator (i.e. the input handling library which is libsdl1.2) reads from /dev/input/eventX, not from the 'console'.

              As I'm using a Pi 5, could it be something to do with the manual (and sort-of unofficial) nature of the Retropie install itself?

              Unlikely, but Pi5 support is stil pending so YMMV and various issues may come up.

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

                Here's my latest runcommand-onstart.sh to test both atari800 and scummvm. As expected, this results in both emulators not seeing the button/axis events even though runcommand.log shows xboxdrv starting without issue:

                #!/bin/sh
                
                rom="${3##*/}"
                
                echo "Emulator: $1" >> /dev/shm/runcommand.log
                echo "Software: $2" >> /dev/shm/runcommand.log
                echo "Game/rom: $3" >> /dev/shm/runcommand.log
                echo "CLI: $4" >> /dev/shm/runcommand.log
                echo "Rom: ${rom}" >> /dev/shm/runcommand.log
                
                # Try to automatically find the correct event[•] of the connected controllers
                controller1=`grep -Ei "js+" /proc/bus/input/devices | sort | grep -Eo 'event[0-9]{1,2}' | sed -n -e '1{p;q}'`
                controller2=`grep -Ei "js+" /proc/bus/input/devices | sort | grep -Eo 'event[0-9]{1,2}' | sed -n -e '2{p;q}'`
                controller3=`grep -Ei "js+" /proc/bus/input/devices | sort | grep -Eo 'event[0-9]{1,2}' | sed -n -e '3{p;q}'`
                controller4=`grep -Ei "js+" /proc/bus/input/devices | sort | grep -Eo 'event[0-9]{1,2}' | sed -n -e '4{p;q}'`
                
                echo "controller1: ${controller1}" >> /dev/shm/runcommand.log
                
                xbdkill="sudo killall >>/dev/shm/runcommand.log xboxdrv"
                
                # xboxdrv settings
                map="--evdev-absmap ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y,ABS_X=x1,ABS_Y=y1,ABS_RX=x2,ABS_RY=y2,ABS_Z=lt,ABS_RZ=rt \
                --evdev-keymap BTN_A=a,BTN_B=b,BTN_X=x,BTN_Y=y,BTN_TL=lb,BTN_TR=rb,BTN_THUMBL=tl,BTN_THUMBR=tr,BTN_SELECT=back,BTN_START=start,BTN_MODE=guide"
                basicSettings="--silent --detach-kernel-driver --force-feedback"
                deadzone="--deadzone 4000 --deadzone-trigger 15%"
                fourway="--four-way-restrictor"
                invert="--ui-buttonmap du=KEY_DOWN,dd=KEY_UP"
                
                remapAtari800="--ui-axismap x1=KEY_KP4:KEY_KP6,y1=KEY_KP8:KEY_KP5 \
                --ui-buttonmap du=KEY_KP8,dd=KEY_KP5,dl=KEY_KP4,dr=KEY_KP6,a=KEY_RIGHTSHIFT,b=KEY_RIGHTCTRL,x=KEY_F9,y=KEY_F1 \
                --ui-buttonmap lb=KEY_UNKNOWN,rb=KEY_UNKNOWN,lt=KEY_UNKNOWN,rt=KEY_UNKNOWN,tl=KEY_UNKNOWN,tr=KEY_UNKNOWN,back=KEY_P,start=KEY_F4,guide=KEY_UNKNOWN"
                remapScummVM="--axismap -Y1=Y1,-Y2=Y2 \
                --ui-axismap x1=REL_X:10,y1=REL_Y:10,x2=void,y2=void \
                --ui-buttonmap a=BTN_LEFT,b=BTN_RIGHT,start=KEY_F5,back=KEY_ESC,guide=KEY_LEFTCTRL+KEY_Q,x=void,y=void,lb=void,rb=void,tl=void,tr=void,lt=void,rt=void,back=void"
                
                case $1 in
                
                  atari800)
                    eval ${xbdkill}
                    echo "Running xboxdrv for ${1}" >>/dev/shm/runcommand.log 2>&1
                    eval "sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >>/dev/shm/runcommand.log 2>&1 \
                    --evdev /dev/input/${controller1} \
                    ${basicSettings} \
                    --mimic-xpad-wireless \
                    --trigger-as-button \
                    ${deadzone} \
                    ${map} \
                    ${remapAtari800} \
                    &"
                  ;;
                
                  scummvm)
                    eval ${xbdkill}
                    echo "Running xboxdrv for ${1}" >>/dev/shm/runcommand.log 2>&1
                    eval "sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >>/dev/shm/runcommand.log 2>&1 \
                    --evdev /dev/input/${controller1} \
                    ${basicSettings} \
                    --mimic-xpad-wireless \
                    --trigger-as-button \
                    ${deadzone} \
                    ${map} \
                    ${remapScummVM} \
                    &"
                  ;;
                
                esac
                
                cheesymonkeyC 1 Reply Last reply Reply Quote 0
                • cheesymonkeyC
                  cheesymonkey @cheesymonkey
                  last edited by cheesymonkey

                  I realised I hadn't tried starting one of these emulators directly. Working directly with the Pi (going through ssh won't work), F4 to leave Emulation Station and a sudo killall xboxdrv just to be sure. Then I ran runcommandonstart.sh directly:

                  /opt/retropie/configs/all/runcommand-onstart.sh atari800
                  

                  This returned nothing (expected) so checked xboxdrv was up and running by checking dev/shm/runcommand.log (I read using batcat which is like a cross between cat and less with added syntax highlighting). Everything seems to be fine, so I then start the atari800 emulator with:

                  /opt/retropie/emulators/atari800/atari800.sh "/home/pi/RetroPie/roms/atari800/Donkey Kong (1983).car"
                  

                  It loads and… it works! Axis needs inverting for the stick, but apart from that, the other remapped keys seem to work, including X to quit the emulator.

                  So the question remains, why isn't the xboxdrv-controlled controller being seen by an emulator when started through ES/runcommand – where are the events being sent to? Is there something I've overlooked, obvious or not?

                  EDIT: scummvm still has no controller recognition started in this way, but atari800 does. Does ScummVM have native controller handling?

                  mituM 1 Reply Last reply Reply Quote 0
                  • mituM
                    mitu Global Moderator @cheesymonkey
                    last edited by mitu

                    @cheesymonkey said in xboxdrv remapping in atari800 emulator not working?:

                    So the question remains, why isn't the xboxdrv-controlled controller being seen by an emulator when started through ES/runcommand – where are the events being sent to? Is there something I've overlooked, obvious or not?

                    I think the difference is that when started by runcommand, the sdl12-compat library is used by the emulator (a SDL2 compatibility shim that implements SDL12), while running it outside of runcommand it uses the sdl12 library directly. Doesn't offer an explanation on why it's not working though, since SDL2 has a wider input handling support than SDL1. I'd also check the permissions on xboxdrv input files (/dev/input/eventX), that might be an issue.

                    EDIT: you can test the 1st theory (sdl12-compat interference) by going into the Configuration / tools part of RetroPie-Setup, then opening the backends menu and set default as the video backend for atari800. Then launch the Atari800 emulator from EmulationStation and see if the input handling is difference w.r.t. xboxdrv.

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

                      @mitu said in xboxdrv remapping in atari800 emulator not working?:

                      EDIT: you can test the 1st theory (sdl12-compat interference) by going into the Configuration / tools part of RetroPie-Setup, then opening the backends menu and set default as the video backend for atari800. Then launch the Atari800 emulator from EmulationStation and see if the input handling is difference w.r.t. xboxdrv.

                      This works, but I'll need to test across other games which hopefully will not involve more than sorting out correct button mappings. I noticed that for scummvm, its only backend options are for SDL2 and therefore will not work (as far as I can tell) with xboxdrv.

                      It's looking to me as if xboxdrv may be a bit of a dead end when it comes to button remappings for non-libretro emulators in RetroPie. Can such remappings be done in SDL2 or is there another option that could be applied system-wide?

                      mituM 1 Reply Last reply Reply Quote 0
                      • mituM
                        mitu Global Moderator @cheesymonkey
                        last edited by mitu

                        This works, but I'll need to test across other games which hopefully will not involve more than sorting out correct button mappings. I noticed that for scummvm, its only backend options are for SDL2 and therefore will not work (as far as I can tell) with xboxdrv.

                        That's because ScummVM is already a SDL2 application and there's no need for a compatibility shim like sd12-compat.

                        It's looking to me as if xboxdrv may be a bit of a dead end when it comes to button remappings for non-libretro emulators in RetroPie. Can such remappings be done in SDL2 or is there another option that could be applied system-wide?

                        Not dead, just not widely used. xboxdrv itself is mostly feature complete and there's little development nowadays, since compatibility with Xbox controllers is offered OOB by Linux kernel modules (xow, xpad, xpadneo).

                        There are no alternative re-mapping solutions in RetroPit, though anything that works in Linux and without X11/Wayland could work.

                        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.