2023-01-07 23:34:43 +00:00
|
|
|
#!/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
|
|
|
|
|
2023-08-10 09:12:19 +00:00
|
|
|
# Ensure we're using pulseaudio
|
|
|
|
export SDL_AUDIODRIVER=pulseaudio
|
2023-06-12 21:23:01 +00:00
|
|
|
jslisten set "-9 cemu"
|
2023-01-07 23:34:43 +00:00
|
|
|
|
2023-01-26 22:51:43 +00:00
|
|
|
if [ -z "${PASINK}" ]
|
|
|
|
then
|
|
|
|
PASINK=$(pactl info | grep 'Default Sink:' | cut -d ' ' -f 3)
|
|
|
|
fi
|
|
|
|
|
2023-01-07 23:34:43 +00:00
|
|
|
# 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"
|
2023-01-07 23:34:43 +00:00
|
|
|
|
|
|
|
# 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" ]
|
2023-01-07 23:34:43 +00:00
|
|
|
then
|
2023-01-10 12:12:46 +00:00
|
|
|
cp -f /usr/config/Cemu/settings.xml ${CEMU_CONFIG_ROOT}/settings.xml
|
2023-01-07 23:34:43 +00:00
|
|
|
fi
|
|
|
|
|
2023-01-08 11:19:57 +00:00
|
|
|
# Make sure the basic controller profiles exist.
|
2023-01-10 12:57:27 +00:00
|
|
|
if [ ! -d "${CEMU_CONFIG_ROOT}/controllerProfiles" ]
|
|
|
|
then
|
2023-01-26 11:49:26 +00:00
|
|
|
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
|
|
|
|
2023-01-25 01:40:36 +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
|
2023-01-26 22:51:43 +00:00
|
|
|
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
|
2023-01-25 01:40:36 +00:00
|
|
|
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
|
2023-01-07 23:34:43 +00:00
|
|
|
|
|
|
|
# Run the emulator
|
2023-01-08 12:28:42 +00:00
|
|
|
cemu -g "$@"
|