@mitu said in Unique config/controller mapping per Gamepad per Core:
If you're thinking of doing this for multiple joysticks/systems, then it might be easier to use an onstart script for runcommand. Instead of overriding joypad_autoconfig_dir, keep a list of desired configurations for a joystick and just copy it over to joypad_autoconfig_dir before the game starts. This way you'll keep one config per standard controller (like the SF 30 Pro) and you can have configs per-system for certain controllers.
...
Somehow this comes up as more complicated than it is and I can't help of thinking if there's a better way.
I modified your script so that it doesn't need to know the names of my controllers or use any new folders:
joypad_autoconfig_dir="/opt/retropie/configs/all/retroarch-joypads" # Put this script in /opt/retropie/configs/all/runcommand-onstart.sh # To support different gamepad autoconfigurations for a joypad in different # libretro emulators copy the current .cfg and rename it with _default added # to the end of the filename. # For each gamepad+emulator combination that requires a variation create # a new copy of the .cfg_default file, changing "default" to match the libretro # core that it applies to, for example .cfg_lr-picodrive. # Modify each variation as needed. This script will copy the variations # (or the default) over the orginal .cfg file as required each time an # emulator is started. # Log output goes to /dev/shm/runcommand.log echo "$0: looking for custom gamepad autoconfigs for $2 in $joypad_autoconfig_dir" >&2 for default_cfg in $joypad_autoconfig_dir/*.cfg_default; do [ -e "$default_cfg" ] || continue # stop now if there are no matches target_cfg_name=${default_cfg%.*} # remove file extention .cfg_default required_variation_cfg="$target_cfg_name.cfg_$2" if [ -e "$required_variation_cfg" ]; then echo "Using autoconfig variation $required_variation_cfg" >&2 cp -f "$required_variation_cfg" "$target_cfg_name.cfg" else echo "Using default gamepad autoconfig $default_cfg" >&2 cp -f "$default_cfg" "$target_cfg_name.cfg" fi doneAll of the .cfg variations stay together in the /opt/retropie/configs/all/retroarch/autoconfigs directory, but with different extensions to indicate which core they are needed for. For example, autoconfigs has these files:
pi@rpi-tv:/opt/retropie/configs/all/retroarch $ ls -1 autoconfig/ 'Microsoft X-Box One pad.cfg' 'SWITCH CO.,LTD. USB Gamepad .cfg' 'SWITCH CO.,LTD. USB Gamepad .cfg_default' 'SWITCH CO.,LTD. USB Gamepad .cfg_lr-fbneo' 'SWITCH CO.,LTD. USB Gamepad .cfg_lr-genesis-plus-gx' 'SWITCH CO.,LTD. USB Gamepad .cfg_lr-picodrive' 'USB gamepad .cfg'The .cfg_lr-picodrive is a symlink to the .cfg_lr-genesis-plus-gx that I made just to check if it would work.
I put some logging in to remind me what's happening if I forget that it's there.
Using joypad_autoconfig_dir in retroarch.cfg seems a bit more "standard", to me so I've stuck with that here. I thought the script could be useful to share though :)