Add Portmaster controller layout

This commit is contained in:
brooksytech 2024-01-13 02:18:35 +00:00 committed by fewtarius
parent 01f46aebcf
commit 93b0d2db12
No known key found for this signature in database
GPG key ID: F4AE55305D1B8C1A
14 changed files with 76 additions and 37 deletions

View file

@ -2,7 +2,7 @@ SYSTEM_NAME="ports"
SYSTEM_FULLNAME="Ports"
SYSTEM_MANUFACTURER=" System"
SYSTEM_RELEASE="System"
SYSTEM_HARDWARE="System"
SYSTEM_HARDWARE="computer"
SYSTEM_PATH="/storage/roms/ports"
SYSTEM_EXTENSION=".sh"
SYSTEM_COMMAND="/usr/bin/runemu.sh %ROM% -P%SYSTEM% --core=%CORE% --emulator=%EMULATOR% --controllers=\"%CONTROLLERSCONFIG%\""

View file

@ -9,7 +9,7 @@ This document describes all available systems emulators and cores available for
|&#xf013; System|Media Player (mplayer)|System|`mplayer`|.mp4 .mkv .avi .mov .wmv .m3u .mpg .ytb .twi .sh .mp3 .aac .mka .dts .flac .ogg .m4a .ac3 .opus .wav .wv .eac33 .thd|**mplayer:** mplayer (default)<br>|
|&#xf013; System|Moonlight Game Streaming (moonlight)|System|`moonlight`|.sh||
|&#xf013; System|Music Player (music)|System|`playlists`|.m3u .sh|**gmu:** gmu (default)<br>|
|&#xf013; System|Ports (ports)|System|`ports`|.sh||
|&#xf013; System|Ports (ports)|System|`ports`|.sh|**portmaster:** portmaster (default)<br>|
|&#xf013; System|Screenshots (imageviewer)|System|`screenshots`|.jpg .jpeg .png .bmp .psd .tga .gif .hdr .pic .ppm .pgm .mkv .pdf .mp4 .avi||
|&#xf013; System|Tools (tools)|System|`modules`|.sh||
|Amstrad|Amstrad CPC (amstradcpc)|1984|`amstradcpc`|.dsk .cpr .sna .tap .cdt .kcr .voc .m3u .zip .7z|**retroarch:** crocods (default)<br>**retroarch:** cap32<br>|

View file

@ -9,7 +9,7 @@ This document describes all available systems emulators and cores available for
|&#xf013; System|Media Player (mplayer)|System|`mplayer`|.mp4 .mkv .avi .mov .wmv .m3u .mpg .ytb .twi .sh .mp3 .aac .mka .dts .flac .ogg .m4a .ac3 .opus .wav .wv .eac33 .thd|**mplayer:** mplayer (default)<br>|
|&#xf013; System|Moonlight Game Streaming (moonlight)|System|`moonlight`|.sh||
|&#xf013; System|Music Player (music)|System|`playlists`|.m3u .sh|**gmu:** gmu (default)<br>|
|&#xf013; System|Ports (ports)|System|`ports`|.sh||
|&#xf013; System|Ports (ports)|System|`ports`|.sh|**portmaster:** portmaster (default)<br>|
|&#xf013; System|Screenshots (imageviewer)|System|`screenshots`|.jpg .jpeg .png .bmp .psd .tga .gif .hdr .pic .ppm .pgm .mkv .pdf .mp4 .avi||
|&#xf013; System|Tools (tools)|System|`modules`|.sh||
|Amstrad|Amstrad CPC (amstradcpc)|1984|`amstradcpc`|.dsk .cpr .sna .tap .cdt .kcr .voc .m3u .zip .7z|**retroarch:** crocods (default)<br>**retroarch:** cap32<br>|

View file

@ -9,7 +9,7 @@ This document describes all available systems emulators and cores available for
|&#xf013; System|Media Player (mplayer)|System|`mplayer`|.mp4 .mkv .avi .mov .wmv .m3u .mpg .ytb .twi .sh .mp3 .aac .mka .dts .flac .ogg .m4a .ac3 .opus .wav .wv .eac33 .thd|**mplayer:** mplayer (default)<br>|
|&#xf013; System|Moonlight Game Streaming (moonlight)|System|`moonlight`|.sh||
|&#xf013; System|Music Player (music)|System|`playlists`|.m3u .sh|**gmu:** gmu (default)<br>|
|&#xf013; System|Ports (ports)|System|`ports`|.sh||
|&#xf013; System|Ports (ports)|System|`ports`|.sh|**portmaster:** portmaster (default)<br>|
|&#xf013; System|Screenshots (imageviewer)|System|`screenshots`|.jpg .jpeg .png .bmp .psd .tga .gif .hdr .pic .ppm .pgm .mkv .pdf .mp4 .avi||
|&#xf013; System|Tools (tools)|System|`modules`|.sh||
|Amstrad|Amstrad CPC (amstradcpc)|1984|`amstradcpc`|.dsk .cpr .sna .tap .cdt .kcr .voc .m3u .zip .7z|**retroarch:** crocods (default)<br>**retroarch:** cap32<br>|

