From 9ab29b33749ab92c25105bb888a0de1c2c02323b Mon Sep 17 00:00:00 2001 From: mike855 Date: Mon, 27 Jan 2025 10:20:46 +0100 Subject: [PATCH 1/2] feat(system): gpicase2: support docked mode on retroflag gpicase2 --- RELEASE-NOTES.md | 4 +++ .../case/installers/gpi2/assets/S15gpi2 | 36 +++++++++++++++++++ .../case/installers/gpi2/install.py | 1 + 3 files changed, 41 insertions(+) create mode 100644 projects/recalbox-hardware/case/installers/gpi2/assets/S15gpi2 diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index e57b9651cf..b20553ef98 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -22,6 +22,10 @@ as release notes for end user on a Recalbox upgrade. - Add NetPlay support for cores libretro-gpsp and libretro-dosbox-pure ### Improvements +- Add script for support of Retroflag GPI Case 2 (at boot only) + - unset in-case pad when HDMI is connected + - audio switching between in-case and HDMI + - Switch to recalbox-next theme when docked - Add gamelist decoration on the right side: regions flags, genre & players - Add sort by playing time & sort by regions - Remove overscan option in frontend diff --git a/projects/recalbox-hardware/case/installers/gpi2/assets/S15gpi2 b/projects/recalbox-hardware/case/installers/gpi2/assets/S15gpi2 new file mode 100644 index 0000000000..b21d7fb3e6 --- /dev/null +++ b/projects/recalbox-hardware/case/installers/gpi2/assets/S15gpi2 @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Retroflag Gpi Case 2 dock management +# Take care of +# * unset in-case pad when HDMI connected +# * audio switching between in-case and HDMI + +start() { + local theme + theme="$(recalbox_settings -command load -key emulationstation.theme.folder -default recalbox-goa2)" + + if grep -q -E '^connected' /sys/class/drm/card?-HDMI-A-*/status; then + # change ES theme + if [ "$theme" = "recalbox-goa2" ]; then + recalbox_settings -command save -key emulationstation.theme.folder -value recalbox-next + fi + + # unmap in-case pad in xpad + echo "1-1.3:1.0" > /sys/bus/usb/drivers/xpad/unbind + + # unset in-case audio output + recalbox_settings -command save -key audio.device -value 'alsa_card.platform-fef00700.hdmi:hdmi-output-0:output:hdmi-stereo' + + else + # keep LCD enable change ES theme + if [ "$theme" = "recalbox-next" ]; then + recalbox_settings -command save -key emulationstation.theme.folder -value recalbox-goa2 + fi + + # force in-case audio output + recalbox_settings -command save -key audio.device -value 'mono' + + fi +} + +start \ No newline at end of file diff --git a/projects/recalbox-hardware/case/installers/gpi2/install.py b/projects/recalbox-hardware/case/installers/gpi2/install.py index b059e28864..36629c6d73 100755 --- a/projects/recalbox-hardware/case/installers/gpi2/install.py +++ b/projects/recalbox-hardware/case/installers/gpi2/install.py @@ -95,6 +95,7 @@ class Install(InstallBase): self.BASE_SOURCE_FOLDER + 'assets/gpi2-retroarch.cfg': '/recalbox/share/.retroarch.cfg', self.BASE_SOURCE_FOLDER + 'assets/es_input.cfg': '/recalbox/share/system/.emulationstation/es_input.cfg', self.BASE_SOURCE_FOLDER + 'assets/gpi2.png': '/recalbox/system/resources/splash/logo-version.png', + self.BASE_SOURCE_FOLDER + 'assets/S15gpi2': '/etc/init.d/S15gpi2', } for source_file, dest_file in files.items(): installed_file = shutil.copy(source_file, dest_file) -- GitLab From 755c610fe14253dce1c5c886f359e606a3653d55 Mon Sep 17 00:00:00 2001 From: mike855 Date: Sun, 2 Feb 2025 00:44:42 +0100 Subject: [PATCH 2/2] feat(system): add ability of user theme and shader config by mode --- .../case/installers/gpi2/assets/S15gpi2 | 103 ++++++++++++++++-- 1 file changed, 91 insertions(+), 12 deletions(-) diff --git a/projects/recalbox-hardware/case/installers/gpi2/assets/S15gpi2 b/projects/recalbox-hardware/case/installers/gpi2/assets/S15gpi2 index b21d7fb3e6..413d5ef915 100644 --- a/projects/recalbox-hardware/case/installers/gpi2/assets/S15gpi2 +++ b/projects/recalbox-hardware/case/installers/gpi2/assets/S15gpi2 @@ -4,33 +4,112 @@ # Take care of # * unset in-case pad when HDMI connected # * audio switching between in-case and HDMI +# * Manage different custom configuration for docked/undocked modes (theme, audio, shaders) + +CONFIG_FILE="/recalbox/system/hardware/case/installers/gpi2/assets/gpi2settings.conf" + +mount -o remount,rw / +# Create configuration file if not exist (more robust in case of user deletion) + +if [ ! -f "$CONFIG_FILE" ]; then + cat > "$CONFIG_FILE" < /sys/bus/usb/drivers/xpad/unbind + echo "1-1.3:1.0" > /sys/bus/usb/drivers/xpad/unbind - # unset in-case audio output - recalbox_settings -command save -key audio.device -value 'alsa_card.platform-fef00700.hdmi:hdmi-output-0:output:hdmi-stereo' + # Set previous mode to HDMI for next restart + sed -i "s/^previousMode=.*/previousMode=\"hdmi\"/" "$CONFIG_FILE" else - # keep LCD enable change ES theme - if [ "$theme" = "recalbox-next" ]; then - recalbox_settings -command save -key emulationstation.theme.folder -value recalbox-goa2 - fi + # Load LCD settings + if [ "$previousMode" != "lcd" ]; then + + # Test to prevent overwriting default config in case of empty previous mode (first start) + if [ "$previousMode" = "hdmi" ]; then + # Save current setting as HDMI settings + saveHdmi + fi - # force in-case audio output - recalbox_settings -command save -key audio.device -value 'mono' + # Apply LCD Settings + recalbox_settings -command save -key emulationstation.theme.folder -value "$lcdTheme" + recalbox_settings -command save -key emulationstation.theme.carousel -value "$lcdThemeCarousel" + recalbox_settings -command save -key emulationstation.theme.transition -value "$lcdThemeTransition" + recalbox_settings -command save -key audio.device -value "$lcdAudio" + recalbox_settings -command save -key global.shaders -value "$lcdShaders" + recalbox_settings -command save -key global.shaderset -value "$lcdShaderSet" + else + # As LCD was already connected on previous boot, save the user settings in CONFIG_FILE + saveLcd + fi + # Set previous mode to LCD for next restart + sed -i "s/^previousMode=.*/previousMode=\"lcd\"/" "$CONFIG_FILE" fi } +# This fonction saves user LCD settings in CONFIG_FILE +saveLcd() { + sed -i "s/^lcdTheme=.*/lcdTheme=\"$(recalbox_settings -command load -key emulationstation.theme.folder)\"/" "$CONFIG_FILE" + sed -i "s/^lcdThemeCarousel=.*/lcdThemeCarousel=\"$(recalbox_settings -command load -key emulationstation.theme.carousel)\"/" "$CONFIG_FILE" + sed -i "s/^lcdThemeTransition=.*/lcdThemeTransition=\"$(recalbox_settings -command load -key emulationstation.theme.transition)\"/" "$CONFIG_FILE" + sed -i "s/^lcdAudio=.*/lcdAudio=\"$(recalbox_settings -command load -key audio.device)\"/" "$CONFIG_FILE" + sed -i "s#^lcdShaders=.*#lcdShaders=\"$(recalbox_settings -command load -key global.shaders)\"#" "$CONFIG_FILE" + sed -i "s/^lcdShaderSet=.*/lcdShaderSet=\"$(recalbox_settings -command load -key global.shaderset)\"/" "$CONFIG_FILE" +} + +# This fonction saves user LCD settings in CONFIG_FILE +saveHdmi() { + sed -i "s/^hdmiTheme=.*/hdmiTheme=\"$(recalbox_settings -command load -key emulationstation.theme.folder)\"/" "$CONFIG_FILE" + sed -i "s/^hdmiThemeCarousel=.*/hdmiThemeCarousel=\"$(recalbox_settings -command load -key emulationstation.theme.carousel)\"/" "$CONFIG_FILE" + sed -i "s/^hdmiThemeTransition=.*/hdmiThemeTransition=\"$(recalbox_settings -command load -key emulationstation.theme.transition)\"/" "$CONFIG_FILE" + sed -i "s/^hdmiAudio=.*/hdmiAudio=\"$(recalbox_settings -command load -key audio.device)\"/" "$CONFIG_FILE" + sed -i "s#^hdmiShaders=.*#hdmiShaders=\"$(recalbox_settings -command load -key global.shaders)\"#" "$CONFIG_FILE" + sed -i "s/^hdmiShaderSet=.*/hdmiShaderSet=\"$(recalbox_settings -command load -key global.shaderset)\"/" "$CONFIG_FILE" +} + start \ No newline at end of file -- GitLab