joeylib2/installer/components/kpjoy.sh

44 lines
1.3 KiB
Bash

# shellcheck shell=bash
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
# See LICENSE.md for license information.
# SPDX-License-Identifier: MIT
#
# KPJOY.DRV, the joystick driver the win16 port's Windows runs with:
# Windows 3.1 has the joystick API (joyGetPos and the rest) but ships no
# driver for it, so without one no stick is ever seen. Built
# (installer/lib/winDriver.sh) from the kpjoy project, a checkout beside
# this repository (../kpjoy, or KPJOY_DIR), into
# toolchains/opt/kpjoy/kpjoy.drv; scripts/lib/win16Gate.sh installs it in
# each run's Windows as MMSYSTEM's joystick driver.
compDescription="win16: KPJOY.DRV joystick driver for its Windows, built from ../kpjoy (KPJOY_DIR)"
compGroups="emulator:win16"
compRequires="openWatcom"
compHostDeps="make"
# shellcheck source=installer/lib/winDriver.sh
source "$JOEY_INSTALLER/lib/winDriver.sh"
kpjoyDir="${KPJOY_DIR:-$(cd "$JOEY_REPO/.." && pwd)/kpjoy}"
compPin="dir:$kpjoyDir:$(winDriverPin "$kpjoyDir")"
compInstall() {
winDriverBuild "$kpjoyDir" Makefile kpjoy.drv
}
compInstalled() {
[ -s "$compDir/kpjoy.drv" ]
}
compVerify() {
# A Windows module whose name is KPJOY.
[ "$(head -c 2 "$compDir/kpjoy.drv")" = "MZ" ] && LC_ALL=C grep -q -a 'KPJOY' "$compDir/kpjoy.drv"
}
compEnv() {
envVar KPJOY_DRV "$compDir/kpjoy.drv"
}