View file

@ -9,7 +9,7 @@ This document describes all available systems emulators and cores available for
|&#xf013; System|Media Player (mplayer)|System|`mplayer`|.mp4 .mkv .avi .mov .wmv .m3u .mpg .ytb .twi .sh .mp3 .aac .mka .dts .flac .ogg .m4a .ac3 .opus .wav .wv .eac33 .thd|**mplayer:** mplayer (default)<br>|
|&#xf013; System|Moonlight Game Streaming (moonlight)|System|`moonlight`|.sh||
|&#xf013; System|Music Player (music)|System|`playlists`|.m3u .sh|**gmu:** gmu (default)<br>|
|&#xf013; System|Ports (ports)|System|`ports`|.sh||
|&#xf013; System|Ports (ports)|System|`ports`|.sh|**portmaster:** portmaster (default)<br>|
|&#xf013; System|Screenshots (imageviewer)|System|`screenshots`|.jpg .jpeg .png .bmp .psd .tga .gif .hdr .pic .ppm .pgm .mkv .pdf .mp4 .avi||
|&#xf013; System|Tools (tools)|System|`modules`|.sh||
|Amstrad|Amstrad CPC (amstradcpc)|1984|`amstradcpc`|.dsk .cpr .sna .tap .cdt .kcr .voc .m3u .zip .7z|**retroarch:** crocods (default)<br>**retroarch:** cap32<br>|

View file

@ -9,7 +9,7 @@ This document describes all available systems emulators and cores available for
|&#xf013; System|Media Player (mplayer)|System|`mplayer`|.mp4 .mkv .avi .mov .wmv .m3u .mpg .ytb .twi .sh .mp3 .aac .mka .dts .flac .ogg .m4a .ac3 .opus .wav .wv .eac33 .thd|**mplayer:** mplayer (default)<br>|
|&#xf013; System|Moonlight Game Streaming (moonlight)|System|`moonlight`|.sh||
|&#xf013; System|Music Player (music)|System|`playlists`|.m3u .sh|**gmu:** gmu (default)<br>|
|&#xf013; System|Ports (ports)|System|`ports`|.sh||
|&#xf013; System|Ports (ports)|System|`ports`|.sh|**portmaster:** portmaster (default)<br>|
|&#xf013; System|Screenshots (imageviewer)|System|`screenshots`|.jpg .jpeg .png .bmp .psd .tga .gif .hdr .pic .ppm .pgm .mkv .pdf .mp4 .avi||
|&#xf013; System|Tools (tools)|System|`modules`|.sh||
|Amstrad|Amstrad CPC (amstradcpc)|1984|`amstradcpc`|.dsk .cpr .sna .tap .cdt .kcr .voc .m3u .zip .7z|**retroarch:** crocods (default)<br>**retroarch:** cap32<br>|

View file

@ -9,7 +9,7 @@ This document describes all available systems emulators and cores available for
|&#xf013; System|Media Player (mplayer)|System|`mplayer`|.mp4 .mkv .avi .mov .wmv .m3u .mpg .ytb .twi .sh .mp3 .aac .mka .dts .flac .ogg .m4a .ac3 .opus .wav .wv .eac33 .thd|**mplayer:** mplayer (default)<br>|
|&#xf013; System|Moonlight Game Streaming (moonlight)|System|`moonlight`|.sh||
|&#xf013; System|Music Player (music)|System|`playlists`|.m3u .sh|**gmu:** gmu (default)<br>|
|&#xf013; System|Ports (ports)|System|`ports`|.sh||
|&#xf013; System|Ports (ports)|System|`ports`|.sh|**portmaster:** portmaster (default)<br>|
|&#xf013; System|Screenshots (imageviewer)|System|`screenshots`|.jpg .jpeg .png .bmp .psd .tga .gif .hdr .pic .ppm .pgm .mkv .pdf .mp4 .avi||
|&#xf013; System|Tools (tools)|System|`modules`|.sh||
|Amstrad|Amstrad CPC (amstradcpc)|1984|`amstradcpc`|.dsk .cpr .sna .tap .cdt .kcr .voc .m3u .zip .7z|**retroarch:** crocods (default)<br>**retroarch:** cap32<br>|

