-
Notifications
You must be signed in to change notification settings - Fork 2
/
toLily.c
40 lines (28 loc) · 823 Bytes
/
toLily.c
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <hidapi/hidapi.h>
int main(int argc, char* argv[]) {
int res;
unsigned char buf[33];
hid_device* handle;
hid_init();
struct hid_device_info *devs, *cur_dev;
devs = hid_enumerate(0x04d8, 0xeb2d);
cur_dev = devs;
while (cur_dev) {
if (cur_dev->interface_number == 1) handle = hid_open_path(cur_dev->path);
cur_dev = cur_dev->next;
}
hid_free_enumeration(devs);
buf[0] = 0;
buf[1] = atoi(argv[1]);
for (int i=0; i<21; i++) {
buf[i+2] = (i < strlen(argv[2])) ? argv[2][i] : ' ';
}
res = hid_write(handle, buf, 33);
printf("%d\n", res);
hid_close(handle);
hid_exit();
return 0;
}