Skip to content
This repository was archived by the owner on Feb 26, 2020. It is now read-only.

Commit 627f3aa

Browse files
swt2csignal11
authored andcommitted
windows: Set the OS report buffer size to 64 reports
Resolves issues with dropped input reports when receiving a large amount of data.
1 parent 6a4743e commit 627f3aa

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

windows/hid.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ extern "C" {
106106
typedef BOOLEAN (__stdcall *HidD_GetPreparsedData_)(HANDLE handle, PHIDP_PREPARSED_DATA *preparsed_data);
107107
typedef BOOLEAN (__stdcall *HidD_FreePreparsedData_)(PHIDP_PREPARSED_DATA preparsed_data);
108108
typedef NTSTATUS (__stdcall *HidP_GetCaps_)(PHIDP_PREPARSED_DATA preparsed_data, HIDP_CAPS *caps);
109+
typedef BOOLEAN (__stdcall *HidD_SetNumInputBuffers_)(HANDLE handle, ULONG number_buffers);
109110

110111
static HidD_GetAttributes_ HidD_GetAttributes;
111112
static HidD_GetSerialNumberString_ HidD_GetSerialNumberString;
@@ -117,6 +118,7 @@ extern "C" {
117118
static HidD_GetPreparsedData_ HidD_GetPreparsedData;
118119
static HidD_FreePreparsedData_ HidD_FreePreparsedData;
119120
static HidP_GetCaps_ HidP_GetCaps;
121+
static HidD_SetNumInputBuffers_ HidD_SetNumInputBuffers;
120122

121123
static HMODULE lib_handle = NULL;
122124
static BOOLEAN initialized = FALSE;
@@ -206,6 +208,7 @@ static int lookup_functions()
206208
RESOLVE(HidD_GetPreparsedData);
207209
RESOLVE(HidD_FreePreparsedData);
208210
RESOLVE(HidP_GetCaps);
211+
RESOLVE(HidD_SetNumInputBuffers);
209212
#undef RESOLVE
210213
}
211214
else
@@ -567,6 +570,13 @@ HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path)
567570
goto err;
568571
}
569572

573+
/* Set the Input Report buffer size to 64 reports. */
574+
res = HidD_SetNumInputBuffers(dev->device_handle, 64);
575+
if (!res) {
576+
register_error(dev, "HidD_SetNumInputBuffers");
577+
goto err;
578+
}
579+
570580
/* Get the Input Report length for the device. */
571581
res = HidD_GetPreparsedData(dev->device_handle, &pp_data);
572582
if (!res) {

0 commit comments

Comments
 (0)