mirror of
https://github.com/stupidcomputer/jsfw.git
synced 2024-12-26 21:42:23 -06:00
38 lines
1.1 KiB
C
38 lines
1.1 KiB
C
// vi:ft=c
|
|
#ifndef HID_H_
|
|
#define HID_H_
|
|
#include "net.h"
|
|
|
|
#include <linux/input-event-codes.h>
|
|
#include <stdint.h>
|
|
|
|
// Unique identifier for devices (provided by linux), May be the mac address
|
|
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;
|
|
char *name;
|
|
DeviceMap mapping;
|
|
MessageDeviceInfo device_info;
|
|
} PhysicalDevice;
|
|
|
|
void *hid_thread();
|
|
void return_device(PhysicalDevice *dev);
|
|
PhysicalDevice get_device();
|
|
void apply_controller_state(PhysicalDevice *dev, MessageControllerState *state);
|
|
|
|
#endif
|