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