distribution/packages/emulators/standalone/cemu-sa/scripts/start_cemu.sh

107 lines
3.2 KiB
Bash
Raw Normal View History

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2022-present Frank Hartung (supervisedthinking (@) gmail.com)
# Copyright (C) 2022-present Fewtarius
# Source environment variables
. /etc/profile
# Ensure we're using pulseaudio
export SDL_AUDIODRIVER=pulseaudio
jslisten set "-9 cemu"
if [ -z "${PASINK}" ]
then
PASINK=$(pactl info | grep 'Default Sink:' | cut -d ' ' -f 3)
fi
# Set up mime db
mkdir -p /storage/.local/share/mime/packages
cp -rf /usr/share/mime/packages/* /storage/.local/share/mime/packages
update-mime-database /storage/.local/share/mime
# Set common paths
2023-01-10 12:12:46 +00:00
CEMU_CONFIG_ROOT="/storage/.config/Cemu"
CEMU_CACHE_LOG="${CEMU_CONFIG_ROOT}/share/log.txt"
CEMU_VAR_LOG="/var/log/Cemu.log"
CEMU_HOME_CONFIG="${CEMU_CONFIG_ROOT}/share"
CEMU_HOME_LOCAL="/storage/.local/share/Cemu"
# create link to config directory
if [ ! -d ${CEMU_HOME_CONFIG} ]; then
mkdir -p ${CEMU_HOME_CONFIG}
echo created ${CEMU_HOME_CONFIG}
fi
if [ -d ${CEMU_HOME_LOCAL} ] && [ ! -L ${CEMU_HOME_LOCAL} ]; then
cp -rf ${CEMU_HOME_LOCAL}/* ${CEMU_HOME_CONFIG}
rm -rf ${CEMU_HOME_LOCAL}
echo moved ${CEMU_HOME_LOCAL} to ${CEMU_HOME_CONFIG}
fi
if [ ! -L ${CEMU_HOME_LOCAL} ]; then
ln -sf ${CEMU_HOME_CONFIG} ${CEMU_HOME_LOCAL}
echo created symlink from ${CEMU_HOME_CONFIG} to ${CEMU_HOME_LOCAL}
fi
# Create symlink to logfile
if [ ! -L ${CEMU_VAR_LOG} ]; then
ln -sf ${CEMU_CACHE_LOG} ${CEMU_VAR_LOG}
fi
# Make sure CEMU settings exist, and set the audio output.
2023-01-10 12:12:46 +00:00
if [ ! -f "${CEMU_CONFIG_ROOT}/settings.xml" ]
then
2023-01-10 12:12:46 +00:00
cp -f /usr/config/Cemu/settings.xml ${CEMU_CONFIG_ROOT}/settings.xml
fi
# Make sure the basic controller profiles exist.
2023-01-10 12:57:27 +00:00
if [ ! -d "${CEMU_CONFIG_ROOT}/controllerProfiles" ]
then
mkdir -p ${CEMU_CONFIG_ROOT}/controllerProfiles
2023-01-10 12:57:27 +00:00
fi
2023-01-10 00:57:35 +00:00
FILE=$(echo $@ | sed "s#^/.*/##g")
FPS=$(get_setting show_fps wiiu "${FILE}")
CON=$(get_setting wiiu_controller_profile wiiu "${FILE}")
if [ -z "${FPS}" ]
then
FPS="0"
fi
2023-07-26 12:10:35 +00:00
case ${CON} in
"Wii U Pro Controller")
CONFILE="wii_u_pro_controller.xml"
CON="Wii U Pro Controller"
;;
*)
### Break these out when possible.
### "Wii U GamePad"|"Wii U Classic Controller"|"Wiimote"
CONFILE="wii_u_gamepad.xml"
CON="Wii U GamePad"
;;
esac
for CONTROLLER in /usr/config/Cemu/controllerProfiles/*
do
LOCALFILE="$(basename ${CONTROLLER})"
if [ "${CONFILE}" = "${LOCALFILE}" ]
then
cp "${CONTROLLER}" "${CEMU_CONFIG_ROOT}/controllerProfiles/controller0.xml"
fi
done
2023-01-10 00:57:35 +00:00
UUID0="0_$(control-gen | awk 'BEGIN {FS="\""} /^DEVICE/ {print $2;exit}')"
CONTROLLER0=$(cat /storage/.controller)
2023-01-10 12:12:46 +00:00
xmlstarlet ed --inplace -u "//Overlay/Position" -v "${FPS}" ${CEMU_CONFIG_ROOT}/settings.xml
xmlstarlet ed --inplace -u "//fullscreen" -v "true" ${CEMU_CONFIG_ROOT}/settings.xml
xmlstarlet ed --inplace -u "//Audio/TVDevice" -v "${PASINK}" ${CEMU_CONFIG_ROOT}/settings.xml
2023-01-10 12:12:46 +00:00
xmlstarlet ed --inplace -u "//emulated_controller/type" -v "${CON}" ${CEMU_CONFIG_ROOT}/controllerProfiles/controller0.xml
xmlstarlet ed --inplace -u "//emulated_controller/controller/uuid" -v "${UUID0}" ${CEMU_CONFIG_ROOT}/controllerProfiles/controller0.xml
xmlstarlet ed --inplace -u "//emulated_controller/controller/display_name" -v "${CONTROLLER0}" ${CEMU_CONFIG_ROOT}/controllerProfiles/controller0.xml
# Run the emulator
cemu -g "$@"