-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtest_keyboard.py
More file actions
63 lines (59 loc) · 1.29 KB
/
test_keyboard.py
File metadata and controls
63 lines (59 loc) · 1.29 KB
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
import foohid
import struct
import time
keyboard = (
0x05, 0x01,
0x09, 0x06,
0xa1, 0x01,
0x05, 0x07,
0x19, 0xe0,
0x29, 0xe7,
0x15, 0x00,
0x25, 0x01,
0x75, 0x01,
0x95, 0x08,
0x81, 0x02,
0x95, 0x01,
0x75, 0x08,
0x81, 0x01,
0x95, 0x05,
0x75, 0x01,
0x05, 0x08,
0x19, 0x01,
0x29, 0x05,
0x91, 0x02,
0x95, 0x01,
0x75, 0x03,
0x91, 0x01,
0x95, 0x06,
0x75, 0x08,
0x15, 0x00,
0x25, 0x65,
0x05, 0x07,
0x19, 0x00,
0x29, 0x65,
0x81, 0x00,
0x09, 0x00,
0x75, 0x08,
0x95, 0x01,
0x15, 0x00,
0x25, 0x7f,
0xb1, 0x02,
0xc0
)
try:
foohid.destroy("FooHID simple keyboard")
except:
pass
foohid.create("FooHID simple keyboard", struct.pack('{0}B'.format(len(keyboard)), *keyboard), "SN 123", 2, 3)
try:
while True:
# press "a" key
foohid.send("FooHID simple keyboard", struct.pack('8B', 0, 0, 4, 0, 0, 0, 0, 0))
time.sleep(0.1)
foohid.send("FooHID simple keyboard", struct.pack('8B', 0, 0, 0, 0, 0, 0, 0, 0))
time.sleep(0.5)
except KeyboardInterrupt:
# make sure key is unpressed before exiting
foohid.send("FooHID simple keyboard", struct.pack('8B', 0, 0, 0, 0, 0, 0, 0, 0))
foohid.destroy("FooHID simple keyboard")