From fcc95868aa5146a5edc1f5338dcea6b27a6c6c2b Mon Sep 17 00:00:00 2001 From: bulzipke Date: Sun, 23 Aug 2026 12:47:39 +0900 Subject: [PATCH] thor: add melonDS DS screen sizing option --- .../rocknix/sources/scripts/setsettings.sh | 50 ++++++++++++++++++- .../rocknix/sources/scripts/vertical-check | 34 +++++++++++-- .../config/common/es_features.cfg | 13 ++++- 3 files changed, 92 insertions(+), 5 deletions(-) diff --git a/projects/ROCKNIX/packages/rocknix/sources/scripts/setsettings.sh b/projects/ROCKNIX/packages/rocknix/sources/scripts/setsettings.sh index 135f949d6ba..c39bb061383 100755 --- a/projects/ROCKNIX/packages/rocknix/sources/scripts/setsettings.sh +++ b/projects/ROCKNIX/packages/rocknix/sources/scripts/setsettings.sh @@ -994,6 +994,18 @@ function set_dreamcastopts() { fi } +function set_melondsds_opt() { + local OPT_FILE="${1}" + local OPT_KEY="${2}" + local OPT_VALUE="${3}" + if grep -q "^${OPT_KEY} = " "${OPT_FILE}" + then + sed -i "/^${OPT_KEY} = /c\\${OPT_KEY} = \"${OPT_VALUE}\"" "${OPT_FILE}" + else + echo "${OPT_KEY} = \"${OPT_VALUE}\"" >>"${OPT_FILE}" + fi +} + function set_melondsdsopts() { log "Set up melonDS DS..." if [ "${CORE}" = "melondsds" ] @@ -1014,6 +1026,42 @@ melonds_touch_mode = "auto" EOF fi + local FIT_SCALE="" FIT_GAP="" FIT_WIDTH="" FIT_HEIGHT="" + case "${QUIRK_DEVICE}" in + "AYN Thor"|"AYN Thor Lite"|"Retroid Pocket Mini V2") + ### 1240x1080 bottom panel + FIT_SCALE="85" + FIT_GAP="15" + FIT_WIDTH="1440" + FIT_HEIGHT="2079" + ;; + "Retroid Pocket Mini") + ### 1240x930 bottom panel, the secondary screen nearly fills it + FIT_SCALE="85" + FIT_GAP="1" + FIT_WIDTH="1440" + FIT_HEIGHT="2004" + ;; + esac + + if [ -n "${FIT_SCALE}" ] + then + local SCREEN_SIZING="$(get_setting "screen_sizing" "${PLATFORM}" "${ROM}")" + if [ "${SCREEN_SIZING}" = "1" ] + then + set_melondsds_opt "${MELONDSDSDIR}/melonDS DS.opt" "melonds_secondary_screen_scale" "100" + set_melondsds_opt "${MELONDSDSDIR}/melonDS DS.opt" "melonds_screen_gap" "0" + else + set_melondsds_opt "${MELONDSDSDIR}/melonDS DS.opt" "melonds_secondary_screen_scale" "${FIT_SCALE}" + set_melondsds_opt "${MELONDSDSDIR}/melonDS DS.opt" "melonds_screen_gap" "${FIT_GAP}" + add_setting "none" "aspect_ratio_index" "23" + add_setting "none" "custom_viewport_height" "${FIT_HEIGHT}" + add_setting "none" "custom_viewport_width" "${FIT_WIDTH}" + add_setting "none" "video_viewport_bias_x" "0.500000" + add_setting "none" "video_viewport_bias_y" "-0.000000" + fi + fi + if [ "${PLATFORM}" = "ndsiware" ] then sed -i '/melonds_console_mode = /c\melonds_console_mode = "dsi"' "${MELONDSDSDIR}/melonDS DS.opt" @@ -1291,11 +1339,11 @@ set_n64opts & set_saturnopts & set_snesopts & set_dreamcastopts & -set_melondsdsopts & ### Sed operations are expensive, so they are staged and executed as ### a single process when all forks complete. wait +set_melondsdsopts flush_settings cleanup diff --git a/projects/ROCKNIX/packages/rocknix/sources/scripts/vertical-check b/projects/ROCKNIX/packages/rocknix/sources/scripts/vertical-check index a6913919f60..d8cd1ccfaa2 100644 --- a/projects/ROCKNIX/packages/rocknix/sources/scripts/vertical-check +++ b/projects/ROCKNIX/packages/rocknix/sources/scripts/vertical-check @@ -21,6 +21,7 @@ if [ -z "${CURRENT_CORE}" ] || [ -z "${ROM_PATH}" ]; then exit 0 fi +ROM=$(basename "${ROM_PATH}") ROM_NAME=$(basename "${ROM_PATH}" | sed 's/\.[^.]*$//') EXTERNAL_DISPLAY_CONNECTED=false if grep -q "^connected$" /sys/class/drm/card*-HDMI*/status 2>/dev/null || grep -q "^connected$" /sys/class/drm/card*-DP*/status 2>/dev/null; then @@ -48,16 +49,33 @@ case "${ROM_NAME}" in ;; esac +melondsds_fit_to_main_screen() { + [ "${CURRENT_CORE}" = "melondsds" ] || return 1 + [ "$(get_setting "screen_sizing" "${PLATFORM}" "${ROM}")" != "1" ] +} + if [ "${IS_VERTICAL}" = "true" ]; then if [ "${QUIRK_DEVICE}" = "AYN Thor" ]; then # Needs two separate swaymsg calls. Screen cannot move and have windows moved to it in the same line. swaymsg '[title="RetroArch.*"] output DSI-2 pos 0 0, output DSI-1 power on pos 340 1080' - swaymsg '[title="RetroArch.*"] floating enable, fullscreen disable, resize set 1240 2160, move to output DSI-2, move absolute position 340 0' + RA_WIDTH="1240" + RA_X="340" + if melondsds_fit_to_main_screen; then + RA_WIDTH="1440" + RA_X="240" + fi + swaymsg "[title=\"RetroArch.*\"] floating enable, fullscreen disable, resize set ${RA_WIDTH} 2160, move to output DSI-2, move absolute position ${RA_X} 0" swaymsg 'input "0:0:bottom_touchscreen" events enabled' elif [ "${QUIRK_DEVICE}" = "AYN Thor Lite" ]; then # Same notes from above apply here. swaymsg '[title="RetroArch.*"] output DSI-1 pos 0 0, output DSI-2 power on pos 340 1080' - swaymsg '[title="RetroArch.*"] floating enable, fullscreen disable, resize set 1240 2160, move to output DSI-1, move absolute position 340 0' + RA_WIDTH="1240" + RA_X="340" + if melondsds_fit_to_main_screen; then + RA_WIDTH="1440" + RA_X="240" + fi + swaymsg "[title=\"RetroArch.*\"] floating enable, fullscreen disable, resize set ${RA_WIDTH} 2160, move to output DSI-1, move absolute position ${RA_X} 0" swaymsg 'input "0:0:bottom_touchscreen" events enabled' elif [ "${QUIRK_DEVICE}" = "Anbernic RG DS" ]; then # Same notes from above apply here. @@ -88,9 +106,19 @@ if [ "${IS_VERTICAL}" = "true" ]; then ;; esac + RA_X="${DSI_X}" + case "${QUIRK_DEVICE}" in + "Retroid Pocket Mini" | "Retroid Pocket Mini V2") + if melondsds_fit_to_main_screen; then + RA_WIDTH="1440" + RA_X="240" + fi + ;; + esac + # Setup vertical stack using external DP-1 as the top screen. swaymsg "[title=\"RetroArch.*\"] output DP-1 pos 0 0, output DSI-1 pos ${DSI_X} 1080" - swaymsg "[title=\"RetroArch.*\"] floating enable, fullscreen disable, resize set ${RA_WIDTH} ${RA_HEIGHT}, move to output DP-1, move absolute position ${DSI_X} 0" + swaymsg "[title=\"RetroArch.*\"] floating enable, fullscreen disable, resize set ${RA_WIDTH} ${RA_HEIGHT}, move to output DP-1, move absolute position ${RA_X} 0" swaymsg input "0:0:generic_ft5x06_(a0)" map_to_output DSI-1 swaymsg input "0:0:generic_ft5x06_(a0)" events enabled diff --git a/projects/ROCKNIX/packages/ui/emulationstation/config/common/es_features.cfg b/projects/ROCKNIX/packages/ui/emulationstation/config/common/es_features.cfg index 0d85640ed27..8d4fc04ecf1 100644 --- a/projects/ROCKNIX/packages/ui/emulationstation/config/common/es_features.cfg +++ b/projects/ROCKNIX/packages/ui/emulationstation/config/common/es_features.cfg @@ -1639,7 +1639,18 @@ - + + + + + + + + + + + +