51 lines
1.9 KiB
Bash
Executable file
51 lines
1.9 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
|
|
# See LICENSE.md for license information.
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
# verify-win32-input.sh - Typed-character acceptance gate for the Win32 port.
|
|
# Runs KEYS.EXE under Wine (scripts/lib/wineGate.sh) at one window pixel per
|
|
# stage pixel (JOEYLIB_SCALE=1, JOEYLIB_ASPECT=square), types the RetroNet
|
|
# definition-of-done string with xdotool (real X key events through XTEST,
|
|
# which Wine turns into WM_KEYDOWN/WM_CHAR), grabs the window, and decodes
|
|
# the example's verification scanline (row 198) with scripts/lib/keysRow.py.
|
|
#
|
|
# Usage: scripts/verify-win32-input.sh
|
|
# Requires: Wine (install.sh install emulator:win32), Xvfb, xdotool,
|
|
# ImageMagick, python3 + PIL; build/win32/bin/KEYS.EXE
|
|
# (make win32).
|
|
set -euo pipefail
|
|
|
|
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
source "$repo/scripts/lib/joeyEnv.sh"
|
|
source "$repo/scripts/lib/wineGate.sh"
|
|
label=verify-win32-input
|
|
wineNeed
|
|
|
|
target="192.168.1.10:6510"
|
|
program=$(joeyExampleProgram keys win32)
|
|
[ -f "$program" ] || { echo "$label: build KEYS.EXE first (make win32)" >&2; exit 2; }
|
|
|
|
work=$(mktemp -d -t "joeylib-win32-input.XXXXXX")
|
|
cleanup() {
|
|
wineStop
|
|
rm -rf "$work"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
wineStart "$work"
|
|
JOEYLIB_SCALE=1 JOEYLIB_ASPECT=square wineRun "$program"
|
|
win=$(wineWindow KEYS) || { echo "$label: FAIL - KEYS window not found" >&2; exit 1; }
|
|
sleep 2
|
|
xdotool windowfocus --sync "$win"
|
|
xdotool type --delay 150 -- "$target"
|
|
sleep 2
|
|
import -window "$win" "$work/keys.png"
|
|
# The window's client area at one pixel a pixel: the row must be exactly at
|
|
# (0,198) of the stage, wherever Wine put the client area in the grab.
|
|
if python3 "$repo/scripts/lib/keysRow.py" "$work/keys.png" "$target" --scale 1; then
|
|
echo "$label: PASS (typed \"$target\", all ${#target} chars arrived via jlInputGetChar)"
|
|
else
|
|
echo "$label: FAIL" >&2
|
|
exit 1
|
|
fi
|