Fail loudly on a touch read, stop the workers before their sockets close, and file down the small edges
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user