diff --git a/audiogame-manager.sh b/audiogame-manager.sh index b66a870..20155b3 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -281,11 +281,58 @@ create_game_array() { done } +# Update NVDA controller client DLLs in wine bottles +update_nvda_dlls() { + # Ensure we have the replacement DLLs + source .includes/functions.sh + download "https://github.com/RastislavKish/nvda2speechd/releases/download/v0.1/nvda2speechd32.dll" \ + "https://github.com/RastislavKish/nvda2speechd/releases/download/v0.1/nvda2speechd64.dll" + + # Update wine64 bottle (most common) + if [[ -d "$HOME/.local/wine64" ]]; then + find "$HOME/.local/wine64" -type f \( -iname "nvdaControllerClient*.dll" \) -print0 | while IFS= read -r -d '' dllFile; do + local basename="${dllFile##*/}" + local replacement="" + + case "${basename,,}" in + "nvdacontrollerclient32.dll") + replacement="${cache}/nvda2speechd32.dll" + ;; + "nvdacontrollerclient64.dll") + replacement="${cache}/nvda2speechd64.dll" + ;; + "nvdacontrollerclient.dll") + # Use file command to detect architecture + if file "$dllFile" | grep -q "PE32+"; then + replacement="${cache}/nvda2speechd64.dll" + elif file "$dllFile" | grep -q "PE32"; then + replacement="${cache}/nvda2speechd32.dll" + fi + ;; + esac + + if [[ -n "$replacement" ]] && [[ -f "$replacement" ]]; then + echo "Updating $dllFile with nvda2speechd" + cp "$replacement" "$dllFile" + fi + done + fi + + # Also update wine32 bottle if it exists + if [[ -d "$HOME/.local/wine32" ]]; then + find "$HOME/.local/wine32" -type f \( -iname "nvdaControllerClient*.dll" \) -print0 | while IFS= read -r -d '' dllFile; do + echo "Updating $dllFile with nvda2speechd32" + cp "${cache}/nvda2speechd32.dll" "$dllFile" + done + fi +} + # launch games that are installed game_launcher() { # For use by update scripts that want to source functions in this file. [[ "$agmNoLaunch" == "true" ]] && return source .includes/bottle.sh + # Start nvda2speechd if available if [[ -x ${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd ]]; then if command -v FEXLoader &> /dev/null ; then @@ -294,6 +341,9 @@ game_launcher() { ${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd &> /dev/null & fi fi + + # Replace NVDA controller client DLLs in wine64 bottle + update_nvda_dlls mapfile -t lines < <(sed -e '/^$/d' -e '/^ *#/d' "${configFile}" 2> /dev/null) if [[ ${#lines} -eq 0 ]]; then echo "Install some games first."