forked from gvalkov/golang-evdev
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ecodes.go.template
92 lines (81 loc) · 1.96 KB
/
ecodes.go.template
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
87
88
89
90
91
92
// -*- mode: go; -*-
// Integer constants defined in linux/input.h and linux/input-event-codes.h can be accessed
// directly as constants or through the provided reverse and forward mappings:
//
// evdev.KEY_A // 30
// evdev.ecodes["KEY_A"] // 30
// evdev.KEY[30] // "KEY_A"
// evdev.REL[0] // "REL_X"
// evdev.EV[evdev.EV_KEY] // "EV_KEY"
// evdev.ByEventType[EV_REL][0] // "REL_X"
//
// Generated on: ${UNAME}
package evdev
import "strings"
const (
${CODES}
)
var ecodes = map[string] int {
${CODEMAP}
}
var KEY = map[int]string {}
var ABS = map[int]string {}
var REL = map[int]string {}
var SW = map[int]string {}
var MSC = map[int]string {}
var LED = map[int]string {}
var BTN = map[int]string {}
var REP = map[int]string {}
var SND = map[int]string {}
var ID = map[int]string {}
var EV = map[int]string {}
var BUS = map[int]string {}
var SYN = map[int]string {}
var FF = map[int]string {}
var ByEventType = map[int] map[int]string {
EV_KEY: KEY,
EV_ABS: ABS,
EV_REL: REL,
EV_SW: SW,
EV_MSC: MSC,
EV_LED: LED,
EV_REP: REP,
EV_SND: SND,
EV_SYN: SYN,
EV_FF: FF,
}
func Ecode(value string) int {
return ecodes[value]
}
func init() {
for code, value := range ecodes {
switch {
case strings.HasPrefix(code, "KEY"):
KEY[value] = code
case strings.HasPrefix(code, "ABS"):
ABS[value] = code
case strings.HasPrefix(code, "REL"):
REL[value] = code
case strings.HasPrefix(code, "SW"):
SW[value] = code
case strings.HasPrefix(code, "MSC"):
MSC[value] = code
case strings.HasPrefix(code, "LED"):
LED[value] = code
case strings.HasPrefix(code, "BTN"):
BTN[value] = code
case strings.HasPrefix(code, "SND"):
SND[value] = code
case strings.HasPrefix(code, "ID"):
ID[value] = code
case strings.HasPrefix(code, "EV"):
EV[value] = code
case strings.HasPrefix(code, "BUS"):
BUS[value] = code
case strings.HasPrefix(code, "SYN"):
SYN[value] = code
case strings.HasPrefix(code, "FF"):
FF[value] = code
}
}
}