forked from acidanthera/VoodooPS2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_focaltech.sh
More file actions
executable file
·241 lines (202 loc) · 9.56 KB
/
Copy pathbuild_focaltech.sh
File metadata and controls
executable file
·241 lines (202 loc) · 9.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#!/bin/bash
set -euo pipefail
FOCAL_VERSION="2.3.7"
VINPUT_VERSION="1.1.6"
BUNDLE_ID="com.stefanalmare.driver.VoodooPS2FocalTech"
CONFIGURATION="${BUILD_CONFIGURATION:-Release}"
ROOT="$(cd "$(dirname "$0")" && pwd)"
case "$CONFIGURATION" in
Release|Debug) ;;
*) echo "ERROR: BUILD_CONFIGURATION must be Release or Debug" >&2; exit 1 ;;
esac
if [[ -n "${BUILD_OUTPUT:-}" ]]; then
OUT="$BUILD_OUTPUT"
elif [[ "$CONFIGURATION" == "Release" ]]; then
OUT="$HOME/Desktop/VoodooPS2-FocalTech-Build"
else
OUT="$HOME/Desktop/VoodooPS2-FocalTech-Build-Debug"
fi
WORK="$(mktemp -d "${TMPDIR:-/tmp}/VoodooPS2-FocalTech.XXXXXX")"
SOURCE_COMMIT="$(git -C "$ROOT" rev-parse HEAD 2>/dev/null || echo unknown)"
say() { printf '\n========== %s ==========\n' "$1"; }
die() { echo "ERROR: $*" >&2; exit 1; }
cleanup() { rm -rf "$WORK"; }
trap cleanup EXIT
[[ "$(uname -s)" == "Darwin" ]] || die "build must run on macOS"
for c in git rsync curl xcodebuild xcode-select python3 plutil ditto strings; do
command -v "$c" >/dev/null 2>&1 || die "missing command: $c"
done
[[ "$(xcode-select -p 2>/dev/null || true)" != "/Library/Developer/CommandLineTools" ]] \
|| die "select full Xcode with: sudo xcode-select -s /Applications/Xcode.app/Contents/Developer"
say "Copy source to isolated build directory"
rsync -a --exclude '.git' --exclude 'build' --exclude 'DerivedData' "$ROOT/" "$WORK/repo/"
cd "$WORK/repo"
say "Apply FocalTech controller compatibility"
python3 Scripts/apply-controller-compat.py
say "Bootstrap MacKernelSDK"
rm -rf MacKernelSDK
git clone --depth=1 https://github.com/acidanthera/MacKernelSDK.git MacKernelSDK
say "Bootstrap pinned VoodooInput ${VINPUT_VERSION}"
rm -rf VoodooInput
mkdir -p VoodooInput/Debug VoodooInput/Release "$WORK/voodooinput"
for spec in "DEBUG:Debug" "RELEASE:Release"; do
conf="${spec%%:*}"
dest="${spec##*:}"
archive="$WORK/voodooinput/VoodooInput-${VINPUT_VERSION}-${conf}.zip"
extract="$WORK/voodooinput/${conf}"
curl -LfsS \
"https://github.com/acidanthera/VoodooInput/releases/download/${VINPUT_VERSION}/VoodooInput-${VINPUT_VERSION}-${conf}.zip" \
-o "$archive" \
|| die "failed to download VoodooInput ${VINPUT_VERSION} ${conf}"
rm -rf "$extract"
mkdir -p "$extract"
ditto -x -k "$archive" "$extract"
[[ -d "$extract/VoodooInput.kext" ]] \
|| die "VoodooInput ${VINPUT_VERSION} ${conf} archive has unexpected layout"
ditto "$extract/VoodooInput.kext" "VoodooInput/${dest}/VoodooInput.kext"
if [[ -d "$extract/VoodooInput.kext.dSYM" ]]; then
ditto "$extract/VoodooInput.kext.dSYM" "VoodooInput/${dest}/VoodooInput.kext.dSYM"
fi
done
[[ -f "VoodooInput/Debug/VoodooInput.kext/Contents/Resources/VoodooInputMultitouch/VoodooInputMessages.h" ]] \
|| die "VoodooInput ${VINPUT_VERSION} debug SDK headers missing"
BUILD="$WORK/build"
mkdir -p "$BUILD/controller" "$BUILD/focaltech"
say "Build patched VoodooPS2Controller (${CONFIGURATION})"
xcodebuild \
-project VoodooPS2Controller.xcodeproj \
-target VoodooPS2Controller \
-configuration "$CONFIGURATION" \
-jobs 1 \
CONFIGURATION_BUILD_DIR="$BUILD/controller"
CONTROLLER="$BUILD/controller/VoodooPS2Controller.kext"
KEYBOARD="$BUILD/controller/VoodooPS2Keyboard.kext"
[[ -d "$CONTROLLER" ]] || die "VoodooPS2Controller.kext was not produced"
[[ -d "$KEYBOARD" ]] || die "VoodooPS2Keyboard.kext was not produced"
say "Build standalone VoodooPS2FocalTech (${CONFIGURATION})"
cp FocalTech/VoodooPS2FocalTech.cpp VoodooPS2Trackpad/VoodooPS2Elan.cpp
cp FocalTech/VoodooPS2FocalTech.h VoodooPS2Trackpad/VoodooPS2FocalTech.h
rm -rf VoodooPS2Trackpad/Source
cp -R FocalTech/Source VoodooPS2Trackpad/Source
python3 - <<'PY'
from pathlib import Path
p = Path("VoodooPS2Trackpad/Source/VoodooPS2FocalTech.part00.inc")
s = p.read_text()
old = '#include "VoodooPS2FocalTech.h"'
new = '#include "../VoodooPS2FocalTech.h"'
if s.count(old) != 1:
raise SystemExit("ERROR: unexpected FocalTech header include layout")
p.write_text(s.replace(old, new, 1))
PY
xcodebuild \
-project VoodooPS2Controller.xcodeproj \
-target VoodooPS2Trackpad \
-configuration "$CONFIGURATION" \
-jobs 1 \
CONFIGURATION_BUILD_DIR="$BUILD/focaltech" \
PRODUCT_NAME=VoodooPS2FocalTech \
PRODUCT_BUNDLE_IDENTIFIER="$BUNDLE_ID" \
MODULE_NAME="$BUNDLE_ID" \
MODULE_VERSION="$FOCAL_VERSION" \
INFOPLIST_FILE="$WORK/repo/FocalTech/Info.plist" \
'EXCLUDED_SOURCE_FILE_NAMES=VoodooPS2ALPSGlidePoint.cpp VoodooPS2SentelicFSP.cpp VoodooPS2SMBusDevice.cpp VoodooPS2SynapticsTouchPad.cpp'
FOCAL="$BUILD/focaltech/VoodooPS2FocalTech.kext"
[[ -d "$FOCAL" ]] || die "VoodooPS2FocalTech.kext was not produced"
say "Assemble final ${CONFIGURATION} kext set"
rm -rf "$OUT"
mkdir -p "$OUT/Kexts"
ditto "$CONTROLLER" "$OUT/Kexts/VoodooPS2Controller.kext"
ditto "$FOCAL" "$OUT/Kexts/VoodooPS2FocalTech.kext"
PLUGINS="$OUT/Kexts/VoodooPS2Controller.kext/Contents/PlugIns"
mkdir -p "$PLUGINS"
rm -rf \
"$PLUGINS/VoodooPS2Mouse.kext" \
"$PLUGINS/VoodooPS2Trackpad.kext" \
"$PLUGINS/VoodooPS2Keyboard.kext" \
"$PLUGINS/VoodooInput.kext"
ditto "$KEYBOARD" "$PLUGINS/VoodooPS2Keyboard.kext"
ditto "$WORK/repo/VoodooInput/${CONFIGURATION}/VoodooInput.kext" "$PLUGINS/VoodooInput.kext"
[[ -d "$PLUGINS/VoodooPS2Keyboard.kext" ]] || die "keyboard plugin missing"
[[ -d "$PLUGINS/VoodooInput.kext" ]] || die "VoodooInput plugin missing"
plutil -lint "$OUT/Kexts/VoodooPS2Controller.kext/Contents/Info.plist"
plutil -lint "$PLUGINS/VoodooPS2Keyboard.kext/Contents/Info.plist"
plutil -lint "$OUT/Kexts/VoodooPS2FocalTech.kext/Contents/Info.plist"
plutil -lint "$PLUGINS/VoodooInput.kext/Contents/Info.plist"
strings "$OUT/Kexts/VoodooPS2Controller.kext/Contents/MacOS/VoodooPS2Controller" | grep -q foclegacy \
|| die "patched controller marker not present in final binary"
strings "$OUT/Kexts/VoodooPS2FocalTech.kext/Contents/MacOS/VoodooPS2FocalTech" | grep -q ApplePS2FocalTech \
|| die "FLT FocalTech class not present in final binary"
strings "$OUT/Kexts/VoodooPS2FocalTech.kext/Contents/MacOS/VoodooPS2FocalTech" | grep -q ApplePS2FTE0001 \
|| die "experimental FTE0001 class not present in final binary"
if [[ "$CONFIGURATION" == "Debug" ]]; then
mkdir -p "$OUT/Symbols"
for dsym in \
"$BUILD/controller/VoodooPS2Controller.kext.dSYM" \
"$BUILD/controller/VoodooPS2Keyboard.kext.dSYM" \
"$BUILD/focaltech/VoodooPS2FocalTech.kext.dSYM" \
"$WORK/repo/VoodooInput/Debug/VoodooInput.kext.dSYM"; do
[[ -d "$dsym" ]] && ditto "$dsym" "$OUT/Symbols/$(basename "$dsym")"
done
fi
cat > "$OUT/INSTALL.txt" <<EOF
VoodooPS2-FocalTech ${FOCAL_VERSION} - ${CONFIGURATION}
THIS IS A PRECOMPILED PACKAGE. Xcode is not required to install it.
OpenCore Kernel -> Add order:
1. VoodooPS2Controller.kext
2. VoodooPS2Controller.kext/Contents/PlugIns/VoodooPS2Keyboard.kext
3. VoodooPS2FocalTech.kext
4. VoodooPS2Controller.kext/Contents/PlugIns/VoodooInput.kext
FLT0101: do NOT use foclegacy=1 or focfte=1
FLT0102: add boot-arg foclegacy=1; do NOT use focfte=1
FLT0103: experimental; start without foclegacy=1 and without focfte=1
FTE0001: experimental separate protocol backend; add boot-arg focfte=1 only when testing FTE0001
Validated on macOS Sequoia and macOS Tahoe on tested FLT0101/FLT0102 hardware.
FTE0001 is implemented but is NOT yet hardware-validated in this fork.
HARDWARE SCOPE / LIMITATIONS:
This fork targets FocalTech PS/2 trackpads. It is not intended as a replacement
for the normal VoodooPS2 Synaptics, ELAN/Elantech, ALPS, Sentelic or generic
mouse/trackpad plugins. Other or unknown FocalTech PS/2 devices may be tried,
but are experimental until validated on physical hardware.
FTE0001 TESTING:
FTE0001 uses a different 8/16-byte FocalTech protocol family and a separate
ApplePS2FTE0001 backend. It is disabled unless focfte=1 is present and the
initial implementation refuses muxed multi-AUX controller layouts. Use a DEBUG
artifact/build and read Docs/FTE0001.md before treating it as supported hardware.
IMPORTANT FOR OC AUXILIARY TOOLS (OCAT) USERS:
OCAT may offer the stock Acidanthera VoodooPS2Controller as an update because
this fork's patched controller has a different size and hash/MD5 even when the
version number is the same. This is expected, not an error. Do not let OCAT
replace this FocalTech stack with stock VoodooPS2 unless you intentionally want
to remove FocalTech support. Update this stack from this repository's Releases.
${CONFIGURATION} PACKAGE:
EOF
if [[ "$CONFIGURATION" == "Release" ]]; then
cat >> "$OUT/INSTALL.txt" <<'EOF'
Recommended for normal use on hardware validated by the current stable release.
For experimental FTE0001 testing, prefer a current DEBUG artifact/build.
EOF
else
cat >> "$OUT/INSTALL.txt" <<'EOF'
For development, diagnostics and hardware bring-up. Use this configuration for
experimental FTE0001 testing and unvalidated hardware reports.
EOF
fi
cp "$WORK/repo/Docs/SUPPORTED-HARDWARE.md" "$OUT/SUPPORTED-HARDWARE.md"
cp "$WORK/repo/Docs/FTE0001.md" "$OUT/FTE0001.md"
printf '%s\n' "$SOURCE_COMMIT" > "$OUT/SOURCE-COMMIT.txt"
printf '%s\n' "$VINPUT_VERSION" > "$OUT/VOODOOINPUT-VERSION.txt"
printf '%s\n' "$CONFIGURATION" > "$OUT/BUILD-CONFIGURATION.txt"
rm -f "$OUT/VoodooPS2-FocalTech-Kexts.zip"
(
cd "$OUT/Kexts"
ditto -c -k --sequesterRsrc --keepParent . "$OUT/VoodooPS2-FocalTech-Kexts.zip"
)
say "Done"
echo "$OUT"
echo "Configuration: $CONFIGURATION"
echo "FocalTech version: $FOCAL_VERSION"
echo "VoodooInput pinned: $VINPUT_VERSION"
echo "FLT0101: no foclegacy=1, no focfte=1"
echo "FLT0102: foclegacy=1, no focfte=1"
echo "FLT0103: experimental"
echo "FTE0001: experimental, focfte=1"