Skip to content

Commit c935e80

Browse files
Merge pull request #737 from tonyg/framebuffer-improvements
Framebuffer input-handling improvements
2 parents 7f20941 + 087cc7d commit c935e80

File tree

4 files changed

+262
-64
lines changed

4 files changed

+262
-64
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Absolutely-positioned input devices and Multitouch
2+
3+
When using `/dev/input/event*` for keyboard/mouse support, ordinary mice (and old trackpads)
4+
are supported directly, via `REL_*` event types.
5+
6+
However, on laptops with trackpads that report `ABS_*` events, we emulate a relative mouse
7+
device, as well as doing some simple gesture recognition (e.g. tap-to-click, drag lock,
8+
multitouch finger tracking).
9+
10+
We use libevdev to get a cleaned-up stream of raw events, but libevdev doesn't try to infer
11+
higher-level gestures. In future we may choose to add libinput as a dependency, since it *does*
12+
do basic gesture recognition of the kind we're interested in. At the moment, though, we do not
13+
want the extra dependency; in addition, libinput operates in a very wayland/X-centric style,
14+
which isn't necessarily a good fit for us.
15+
16+
We maintain enough state to distinguish between simple absolute-positioned devices, "type A"
17+
multitouch devices, and "type B" multitouch devices. See
18+
<https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt> for specifics of
19+
"type A" vs "type B".
20+
21+
- Simple absolute-positioned ("simple") devices: never emit `SYN_MT_REPORT` events or `ABS_MT_SLOT` events.
22+
- Type A multitouch: emit `SYN_MT_REPORT`.
23+
- Type B multitouch: emit `ABS_MT_SLOT`.
24+
25+
`BTN_TOUCH` indicates some input is active. We use this as a signal to update our simulated
26+
mouse cursor position, but do not take it as a signal to emit click events, *except* that we do
27+
tap-to-click detection; see use of the `moved` flag in `sqUnixEvdevKeyMouse.c`.
28+
29+
Each `SYN_REPORT` commits the state of the simulated mouse cursor and sends events on to the
30+
image, resetting our state as appropriate:
31+
- for simple devices, no resetting is needed;
32+
- for type A devices, the finger count is reset to zero;
33+
- for type B devices, no resetting is needed.
34+
35+
To decide which coordinate pairs to attend to, we follow these rules:
36+
37+
- for simple devices, we just take `ABS_X`/`ABS_Y` events and do tap detection using
38+
`BTN_TOUCH`;
39+
40+
- for type A devices, we take `ABS_MT_POSITION_X`/`Y` for the *first* finger in each report;
41+
42+
- for type B devices, each time a new touch is detected, if zero touches are in progress, we
43+
mark this touch slot as the one to attend to; when it is released, we attend to no others
44+
until all active touches have ended.
45+
46+
In all cases, `BTN_TOOL_DOUBLETAP` etc are used to let multi-finger taps substitute for middle
47+
and right mouse button clicks.

0 commit comments

Comments
 (0)