input_events.go RawHistoryFolder
1package ports
2
3import "time"
4
5// Mods carries input → core modifier flags.
6type Mods uint8
7
8const (
9 ModShift Mods = 1 << iota
10 ModCtrl
11 ModAlt
12 ModSuper
13)
14
15// InputEvent carries input → core notifications.
16type InputEvent interface{ inputEvent() }
17
18// KeyEvent carries input → core key transitions; Keysym is an xkb keysym name.
19// Keycode is the evdev code (xkb keycode - 8) and State the xkb modifier state
20// after this transition; wayland forwards both to clients unchanged. Time is
21// the device timestamp (CLOCK_MONOTONIC), like SwipeBegin.Time.
22type KeyEvent struct {
23 Keysym string
24 // Base is the key's unshifted keysym in the active layout, so Cmd+Shift+1
25 // still matches a cmd+shift+1 bind although it prints exclam.
26 Base string
27 Mods Mods
28 Pressed bool
29 Time time.Duration
30 Keycode uint32
31 State ModState
32}
33
34// ModState is the serialized xkb modifier state sent in wl_keyboard.modifiers.
35type ModState struct{ Depressed, Latched, Locked, Group uint32 }
36
37func (KeyEvent) inputEvent() {}
38
39// PointerMotion uses global layout coordinates in logical pixels (see OutputPlacement).
40// DX and DY are the accelerated logical deltas and UnaccelDX, UnaccelDY the
41// raw device deltas; all four are 0 for absolute devices. Time is the device
42// timestamp (CLOCK_MONOTONIC).
43type PointerMotion struct {
44 X, Y float64
45 DX, DY float64
46 UnaccelDX, UnaccelDY float64
47 Time time.Duration
48}
49
50func (PointerMotion) inputEvent() {}
51
52// PointerButton uses evdev button codes (BTN_LEFT is 0x110). Time is the
53// device timestamp (CLOCK_MONOTONIC).
54type PointerButton struct {
55 Button uint32
56 Pressed bool
57 Time time.Duration
58}
59
60func (PointerButton) inputEvent() {}
61
62// AxisSource tells how a scroll was made; values match wl_pointer.axis_source.
63type AxisSource uint8
64
65const (
66 AxisWheel AxisSource = iota
67 AxisFinger
68 AxisContinuous
69)
70
71// ScrollAxis is one scroll direction in a pointer frame. Value is in
72// surface pixels; V120 counts wheel detents in 1/120 steps (wheel only).
73// Stop ends a finger or continuous scroll on this axis.
74type ScrollAxis struct {
75 Set bool
76 Value float64
77 V120 int32
78 Stop bool
79}
80
81// PointerAxis is one scroll frame: Vertical, then Horizontal. Time is the
82// device timestamp (CLOCK_MONOTONIC).
83type PointerAxis struct {
84 Source AxisSource
85 Vertical, Horizontal ScrollAxis
86 Time time.Duration
87}
88
89func (PointerAxis) inputEvent() {}
90
91// SwipeBegin starts a three- or four-finger touchpad swipe. Time is the
92// device timestamp (CLOCK_MONOTONIC), shared by the updates and the end.
93type SwipeBegin struct {
94 Fingers int
95 Time time.Duration
96}
97
98// SwipeUpdate moves the fingers by the unaccelerated deltas DX, DY
99// (touchpad units, as libinput reports them, not natural-scroll inverted).
100type SwipeUpdate struct {
101 DX, DY float64
102 Time time.Duration
103}
104
105// SwipeEnd lifts the fingers. Cancelled is set when libinput cancelled
106// the swipe (another finger landed).
107type SwipeEnd struct {
108 Cancelled bool
109 Time time.Duration
110}
111
112func (SwipeBegin) inputEvent() {}
113func (SwipeUpdate) inputEvent() {}
114func (SwipeEnd) inputEvent() {}