-
Notifications
You must be signed in to change notification settings - Fork 0
/
hid.h
47 lines (40 loc) · 1.33 KB
/
hid.h
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
// vi:ft=c
#ifndef HID_H_
#define HID_H_
#include "net.h"
#include "server.h"
#include <linux/input-event-codes.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// Unique identifier for devices (provided by linux)
typedef uint64_t uniq_t;
// Mapping to go from index to id of events
// the id of an event is the code field of a input_event struct
// the index is given (somewhat arbitrarily) by hid.c::setup_device, this is done because ids are sparse
// and innefficient to transfer over network (especially for keys that can range from 0 to 700).
typedef struct {
uint16_t abs_indices[ABS_CNT];
uint16_t rel_indices[REL_CNT];
uint16_t key_indices[KEY_CNT];
} DeviceMap;
// A struct representing a connected device
typedef struct {
int event;
int hidraw;
uniq_t uniq;
uint64_t id;
char *name;
DeviceMap mapping;
DeviceInfo device_info;
} PhysicalDevice;
typedef struct {
PhysicalDevice dev;
ServerConfigController ctr;
} Controller;
void *hid_thread(void *arg);
void return_device(Controller *c);
void forget_device(Controller *c);
bool get_device(char **tags, size_t tag_count, bool *stop, Controller *res, uint8_t *index);
void apply_controller_state(Controller *c, DeviceControllerState *state);
#endif