From 627f3aa478e8099e3660d6a429f1584eeca0724c Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Tue, 28 Jan 2014 23:35:06 -0500 Subject: [PATCH] windows: Set the OS report buffer size to 64 reports Resolves issues with dropped input reports when receiving a large amount of data. --- windows/hid.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/windows/hid.c b/windows/hid.c index 3dee05b..179f88e 100755 --- a/windows/hid.c +++ b/windows/hid.c @@ -106,6 +106,7 @@ extern "C" { typedef BOOLEAN (__stdcall *HidD_GetPreparsedData_)(HANDLE handle, PHIDP_PREPARSED_DATA *preparsed_data); typedef BOOLEAN (__stdcall *HidD_FreePreparsedData_)(PHIDP_PREPARSED_DATA preparsed_data); typedef NTSTATUS (__stdcall *HidP_GetCaps_)(PHIDP_PREPARSED_DATA preparsed_data, HIDP_CAPS *caps); + typedef BOOLEAN (__stdcall *HidD_SetNumInputBuffers_)(HANDLE handle, ULONG number_buffers); static HidD_GetAttributes_ HidD_GetAttributes; static HidD_GetSerialNumberString_ HidD_GetSerialNumberString; @@ -117,6 +118,7 @@ extern "C" { static HidD_GetPreparsedData_ HidD_GetPreparsedData; static HidD_FreePreparsedData_ HidD_FreePreparsedData; static HidP_GetCaps_ HidP_GetCaps; + static HidD_SetNumInputBuffers_ HidD_SetNumInputBuffers; static HMODULE lib_handle = NULL; static BOOLEAN initialized = FALSE; @@ -206,6 +208,7 @@ static int lookup_functions() RESOLVE(HidD_GetPreparsedData); RESOLVE(HidD_FreePreparsedData); RESOLVE(HidP_GetCaps); + RESOLVE(HidD_SetNumInputBuffers); #undef RESOLVE } else @@ -567,6 +570,13 @@ HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path) goto err; } + /* Set the Input Report buffer size to 64 reports. */ + res = HidD_SetNumInputBuffers(dev->device_handle, 64); + if (!res) { + register_error(dev, "HidD_SetNumInputBuffers"); + goto err; + } + /* Get the Input Report length for the device. */ res = HidD_GetPreparsedData(dev->device_handle, &pp_data); if (!res) {