Advertisement
Guest User

reicast.sh

a guest
Jan 4th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.40 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # This file is part of The RetroPie Project
  4. #
  5. # The RetroPie Project is the legal property of its developers, whose names are
  6. # too numerous to list here. Please refer to the COPYRIGHT.md file distributed with this source.
  7. #
  8. # See the LICENSE.md file at the top-level directory of this distribution and
  9. # at https://raw.githubusercontent.com/RetroPie/RetroPie-Setup/master/LICENSE.md
  10. #
  11.  
  12. AUDIO="$1"
  13. ROM="$2"
  14. rootdir="/opt/retropie"
  15. configdir="$rootdir/configs"
  16.  
  17. source "$rootdir/lib/inifuncs.sh"
  18.  
  19. function mapInput() {
  20.     local js_device
  21.     local js_device_num
  22.     local ev_device
  23.     local ev_devices
  24.     local ev_device_num
  25.     local device_counter
  26.     local conf="$configdir/dreamcast/emu.cfg"
  27.     local params=""
  28.  
  29.     # get a list of all present js device numbers and device names
  30.     # and device count
  31.     for js_device in /dev/input/js*; do
  32.         js_device_num=${js_device/\/dev\/input\/js/}
  33.         for ev_device in /dev/input/event*; do
  34.             ev_device_num=${ev_device/\/dev\/input\/event/}
  35.             if [[ -d "/sys/class/input/event${ev_device_num}/device/js${js_device_num}" ]]; then
  36.                 file[$ev_device_num]=$(grep --exclude=*.bak -rl "$configdir/dreamcast/mappings/" -e "= $(</sys/class/input/event${ev_device_num}/device/name)")
  37.                 if [[ -f "${file[$ev_device_num]}" ]]; then
  38.                     #file[$ev_device_num]="${file[$ev_device_num]##*/}"
  39.                     ev_devices[$ev_device_num]=$(</sys/class/input/event${ev_device_num}/device/name)
  40.                     device_counter=$(($device_counter+1))
  41.                 fi
  42.             fi
  43.         done
  44.     done
  45.  
  46.     # emu.cfg: store up to four event devices and mapping files
  47.     if [[ "$device_counter" -gt "0" ]]; then
  48.         # reicast supports max 4 event devices
  49.         if [[ "$device_counter" -gt "4" ]]; then
  50.             device_counter="4"
  51.         fi
  52.         local counter=0
  53.         for ev_device_num in "${!ev_devices[@]}"; do
  54.             if [[ "$counter" -lt "$device_counter" ]]; then
  55.                 counter=$(($counter+1))
  56.                 params+="-config input:evdev_device_id_$counter=$ev_device_num "
  57.                 params+="-config input:evdev_mapping_$counter=${file[$ev_device_num]} "
  58.             fi
  59.         done
  60.         while [[ "$counter" -lt "4" ]]; do
  61.             counter=$(($counter+1))
  62.             params+="-config input:evdev_device_id_$counter=-1 "
  63.             params+="-config input:evdev_mapping_$counter=-1 "
  64.         done
  65.     else
  66.         # fallback to keyboard setup
  67.         params+="-config input:evdev_device_id_1=0 "
  68.         device_counter=1
  69.     fi
  70.     params+="-config input:joystick_device_id=-1 "
  71.     params+="-config players:nb=$device_counter "
  72.     echo "$params"
  73. }
  74.  
  75. if [[ -f "$HOME/RetroPie/BIOS/dc_boot.bin" ]]; then
  76.     params="-config config:homedir=$HOME -config x11:fullscreen=1 "
  77.     getAutoConf reicast_input && params+=$(mapInput)
  78.     params+=" -config audio:backend=$AUDIO -config audio:disable=0 "
  79.     if [[ "$AUDIO" == "oss" ]]; then
  80.         aoss "$rootdir/emulators/reicast/bin/reicast" $params -config config:image="$ROM" >> /dev/null
  81.     else
  82.         "$rootdir/emulators/reicast/bin/reicast" $params -config config:image="$ROM" >> /dev/null
  83.     fi
  84. else
  85.     dialog --msgbox "You need to copy the Dreamcast BIOS files (dc_boot.bin and dc_flash.bin) to the folder $biosdir to boot the Dreamcast emulator." 22 76
  86. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement