-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtypes.go
86 lines (72 loc) · 1.9 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package evdev
import (
"fmt"
"syscall"
)
// EvType is EV_KEY, EV_SW, EV_LED, EV_SND, ...
type EvType uint16
// EvCode describes codes within a type (eg. KEY_A, KEY_B, ...)
type EvCode uint16
// EvProp describes device properties (eg. INPUT_PROP_ACCELEROMETER, INPUT_PROP_BUTTONPAD, ...)
type EvProp uint16
// StateMap describes the current state of codes within a type, as booleans.
type StateMap map[EvCode]bool
// InputEvent describes an event that is generated by an InputDevice
type InputEvent struct {
Time syscall.Timeval // time in seconds since epoch at which event occurred
Type EvType // event type - one of ecodes.EV_*
Code EvCode // event code related to the event type
Value int32 // event value related to the event type
}
func (e *InputEvent) TypeName() string {
return TypeName(e.Type)
}
func (e *InputEvent) CodeName() string {
return CodeName(e.Type, e.Code)
}
func (e *InputEvent) String() string {
return fmt.Sprintf(
"type: 0x%02x [%s], code: 0x%02x [%s], value: %d",
e.Type, e.TypeName(), e.Code, e.CodeName(), e.Value,
)
}
// InputID ...
type InputID struct {
BusType uint16
Vendor uint16
Product uint16
Version uint16
}
// AbsInfo describes details on ABS input types
type AbsInfo struct {
Value int32
Minimum int32
Maximum int32
Fuzz int32
Flat int32
Resolution int32
}
// InputKeymapEntry is used to retrieve and modify keymap data
type InputKeymapEntry struct {
Flags uint8
Len uint8
Index uint16
KeyCode uint32
ScanCode [32]uint8
}
// InputMask ...
type InputMask struct {
Type uint32
CodesSize uint32
CodesPtr uint64
}
// UinputUserDevice is used when creating or cloning a device
type UinputUserDevice struct {
Name [uinputMaxNameSize]byte
ID InputID
EffectsMax uint32
Absmax [absSize]int32
Absmin [absSize]int32
Absfuzz [absSize]int32
Absflat [absSize]int32
}