MizterB This is genius! Helped me with issues because multiple mice were making some games jittery. Now my Wii mayflash is super smooth and accurate. I tweaked your script to pick the mouse based on the rom name, as I have some games I want to use the trackball. Also had an issue where the sed was giving two indexes, so I just made it pick the first one. My version of script is below.
I also added this in my batocera.conf to force the Wii Trigger and A button to be mapped to joystick A and B button. Without that, I could not get the A button to register in a few mame games.
mame.retroarch.input_player1_a_mbtn=1
mame.retroarch.input_player1_b_mbtn=2
The wiki should be updated with your technique or integrated directly into batocera. I also found “lightgun” mode in NES works well and can still use buttons.
#!/bin/bash
#name of games that use the trackball
trackball_roms[0]="centiped.zip"
trackball_roms[1]="milliped.zip"
trackball_roms[2]="gt99.zip"
trackball_roms[3]="gtclassc.zip"
trackball_roms[4]="gt2k.zip"
trackball_roms[5]="marble.zip"
trackball_roms[6]="missile.zip"
trackball_roms[7]="trackfld.zip"
trackball_roms[8]="combasct.zip"
trackball_roms[9]="capbowl.zip"
trackball_roms[10]="shufshot.zip"
trackball_roms[11]="wcbowl.zip"
trackball_roms[12]="irrmaze.zip"
# NAME OF DESIRED MOUSE INPUT
# Can be found via the RetroArch log file or by running 'evtest'
# default to gun
mouse_name_gun="HJZ Mayflash Wiimote PC Adapter Mouse"
mouse_name_trackball="HID 0838:8918"
mouse_name=$mouse_name_gun
GAMENAME=$(basename "$1") #get rid of the path, just want the game name only
# Loop over trackball games
for trackball_game in ${trackball_roms[@]}
do
echo $trackball_game
if [ "$trackball_game" = "$GAMENAME" ]; then
mouse_name=$mouse_name_trackball
fi
done
# 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
mouse_index=$(sed -En "s/.*Mouse #(.*): \"$mouse_name\".*/\1/p" /userdata/system/logs/retroarch/retroarch.log)
if [[ -z "$mouse_index" ]]; then
mouse_index=0
fi
# Just pick the first index
first_mouse=${mouse_index:0:1}
batocera-settings-set mame.retroarch.input_player1_mouse_index $first_mouse