#!/bin/bash # NAME OF DESIRED MOUSE INPUT # Can be found via the RetroArch log file or by running 'evtest' mouse_name="Combined Analog Arcade Controls" # RetroArch log file must be enabled for this to work batocera-settings-set global.retroarch.log_dir "/userdata/system/logs/retroarch" batocera-settings-set global.retroarch.log_to_file true batocera-settings-set global.retroarch.log_to_file_timestamp false # Read the mouse index values from the last RetroArch log file # and update the config for the next time RetroArch is run # NOTE: Using '~' as a sed delimiter as some device names include the traditional '/' delimiter # NOTE: Pipe to 'head -1' to return the index of the first matching device, as some devices expose multiple inputs mouse_index=$(sed -En "s~.*Mouse.* #(.*): \"$mouse_name\".*~\1~p" /userdata/system/logs/retroarch/retroarch.log | head -1) if [[ -z "$mouse_index" ]]; then mouse_index=0 fi batocera-settings-set global.retroarch.input_player1_mouse_index $mouse_index