wut/include/nsyshid/hid.h

159 lines
3.6 KiB
C
Raw Normal View History

2018-06-17 19:33:48 +02:00
#pragma once
#include <wut.h>
/**
* \defgroup nsyshid_hid HID API
* \ingroup nsyshid
* @{
*/
2018-06-17 19:33:48 +02:00
#ifdef __cplusplus
extern "C" {
#endif
2018-06-18 11:04:39 +02:00
typedef struct HIDClient HIDClient;
typedef struct HIDDevice HIDDevice;
2018-06-17 19:33:48 +02:00
2018-06-18 11:04:39 +02:00
typedef enum HIDAttachEvent
2018-06-17 19:33:48 +02:00
{
2018-06-19 12:46:47 +02:00
HID_DEVICE_DETACH = 0,
HID_DEVICE_ATTACH = 1,
2018-06-18 11:04:39 +02:00
} HIDAttachEvent;
typedef int32_t
(*HIDAttachCallback)(HIDClient *client,
HIDDevice *device,
HIDAttachEvent attach);
typedef void
(*HIDCallback)(uint32_t handle,
int32_t error,
uint8_t *buffer,
uint32_t bytesTransferred,
void *userContext);
struct HIDDevice
{
uint32_t handle;
uint32_t physicalDeviceInst;
uint16_t vid;
uint16_t pid;
uint8_t interfaceIndex;
uint8_t subClass;
uint8_t protocol;
2018-06-20 11:31:53 +02:00
WUT_PADDING_BYTES(1);
2018-06-18 11:04:39 +02:00
uint16_t maxPacketSizeRx;
uint16_t maxPacketSizeTx;
};
2018-06-20 11:31:53 +02:00
WUT_CHECK_OFFSET(HIDDevice, 0x00, handle);
WUT_CHECK_OFFSET(HIDDevice, 0x04, physicalDeviceInst);
WUT_CHECK_OFFSET(HIDDevice, 0x08, vid);
WUT_CHECK_OFFSET(HIDDevice, 0x0A, pid);
WUT_CHECK_OFFSET(HIDDevice, 0x0C, interfaceIndex);
WUT_CHECK_OFFSET(HIDDevice, 0x0D, subClass);
WUT_CHECK_OFFSET(HIDDevice, 0x0E, protocol);
WUT_CHECK_OFFSET(HIDDevice, 0x10, maxPacketSizeRx);
WUT_CHECK_OFFSET(HIDDevice, 0x12, maxPacketSizeTx);
WUT_CHECK_SIZE(HIDDevice, 0x14);
2018-06-18 11:04:39 +02:00
struct HIDClient
{
HIDClient *next;
HIDAttachCallback attachCallback;
2018-06-17 19:33:48 +02:00
};
2018-06-20 11:31:53 +02:00
WUT_CHECK_OFFSET(HIDClient, 0x00, next);
WUT_CHECK_OFFSET(HIDClient, 0x04, attachCallback);
WUT_CHECK_SIZE(HIDClient, 0x08);
2018-06-17 19:33:48 +02:00
int32_t
2018-06-18 11:04:39 +02:00
HIDSetup();
2018-06-17 19:33:48 +02:00
int32_t
2018-06-18 11:04:39 +02:00
HIDTeardown();
2018-06-17 19:33:48 +02:00
int32_t
2018-06-18 11:04:39 +02:00
HIDAddClient(HIDClient *client,
HIDAttachCallback attachCallback);
2018-06-17 19:33:48 +02:00
int32_t
2018-06-18 11:04:39 +02:00
HIDDelClient(HIDClient *client);
2018-06-17 19:33:48 +02:00
int32_t
HIDGetDescriptor(uint32_t handle,
2018-06-18 11:04:39 +02:00
uint8_t descriptorType,
uint8_t descriptorIndex,
uint16_t languageId,
uint8_t *buffer,
uint32_t bufferLength,
HIDCallback callback,
void *userContext);
2018-06-17 19:33:48 +02:00
int32_t
HIDSetDescriptor(uint32_t handle,
2018-06-18 11:04:39 +02:00
uint8_t descriptorType,
uint8_t descriptorIndex,
uint16_t languageId,
uint8_t *buffer,
uint32_t bufferLength,
HIDCallback callback,
void *userContext);
2018-06-17 19:33:48 +02:00
int32_t
2018-06-18 11:04:39 +02:00
HIDGetReport(uint32_t handle,
uint8_t reportType,
uint8_t reportId,
uint8_t *buffer,
uint32_t bufferLength,
HIDCallback callback,
void *userContext);
2018-06-17 19:33:48 +02:00
int32_t
2018-06-18 11:04:39 +02:00
HIDSetReport(uint32_t handle,
uint8_t reportType,
uint8_t reportId,
uint8_t *buffer,
uint32_t bufferLength,
HIDCallback callback,
void *userContext);
2018-06-17 19:33:48 +02:00
int32_t
2018-06-18 11:04:39 +02:00
HIDSetIdle(uint32_t handle,
uint8_t interfaceIndex,
uint8_t duration,
HIDCallback callback,
void *userContext);
2018-06-17 19:33:48 +02:00
int32_t
HIDSetProtocol(uint32_t handle,
2018-06-18 11:04:39 +02:00
uint8_t interfaceIndex,
uint8_t protocol,
HIDCallback callback,
void *userContext);
2018-06-17 19:33:48 +02:00
int32_t
HIDGetProtocol(uint32_t handle,
2018-06-18 11:04:39 +02:00
uint8_t interfaceIndex,
uint8_t *protocol,
HIDCallback callback,
void *userContext);
2018-06-17 19:33:48 +02:00
int32_t
2018-06-18 11:04:39 +02:00
HIDRead(uint32_t handle,
uint8_t *buffer,
uint32_t bufferLength,
HIDCallback callback,
void *userContext);
2018-06-17 19:33:48 +02:00
int32_t
2018-06-18 11:04:39 +02:00
HIDWrite(uint32_t handle,
uint8_t *buffer,
uint32_t bufferLength,
HIDCallback hc,
void *userContext);
2018-06-17 19:33:48 +02:00
#ifdef __cplusplus
}
#endif
/** @} */