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

Xbox compatible controllers working with xboxdrv on EmulationStation and Linux but not on Retroarch emulators



    • Pi Model or other hardware: Raspberry Pi 4
    • Power Supply used: Official Raspberry Pi 4 power supply (3A)
      RetroPie Version Used: 4.6 (all core packages + selected main and optional packages)
    • Built From: Raspberry Pi OS Lite 10 (buster)
      USB Devices connected: 2.5" HDD (SATA USB adapter) + 2 controllers
    • Controller used: 2 Logitech Gamepad F710
    • Guide used: https://retropie.org.uk/docs/Universal-Controller-Calibration-%26-Mapping-Using-xboxdrv
    • Emulator: lr-mupen64plus and lr-pcsx-rearmed

    I've been trying to get my two Logitech Gamepad F710 controllers working with xboxdrv on Retroarch emulators (r-mupen64plus and lr-pcsx-rearmed) without success so far.

    With the default settings (xpad) I was able to set them up on EmulationStation and they worked without problems both there and on some Retroarch emulators (r-mupen64plus and lr-pcsx-rearmed).

    I intend to eventually use them with computer emulators and Linux games that don't support controllers, hence I want to be able to map them to a keyboard and mouse.

    I first tried with Linux Joystick Mapper (https://sourceforge.net/projects/linuxjoymap) without success.

    xboxdrv seems a more popular option and I tried following the documentation (https://retropie.org.uk/docs/Universal-Controller-Calibration-%26-Mapping-Using-xboxdrv)

    Following the guide I installed xboxdrv and disabled it using the retropie setup and edited the /etc/rc.local https://pastebin.com/YAsCDYii

    After that I was able to set up the two new virtual controllers on EmulationStation, and there they work without problems.

    I installed Blobby Volley (a Linux game), created a custom "system" copying /etc/emulationstation/es_systems.cfg onto /opt/retropie/configs/all/emulationstation/es_systems.cfg and editing it and creating the following shell script on ~/RetroPie/roms/misc https://pastebin.com/Hy9VRgUY

    The shell script kills the two xboxdrv processes with the default config, runs two new processes with a game specific config (where the controllers are mapped to a keyboard and mouse) and runs the game. When the game finishes, the two processes with the game specific config are killed and two new processes are run with the default config. The controllers also work fine (mapping to keyboard and mouse included) on a Linux game run this way.

    However, I have now noticed that the controllers are not working properly on the two Retroarch emulators. Most buttons don't do anything, and a few do the wrong thing. This happens independently of whether I try first thing after a restart or after I've played Blobby Volley (and hence killed and rerun the processes). Why? I understood that Retroarch emulators piggyback their controller config from EmulationStation, and the controllers are working fine there.

    When I started these emulators a saw a 4 pop-ups on the bottom left saying that 4 controllers were configured - the 2 physical Logitech and the two emulated Xbox.

    As part of my investigation I went into /opt/retropie/configs/all/retroarch/autoconfig where I had 4 files - two related to the physical Logitech (*.cfg and .cfg.bak) and two related to the emulated Xbox (.cfg and *.cfg.bak) and deleted the Logitech ones.

    Now when I start one of the Retroarch emulators it still detects 4 controllers, but it says that the Xbox ones are configured and the Logitech ones are not. However, the issue still persists.

    I have also tried editing /opt/retropie/configs/all/retroarch.cfg and replaced:

    # input_player1_joypad_index = 0
    # input_player2_joypad_index = 1
    

    With:

    input_player1_joypad_index = 2
    input_player1_joypad_index = 3
    

    To ensure that the right (emulated Xbox) controllers are used (which according to the pop-ups are controllers 2 and 3.

    Why is this working on EmulationStation and a Linux game yet not on Retroarch emulators? Thanks for all your suggestions.


  • Global Moderator

    Check in RetroArch's RGUI what joypads are configured for P1 and P2 - in the Controls section of the menu. The order or joysticks might be different than the one you set-up.

    Did you also configure the - emulated - Xbox controllers in EmulationStation ?



  • It's difficult to navigate through the Retroarch menu, as the buttons are not mapped as expected (the same it happens with the Retroarch emulators with which I'm having problems). Ports 1 and 2 are allocated to the physical Logitech controllers. Port 3 and 4 to the virtual Xbox controllers and port 5 is N/A.

    Yes, the virtual Xbox controllers have been configured on EmulationStation and they appear as configured on the pop-ups on the bottom left when starting up the Retroarch emulators.

    The physical Logitech controllers are not configured anymore as I deleted their files from /opt/retropie/configs/all/retroarch/autoconfig and they now appeared as unconfigured (as expected) when starting up the Retroarch emulators.

    I assume that ideally I want to get the emulated Xbox controllers allocated to players 1 and 2 on Retroarch. That's why I've edited /opt/retropie/configs/all/retroarch.cfg input_player1_joypad_index and input_player2_joypad_index options right? Why do they appear on a different order here? How do I change this?

    Thanks for your time.


  • Global Moderator

    @cvillarl said in Xbox compatible controllers working with xboxdrv on EmulationStation and Linux but not on Retroarch emulators:

    Why do they appear on a different order here? How do I change this?

    Each system has it's own retroarch.cfg file, which inherits from the 'global' retroarch.cfg - the one you modified. However, if you used 'Save/Reset Configuration' at some point from the RGUI, the system's configuration will take over and will not look in the file you configured.

    So check - for the system where you opened the game and you have P1/P2 still as the Logitech - the retroarch.cfg in /opt/retropie/configs/<system> and see if it still includes /opt/retropie/configs/all/retroarch.cfg or it's just a huge list of configuration options.

    Regarding your configuration, I find it a bit peculiar to use xboxdrv globally and remove the configuration for the actual gamepads (especially in RetroArch). If you use xboxdrv only for a few systems (to simulate keyboard/mouse movements), then I'd use the Runcommand onstart/onend scripts to start/stop xboxdrv on-demand (on those systems) and don't start it from /etc/rc.local (globally).



  • My understanding of the estructure of Retroarch was as you have described; an overall config file and system specific config files that override the general config. But if I look at the two relevant system config files, there isn't anything there overriding the general config:

    $ cat /opt/retropie/configs/n64/retroarch.cfg
    # Settings made here will only override settings in the global retroarch.cfg if placed above the #include line
    
    input_remapping_directory = "/opt/retropie/configs/n64/"
    
    #include "/opt/retropie/configs/all/retroarch.cfg"
    
    $ cat /opt/retropie/configs/psx/retroarch.cfg
    # Settings made here will only override settings in the global retroarch.cfg if placed above the #include line
    
    input_remapping_directory = "/opt/retropie/configs/psx/"
    
    #include "/opt/retropie/configs/all/retroarch.cfg"
    

    In more general terms, and regarding how to structure the configuration, I considered something similar to what you have described, but I actually thought my current approach would be easier.

    This approach is to always use xboxdrv and the emulated Xbox controllers and to always "ignore" the physical Logitech controllers. And as I run games, to change the xboxdrv settings from a straight controller to keyboard+mouse mapping as required.

    The alternative you suggest is to mostly rely on xpad for EmulationStation and Retroarch emulators and only use xboxdrv when I need keyboard+mouse mapping. Either by using Runcommand onstart/onend scripts or a shell script as on my example. The trick here is how to ensure that, when I'm using xboxdrv with a game that needs mapping, the keypresses are understood as coming from the Xbox controller (and hence remapped) and not from the Logitech controller.

    I should do some testing on this approach, although I still don't understand why the first one doesn't work.


  • Global Moderator

    Can you post your actual retroarch.cfg, with the modifications you've done ? Use pastebin.com, since it's rather large.



  • Sure, this my /opt/retropie/configs/all/retroarch.cfg
    https://pastebin.com/25ZYJNs7


  • Global Moderator

    It looks ok, for completeness I would have added also the entries for P3/P4.
    The re-mapping of joypads can be toggled from the RGUI, where you can change the joypad index for each player (Port 1 to 4) and then you can save the core remap. Try using the RGUI, but re-configure the Logitech gamepads again so you'll have a configuration file for them.



  • It has worked!

    In a bit more detail:

    I didn't add entries for P3 and P4 on retroarch.cfg because, what would I set them to if I only have two controllers? 4 and 5, assuming that I could be plugging in additional ones?

    Anyway, I tried to re-add the two physical Logitech controllers to EmulationStation; it detect 4 controllers, but it would keep detecting the button presses as coming from the emulated Xbox controllers.

    I then reset the controller settings for EmulationStation on the Retropie menu and again, it would detect 4 controllers, but it also would keep detecting the button presses as coming from the emulated Xbox controllers.

    I had to disable xboxdrv and then it would only detect 2 controllers and the button presses a coming from the physical Logitech controllers. The conclusion here is for EmulationStation the physical and emulated controllers don't clash; the emulated ones take priority and the button presses are understood to be coming from them.

    I then checked that on the Retroarch menu the emulated controllers were assigned to P1 and P2 and removed the physical controllers that were assigned to P3 and P4. And then everything was fine. The crux here appears to be that I had a clash, as both the emulated and physical controllers were assigned to players and probably registering button presses. Something that support this hypothesis is that on games where you have a grid to select your character (e.g. Mario Kart) it was fairly obvious that when I was pressing once to move one cell to the right, for instance, the selection box was moving two cells.

    Thanks again for all your time helping me figure this out.



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.