Hi,
I’m trying to interact with an HID device with Windows API. I’m opening my device the following way:
handle = CreateFileA(path,
0,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,/*FILE_ATTRIBUTE_NORMAL,*/
0);
Then i’m trying to set a feature with the following code but it gives me an error:
unsigned char data[2] = { REPORTID_LED, value };
BOOL res = HidD_SetFeature(handle, (PVOID)data, 2);
if (!res)
{
int error = GetLastError(); // error: 1 - ERROR_INVALID_FUNCTION
}
My report descriptor is quite long as it describes a multitouch digitizer, so I will only past here the feature part:
0x09, 0x00, // USAGE (Undefined)
0xa1, 0x01, // COLLECTION (Application)
0x85, REPORTID_LED, // REPORT_ID (Feature)
0x09, 0x55, // USAGE(Maximum Count)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x07, // LOGICAL_MAXIMUM (7)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x08, // REPORT_SIZE (8)
0xb1, 0x02, // FEATURE (Data,Var,Abs)
0xc0, // END_COLLECTION
This works under linux. I have tested before going to windows. Why is it falling in Windows? How can I know more about the ERROR_INVALID_FUNCTION?
Any ideas?
Thanks in advance,
Regards,
Nuno Santos