5 #ifndef HOST_LIB_SLABHIDDEVICE_INCLUDE_SLABHIDDEVICE_H_INCLUDED_MJWYLEYUPA 6 #define HOST_LIB_SLABHIDDEVICE_INCLUDE_SLABHIDDEVICE_H_INCLUDED_MJWYLEYUPA 48 #include "silabs_defs.h" 49 #include "silabs_sal.h" 63 #ifdef SLAB_HID_DEVICE_EXPORTS 64 #define SLAB_HID_DEVICE_API 65 #elif defined(SLAB_HID_DEVICE_BUILD_SOURCE) 66 #define SLAB_HID_DEVICE_API 68 #if defined(SILABS_STATIC_LINK) 69 #define SLAB_HID_DEVICE_API extern 70 #pragma comment (lib, "SLABHIDDevice.static.lib") 71 #else // defined(SILABS_STATIC_LINK) 72 #define SLAB_HID_DEVICE_API __declspec(dllimport) 73 #pragma comment (lib, "SLABHIDDevice.lib") 74 #endif // defined(SILABS_STATIC_LINK) 77 #define SLAB_HID_DEVICE_API 87 #define USE_LEGACY_SLAB_HID_DEVICE_STATUS 88 #if !defined(USE_LEGACY_SLAB_HID_DEVICE_STATUS) // TODO: Enstone: These defines are a exact duplicate values of HID_DEVICE_STATUS enums in HIDDevice.h. 89 typedef enum _SLAB_HID_DEVICE_STATUS {
103 #else // defined(NOT_YET) 107 #if !defined(HID_DEVICE_H) 108 #define HID_DEVICE_SUCCESS 0x00 109 #define HID_DEVICE_NOT_FOUND 0x01 110 #define HID_DEVICE_NOT_OPENED 0x02 111 #define HID_DEVICE_ALREADY_OPENED 0x03 112 #define HID_DEVICE_TRANSFER_TIMEOUT 0x04 113 #define HID_DEVICE_TRANSFER_FAILED 0x05 114 #define HID_DEVICE_CANNOT_GET_HID_INFO 0x06 115 #define HID_DEVICE_HANDLE_ERROR 0x07 116 #define HID_DEVICE_INVALID_BUFFER_SIZE 0x08 117 #define HID_DEVICE_SYSTEM_CODE 0x09 118 #define HID_DEVICE_INVALID_PARAMETER 0x0B 119 #define HID_DEVICE_UNKNOWN_ERROR SILABS_STATUS_UNKNOWN_ERROR 121 #define HID_DEVICE_UNSUPPORTED_FUNCTION 0x0A 122 #endif // defined(NOT_YET) 127 #define MAX_USB_DEVICES 64 131 #define MAX_REPORT_REQUEST_XP 512 132 #define MAX_REPORT_REQUEST_2K 200 134 #define DEFAULT_REPORT_INPUT_BUFFERS 0 137 #if !defined(HID_DEVICE_H) 139 #define HID_VID_STRING 0x01 140 #define HID_PID_STRING 0x02 141 #define HID_PATH_STRING 0x03 142 #define HID_SERIAL_STRING 0x04 143 #define HID_MANUFACTURER_STRING 0x05 144 #define HID_PRODUCT_STRING 0x06 146 #if !defined(MAX_STRING_LENGTH) 149 #define MAX_VID_LENGTH 5 150 #define MAX_PID_LENGTH 5 151 #define MAX_PATH_LENGTH 260 152 #define MAX_SERIAL_STRING_LENGTH 256 153 #define MAX_MANUFACTURER_STRING_LENGTH 256 154 #define MAX_PRODUCT_STRING_LENGTH 256 155 #define MAX_INDEXED_STRING_LENGTH 256 156 #define MAX_STRING_LENGTH 260 173 #endif // __cplusplus 249 HidDevice_GetHidString(_In_ _Pre_defensive_
const DWORD dwDeviceIndex, _In_ _Pre_defensive_
const WORD Vid, _In_ _Pre_defensive_
const WORD Pid, _In_ _Pre_defensive_
const BYTE WhichHidStringToReturn,
char* deviceString, _In_ _Pre_defensive_
const DWORD deviceStringLengthInBytes);
279 HidDevice_GetHidIndexedString(_In_ _Pre_defensive_
const DWORD dwDeviceIndex, _In_ _Pre_defensive_
const WORD Vid, _In_ _Pre_defensive_
const WORD Pid, _In_ _Pre_defensive_
const DWORD stringIndex,
char* deviceString, _In_ _Pre_defensive_
const DWORD deviceStringLengthInBytes);
307 HidDevice_GetHidAttributes(_In_ _Pre_defensive_
const DWORD dwDeviceIndex, _In_ _Pre_defensive_
const WORD Vid, _In_ _Pre_defensive_
const WORD Pid, _Out_writes_bytes_(2) _Pre_defensive_ WORD* pDeviceVid, _Out_writes_bytes_(2) _Pre_defensive_ WORD* pDevicePid, _Out_writes_bytes_(2) _Pre_defensive_ WORD* pDeviceReleaseNumber);
369 HidDevice_Open(_Out_
HID_DEVICE* device, _In_ _Pre_defensive_
const DWORD dwDeviceIndex, _In_ _Pre_defensive_
const WORD Vid, _In_ _Pre_defensive_
const WORD Pid, _In_ _Pre_defensive_
const DWORD numInputBuffers);
376 _Ret_range_(FALSE, TRUE)
434 HidDevice_GetString(_In_ _Pre_defensive_
const HID_DEVICE device, _In_ _Pre_defensive_
const BYTE WhichHidStringToReturn,
char* deviceString, _In_ _Pre_defensive_
const DWORD deviceStringLengthInBytes);
458 HidDevice_GetIndexedString(_In_ _Pre_defensive_
const HID_DEVICE device, _In_ _Pre_defensive_
const DWORD stringIndex,
char* deviceString, _In_ _Pre_defensive_
const DWORD deviceStringLengthInBytes);
482 HidDevice_GetAttributes(_In_ _Pre_defensive_
const HID_DEVICE device, _Out_writes_bytes_(2) _Pre_defensive_ WORD* pDeviceVid, _Out_writes_bytes_(2) _Pre_defensive_ WORD* pDevicePid, _Out_writes_bytes_(2) _Pre_defensive_ WORD* pDeviceReleaseNumber);
570 HidDevice_GetInputReport_Interrupt(_In_ _Pre_defensive_
const HID_DEVICE device, _Out_writes_bytes_(ReportBufferLengthInBytes) _Pre_defensive_
BYTE* ReportBuffer, _In_ _Pre_defensive_
const DWORD ReportBufferLengthInBytes, _In_ _Pre_defensive_
const DWORD numReports, _Out_writes_bytes_(
sizeof(DWORD)) _Pre_defensive_ DWORD* bytesReturned);
602 HidDevice_GetInputReport_Interrupt_WithTimeout(_In_ _Pre_defensive_
const HID_DEVICE device, _Out_writes_bytes_(ReportBufferLengthInBytes) _Pre_defensive_
BYTE* ReportBuffer, _In_ _Pre_defensive_
const DWORD ReportBufferLengthInBytes, _In_ _Pre_defensive_
const DWORD numReports, _Out_writes_bytes_(
sizeof(
BYTE)) _Pre_defensive_ DWORD* bytesReturned, _In_ _Pre_defensive_
const DWORD TimeoutMSec);
702 _Ret_range_(FALSE, TRUE)
716 _Ret_range_(FALSE, TRUE)
745 HidDevice_GetTimeouts(_In_ _Pre_defensive_
const HID_DEVICE device, _Out_writes_bytes_(4) _Pre_defensive_ DWORD* pGetReportTimeoutInMilliSeconds, _Out_writes_bytes_(4) _Pre_defensive_ DWORD* pSetReportTimeoutInMilliSeconds);
769 HidDevice_SetTimeouts(_In_ _Pre_defensive_
const HID_DEVICE device, _In_ _Pre_defensive_
const DWORD getReportTimeoutInMilliSeconds, _In_ _Pre_defensive_
const DWORD setReportTimeoutInMilliSeconds);
791 #endif // __cplusplus 795 #endif // HOST_LIB_SLABHIDDEVICE_INCLUDE_SLABHIDDEVICE_H_INCLUDED_MJWYLEYUPA #define HID_DEVICE_SYSTEM_CODE
Indicates that a system error occurred. Call Windows GetLastError() to retrieve the system error code...
Definition: SLABHIDDevice.h:117
SLAB_HID_DEVICE_STATUS HidDevice_SetFeatureReport_Control(const HID_DEVICE device, BYTE *ReportBuffer, const DWORD ReportBufferLengthInBytes)
This function sends an HID feature report from the host to the device over the control endpoint...
WORD HidDevice_GetFeatureReportBufferLength(const HID_DEVICE device)
Returns the maximum feature report size, including the report ID.
SLAB_HID_DEVICE_STATUS HidDevice_SetOutputReport_Interrupt(const HID_DEVICE device, BYTE *ReportBuffer, const DWORD ReportBufferLengthInBytes)
This function sends an HID output report from the host to the device over the interrupt endpoint...
SLAB_HID_DEVICE_STATUS HidDevice_GetInputReport_Control(const HID_DEVICE device, BYTE *ReportBuffer, const DWORD ReportBufferLengthInBytes)
Receives an HID input report from the device to the host over the control endpoint.
#define SLAB_HID_DEVICE_API
SLAB_HID_DEVICE_API definition.
Definition: SLABHIDDevice.h:77
BOOL HidDevice_FlushBuffers(const HID_DEVICE device)
Deletes all pending input reports in the HID driver queue and the HID library.
#define HID_DEVICE_UNSUPPORTED_FUNCTION
The function is only supported on certain (newer?) Windows versions.
Definition: SLABHIDDevice.h:121
SLAB_HID_DEVICE_STATUS HidDevice_Open(HID_DEVICE *device, const DWORD dwDeviceIndex, const WORD Vid, const WORD Pid, const DWORD numInputBuffers)
tbd
#define HID_DEVICE_NOT_OPENED
Indicates that the device must be opened prior to calling the function.
Definition: SLABHIDDevice.h:110
SLAB_HID_DEVICE_STATUS HidDevice_GetHidAttributes(const DWORD dwDeviceIndex, const WORD Vid, const WORD Pid, WORD *pDeviceVid, WORD *pDevicePid, WORD *pDeviceReleaseNumber)
Reads and returns the Vendor ID, Product ID and device Release Number.
DWORD HidDevice_GetNumHidDevices(const WORD Vid, const WORD Pid)
Determines the number of devices connected to the system with matching VID/PID.
void HidDevice_GetHidGuid(void *pHIDGuid)
Return the GUID for HIDClass devices ("return the HID GUID")
SLAB_HID_DEVICE_STATUS HidDevice_SetOutputReport_Control(const HID_DEVICE device, BYTE *ReportBuffer, const DWORD ReportBufferLengthInBytes)
Sends an HID output report from the host to the device over the control endpoint. ...
#define HID_DEVICE_ALREADY_OPENED
Indicates that the device is already opened and cannot be re-opened.
Definition: SLABHIDDevice.h:111
void HidDevice_GetTimeouts(const HID_DEVICE device, DWORD *pGetReportTimeoutInMilliSeconds, DWORD *pSetReportTimeoutInMilliSeconds)
Returns the input and output report timeouts over the interrupt endpoint.
#define WINAPI
WINAPI definition.
Definition: SLABHIDDevice.h:78
BOOL HidDevice_CancelIo(const HID_DEVICE device)
Cancels all pending input and output operations issued by the calling thread.
#define HID_DEVICE_TRANSFER_TIMEOUT
Indicates that a get or set report function returned due to a timeout. HidDevice_GetInputReport_Inter...
Definition: SLABHIDDevice.h:112
SLAB_HID_DEVICE_STATUS HidDevice_GetHidLibraryVersion(BYTE *pMajor, BYTE *pMinor, BOOL *pbIsReleaseBuild)
tbd
WORD HidDevice_GetOutputReportBufferLength(const HID_DEVICE device)
Returns the maximum output report size including the report ID.
SLAB_HID_DEVICE_STATUS HidDevice_GetAttributes(const HID_DEVICE device, WORD *pDeviceVid, WORD *pDevicePid, WORD *pDeviceReleaseNumber)
Reads and returns the Vendor ID, Product ID and device Release Number.
SLAB_HID_DEVICE_STATUS HidDevice_GetInputReport_Interrupt(const HID_DEVICE device, BYTE *ReportBuffer, const DWORD ReportBufferLengthInBytes, const DWORD numReports, DWORD *bytesReturned)
This function receives an HID input report from the host to the device over the interrupt endpoint...
SLAB_HID_DEVICE_STATUS HidDevice_GetIndexedString(const HID_DEVICE device, const DWORD stringIndex, char *deviceString, const DWORD deviceStringLengthInBytes)
Gets an indexed string from the device.
#define HID_DEVICE_NOT_FOUND
Indicates that the specified device index was invalid or the device does not exist or is inaccessible...
Definition: SLABHIDDevice.h:109
#define HID_DEVICE_UNKNOWN_ERROR
This is the default return code value. This value should never be returned.
Definition: SLABHIDDevice.h:119
SLAB_HID_DEVICE_STATUS HidDevice_GetString(const HID_DEVICE device, const BYTE WhichHidStringToReturn, char *deviceString, const DWORD deviceStringLengthInBytes)
Gets a "Product string".
unsigned char BYTE
Byte definition.
Definition: silabs_defs.h:41
an otherwise unclassified error occurred
Definition: silabs_defs.h:280
SLAB_HID_DEVICE_STATUS HidDevice_GetHidIndexedString(const DWORD dwDeviceIndex, const WORD Vid, const WORD Pid, const DWORD stringIndex, char *deviceString, const DWORD deviceStringLengthInBytes)
Gets an indexed string from the device.
#define HID_DEVICE_SUCCESS
SILABS_STATUS no error
Definition: SLABHIDDevice.h:108
WORD HidDevice_GetInputReportBufferLength(const HID_DEVICE device)
Returns the maximum input report size including the report ID.
BOOL HidDevice_IsOpened(const HID_DEVICE device)
This function returns the device opened state.
#define MAX_USB_DEVICES
Max number of USB Devices allowed.
Definition: SLABHIDDevice.h:127
BYTE SLAB_HID_DEVICE_STATUS
SLAB HID Device Status Codes.
Definition: SLABHIDDevice.h:106
#define HID_DEVICE_HANDLE_ERROR
HID CreateFile() handle is invalid.
Definition: SLABHIDDevice.h:115
void HidDevice_SetTimeouts(const HID_DEVICE device, const DWORD getReportTimeoutInMilliSeconds, const DWORD setReportTimeoutInMilliSeconds)
Sets the input and output report timeouts over the interrupt endpoint.
void * HID_DEVICE
an opaque handle object
Definition: SLABHIDDevice.h:164
#define HID_DEVICE_CANNOT_GET_HID_INFO
Cannot retrieve device path or hidStringType is invalid.
Definition: SLABHIDDevice.h:114
SLAB_HID_DEVICE_STATUS HidDevice_GetHidString(const DWORD dwDeviceIndex, const WORD Vid, const WORD Pid, const BYTE WhichHidStringToReturn, char *deviceString, const DWORD deviceStringLengthInBytes)
Gets a "Product string".
#define HID_DEVICE_INVALID_BUFFER_SIZE
Specified buffer is not large enough to return requested data.
Definition: SLABHIDDevice.h:116
#define HID_DEVICE_TRANSFER_FAILED
The host failed to communicate with the device or function parameters are incorrect.
Definition: SLABHIDDevice.h:113
SLAB_HID_DEVICE_STATUS HidDevice_Close(const HID_DEVICE device)
Closes an open handle to the device.
HANDLE HidDevice_GetHandle(const HID_DEVICE device)
This function returns the HID handle for the currently-opened device.
SLAB_HID_DEVICE_STATUS HidDevice_GetInputReport_Interrupt_WithTimeout(const HID_DEVICE device, BYTE *ReportBuffer, const DWORD ReportBufferLengthInBytes, const DWORD numReports, DWORD *bytesReturned, const DWORD TimeoutMSec)
This function receives an HID input report from the host to the device over the interrupt endpoint...
SLAB_HID_DEVICE_STATUS HidDevice_GetFeatureReport_Control(const HID_DEVICE device, BYTE *ReportBuffer, const DWORD ReportBufferLengthInBytes)
This function receives an HID feature report from the host to the device over the control endpoint...
DWORD HidDevice_GetMaxReportRequest(const HID_DEVICE device)
Returns the maximum number of input reports that can be queued in the HID driver. ...