View file

@ -21,6 +21,7 @@ case "${QUIRK_DEVICE}" in
rm -rf /storage/roms/ports/*/lib*/libEGL*
rm -rf /storage/roms/ports/*/lib*/libGL*
for port in /storage/roms/ports/*.sh; do
if grep -q SDL_VIDEO_GL_DRIVER "$port"; then
sed -i '/^export SDL_VIDEO_GL_DRIVER/c\#export SDL_VIDEO_GL_DRIVER"' "$port"
sed -i '/^export SDL_VIDEO_EGL_DRIVER/c\#export SDL_VIDEO_EGL_DRIVER' "$port"
echo Fixing: "$port";

View file

@ -14,9 +14,12 @@ fi
cd /storage/.config/PortMaster
#Grab the latest control.txt
#Grab the latest control.txt & mapper.txt, then set correct permissions
cp /usr/config/PortMaster/control.txt control.txt
chmod +x /storage/.config/PortMaster/control.txt
cp /usr/config/PortMaster/mapper.txt mapper.txt
chmod +x /storage/.config/PortMaster/mapper.txt
#Use our gamecontrollerdb.txt
rm -r gamecontrollerdb.txt
@ -44,6 +47,7 @@ cp /storage/roms/ports/PortMaster/gptokeyb gptokeyb
#Copy over required files for ports
cp /storage/.config/PortMaster/control.txt /storage/roms/ports/PortMaster/control.txt
cp /storage/.config/PortMaster/mapper.txt /storage/roms/ports/PortMaster/mapper.txt
cp /storage/.config/PortMaster/gamecontrollerdb.txt /storage/roms/ports/PortMaster/gamecontrollerdb.txt
cp /usr/bin/oga_controls* /storage/roms/ports/PortMaster/

View file

@ -75,24 +75,18 @@ get_controls() {
param_device="${profile}"
# Extract GUID of current input
GUID=$(control-gen | awk 'BEGIN {FS="\""} /^DEVICE/ {print $2;exit}')
# Set file
export SDL_GAMECONTROLLERCONFIG_FILE="/tmp/gamecontrollerdb.txt"
# Spit the controller of the device our heuristics found (if it did).
if [[ ! -z ${GUID} ]]; then
grep "${SDLDBUSERFILE}" -e "${GUID}" > /tmp/gamecontrollerdb.txt
else
echo "" > /tmp/gamecontrollerdb.txt
fi
# Now find any controller mapped on emulationstation...
/storage/.config/PortMaster/mapper.txt ${SDL_GAMECONTROLLERCONFIG_FILE}
# Set compatability libs and run compatability script
export LD_LIBRARY_PATH=${clibs}
# Now find any controller mapped on emulationstation...
/storage/.config/PortMaster/mapper.txt SDL_GAMECONTROLLERCONFIG_FILE > /dev/null 2>&1
# Some ports want SDL_GAMECONTROLLERCONFIG, so let's fill it in
sdl_controllerconfig="$(< "${SDL_GAMECONTROLLERCONFIG_FILE}")"
}

View file

@ -1,5 +1,7 @@
#!/bin/bash
. /etc/profile
# -- Config & Setup --
# Destination file
if [[ -z "$1" ]]; then
@ -8,14 +10,36 @@ if [[ -z "$1" ]]; then
fi
CONTROLLER_DB="$1"
if [[ ! -f "${CONTROLLER_DB}" ]]; then
echo "File ${CONTROLLER_DB} does not exist."
exit -1
fi
#Scrub the CONTROLLER_DB file
rm ${CONTROLLER_DB}
touch ${CONTROLLER_DB}
# Where the emulationstation configuration file is
ES_CONFIG="${HOME}/.config/emulationstation/es_input.cfg"
#Set layout via Emulation Station
ACTIVE_GAME=""
GAME="${ACTIVE_GAME##*/}"
CONTROLLER_LAYOUT=$(get_setting port_controller_layout ports "${GAME}")
#Default to nintendo if no value assigned
if [ ! -n "${CONTROLLER_LAYOUT}" ]; then
CONTROLLER_LAYOUT="nintendo"
fi
if [[ "${CONTROLLER_LAYOUT}" == "xbox" ]]; then
ABUT="b"
BBUT="a"
XBUT="y"
YBUT="x"
else
ABUT="a"
BBUT="b"
XBUT="x"
DBUT="y"
fi
# -- Helper function --
# Map the actual button/hat/axis
function map {
@ -26,10 +50,10 @@ function map {
map_x_result=""
case "${INPUT_NAME}" in
"a") TR_NAME="a";;
"b") TR_NAME="b";;
"x") TR_NAME="x";;
"y") TR_NAME="y";;
"a") TR_NAME="${ABUT}";;
"b") TR_NAME="${BBUT}";;
"x") TR_NAME="${XBUT}";;
"y") TR_NAME="${YBUT}";;
"hotkeyenable") TR_NAME="guide";;
"up") TR_NAME="dpup";;
"down") TR_NAME="dpdown";;
@ -93,7 +117,7 @@ function get_map_prefix {
# query controllers mapped in emulationstation, ignore devices without a GUID
ES_QUERY="$(xmlstarlet sel -T -t -m "inputList/inputConfig[@deviceGUID!='']" -n -v "concat(@deviceName,';',@deviceGUID)" $ES_CONFIG)"
printf "\n# Custom Entries\n" >> "${CONTROLLER_DB}"
printf "### ${CONTROLLER_LAYOUT} layout\n" >> "${CONTROLLER_DB}"
echo "## ES Dev Mapper ##"
while IFS=";" read -r NAME GUID; do
@ -103,8 +127,6 @@ while IFS=";" read -r NAME GUID; do
continue
fi
# Check if GUID exists in gamecontrollerdb.txt
if [ -z "$(fgrep -- ${GUID} "${CONTROLLER_DB}")" ]; then
# Query this specific GUID on the mappings
MAPPING_CFG=$(xmlstarlet sel -T -t -m "//inputConfig[@deviceGUID = '${GUID}']/input" -n -v "concat(@name,';',@type,';',@id,';',@value)" $ES_CONFIG)
@ -112,24 +134,21 @@ while IFS=";" read -r NAME GUID; do
while IFS=";" read -r -e INPUT_NAME TYPE ID VALUE; do
# Map the controller
map "${INPUT_NAME}" "${TYPE}" "${ID}" "${VALUE}"
# Only concatenate valid mappings
if [[ ! -z ${map_x_result} ]]; then
MAPPING="${MAPPING}${map_x_result}"
fi
done <<< ${MAPPING_CFG:1}
get_map_prefix
get_map_suffix
if [[ ! -z "${MAPPING}" ]]; then
echo "${map_prefix}${MAPPING}${map_suffix}" >> "${CONTROLLER_DB}"
echo "${map_prefix}${MAPPING}${map_suffix}"
echo ""
else
echo "Failed to map anything."
echo ""
fi
else
echo "Already mapped..."
fi
done <<< ${ES_QUERY:1}
#Reset file for next run
sed -i '/^ACTIVE_GAME=/c\ACTIVE_GAME=""' /storage/.config/PortMaster/mapper.txt

View file

@ -280,7 +280,11 @@ case ${EMULATOR} in
"wii")
RUNTHIS='${RUN_SHELL} /usr/bin/start_dolphin_wii.sh "${ROMNAME}"'
;;
"shell"|"ports")
"ports")
RUNTHIS='${RUN_SHELL} "${ROMNAME}"'
sed -i "/^ACTIVE_GAME=/c\ACTIVE_GAME=\"${ROMNAME}\"" /storage/.config/PortMaster/mapper.txt
;;
"shell")
RUNTHIS='${RUN_SHELL} "${ROMNAME}"'
;;
*)

View file

@ -744,6 +744,18 @@
</core>
</cores>
</emulator>
<emulator name="portmaster">
<cores>
<core name="portmaster">
<features>
<feature name="port controller layout">
<choice name="xbox" value="xbox"/>
<choice name="nintendo" value="nintendo"/>
</feature>
</features>
</core>
</cores>
</emulator>
<emulator name="pico-8" features="pixel_perfect" />
<emulator name="retroarch" features="ratio, smooth, shaders, pixel_perfect, latency_reduction, game_translation">
<cores>

View file

@ -1194,6 +1194,11 @@ makeinstall_target() {
add_es_system x68000
### PC Ports
case ${TARGET_ARCH} in
arm|aarch64)
add_emu_core ports portmaster portmaster true
;;
esac
add_es_system ports
### Doom