Fail loudly on a touch read, stop the workers before their sockets close, and file down the small edges

This commit is contained in:
flamingcow
2026-08-04 22:26:07 -07:00
parent 12cef6a89b
commit 7b2601a02e
5 changed files with 38 additions and 20 deletions
+8 -3
View File
@@ -119,8 +119,11 @@ func watchTouch(w, h int) (*touchState, error) {
var down bool
for {
n, err := f.Read(buf)
// Nothing else feeds this state, so returning here would freeze the
// last touch in place and leave the reset button dead while the panel
// goes on looking alive.
if err != nil {
return
panic(fmt.Sprintf("reading touchscreen events: %v", err))
}
for o := 0; o+sizeofInputEvent <= n; o += sizeofInputEvent {
typ := *(*uint16)(unsafe.Pointer(&buf[o+16]))
@@ -142,9 +145,11 @@ func watchTouch(w, h int) (*touchState, error) {
if code != synReport {
break
}
// Scaled onto [0, w-1], so full deflection is the last pixel
// rather than one past it.
state.set(
int(int64(rawX-minX)*int64(w)/int64(maxX-minX)),
int(int64(rawY-minY)*int64(h)/int64(maxY-minY)),
int(int64(rawX-minX)*int64(w-1)/int64(maxX-minX)),
int(int64(rawY-minY)*int64(h-1)/int64(maxY-minY)),
down)
}
}