forked from gvalkov/golang-evdev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_test.go
42 lines (34 loc) · 1.03 KB
/
example_test.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
package evdev
import (
"fmt"
)
func ExampleOpen() {
device, _ := Open("/dev/input/event3")
fmt.Println(device)
}
// Listing accessible input devices.
func ExampleListInputDevices() {
devices, _ := ListInputDevices()
for _, dev := range devices {
fmt.Printf("%s %s %s", dev.Fn, dev.Name, dev.Phys)
}
}
func Example() {
device, _ := Open("/dev/input/event3")
fmt.Println(device)
// InputDevice /dev/input/event3 (fd 3)
// name Logitech USB Laser Mouse
// phys usb-0000:00:12.0-2/input0
// bus 0x0003, vendor 0x046d, product 0xc069, version 0x110
// events EV_KEY 1, EV_SYN 0, EV_REL 2, EV_MSC 4
fmt.Println(device.Capabilities)
// map[ 4:[4 272 273 274 275 276 277 278 279]
// 0:[0 1 2 4]
// 2:[0 1 6 8 272 273 274 275 276 277 278 279]
// 1:[272 273 274 275 276 277 278 279] ]
// fmt.Println(device.ResolveCapabilities())
// // map[ 4:[4 272 273 274 275 276 277 278 279]
// // 0:[0 1 2 4]
// // 2:[0 1 6 8 272 273 274 275 276 277 278 279]
// // 1:[272 273 274 275 276 277 278 279] ]
}