-
Notifications
You must be signed in to change notification settings - Fork 6
/
k810.cpp
42 lines (30 loc) · 925 Bytes
/
k810.cpp
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
#include <stdio.h>
#include <wchar.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "hidapi.h"
#define MAX_STR 255
const unsigned char k810_seq_fkeys_on[] = { 0x0 ,0x10, 0xff, 0x06, 0x15, 0x00, 0x00, 0x00};
const unsigned char k810_seq_fkeys_off[] = { 0x0, 0x10, 0xff, 0x06, 0x15, 0x01, 0x00, 0x00};
#define HID_VENDOR_ID_LOGITECH 0x046d
#define HID_DEVICE_ID_K810 0xb319
int main(int argc, char* argv[]) {
const unsigned char *sequence;
hid_device *handle = NULL;
char *result;
int res;
sequence = k810_seq_fkeys_on;
result = "on";
if(argc == 2 && strcmp("off", argv[1]) == 0) {
sequence = k810_seq_fkeys_off;
result = "off";
}
res = hid_init();
do {
handle = hid_open(HID_VENDOR_ID_LOGITECH, HID_DEVICE_ID_K810, NULL);
res = hid_write(handle, sequence, 8);
hid_close(handle);
} while (res < 0);
printf("Fkeys %s\n", result);
}