Hi ! I haven written a small prog to handle a HID keyboard (standard mouse + keyboard + special keys/sliders) we are developping. Mouse and keyboard are managed by X, special keys are handled through hiddev by my small prog. This prog reads report from hiddev ( we have 3 In-Endpoints on our keyboard) using following code:
..... if( read( mFileDescriptor, buffer, USIF_REPORT_SIZE ) > 0 ) { readReport(); } ..... // PUBLIC METHODS -------------------- // Read the incoming report. Iterate through all field and all usage to find if a value has been changed // return true if no error occured else false bool MyDevice::readReport(void) { bool reportChanged = false; struct hiddev_usage_ref usageRef; struct hiddev_field_info fieldInfo; //cout << "Reading report!" << endl; // Fill in structure needed by Hiddev Ioctl cmd fieldInfo.report_type = HID_REPORT_TYPE_INPUT; fieldInfo.report_id = HID_REPORT_ID_FIRST; usageRef.report_type = HID_REPORT_TYPE_INPUT; usageRef.report_id = HID_REPORT_ID_FIRST; // Get number of usages for given Field fieldInfo.field_index = mUsbReportFieldId; if( ioctl( mFileDescriptor, HIDIOCGFIELDINFO, &fieldInfo ) < 0 ) perror(""); else { usageRef.field_index = mUsbReportFieldId; // Iterate through all usage and get values for ( unsigned int i = 0; i < min(fieldInfo.maxusage, mNumberOfUsbUsage); i++ ) { usageRef.usage_index = i; if( ioctl( mFileDescriptor, HIDIOCGUSAGE, &usageRef ) < 0 ) perror(""); else { // if new value then save it in the mControlsValueReport if( mpCurrentValue[i].value != usageRef.value ) { mpCurrentValue[i].value = usageRef.value; mpCurrentValue[i].haschanged = true; reportChanged = true; } } } } return reportChanged; } .... First remark: on 2.4.20 I had to take care of "fieldInfo.maxusage" field because it DOESN'T return the correct value our device is intended to return (on 2.4.18 kernel this value is OK) Does anyone knows why ??? For sending informations to our device (to light on/off leds), we are using control endpoint and "SendReport": ..... // Send commands to Usif through USB void MyDevice::SendReport() { .... if( ioctl(fd, HIDIOCINITREPORT, NULL)<0) perror("Init:"); rinfo.report_type = HID_REPORT_TYPE_OUTPUT; rinfo.report_id = HID_REPORT_ID_FIRST; ret = ioctl(fd, HIDIOCGREPORTINFO, &rinfo); if( ret < 0 ) perror("Rep:"); printf("led: %d \n",rinfo.num_fields); finfo.report_type = HID_REPORT_TYPE_OUTPUT; finfo.report_id = HID_REPORT_ID_FIRST; finfo.field_index = 0; if( ioctl(fd, HIDIOCGFIELDINFO, &finfo) < 0 ) perror("Field:"); printf("num fields %d, report id %d, max usage %d, value: %d \n\n", rinfo.num_fields, finfo.report_id,finfo.maxusage, uref.value); } ..... On 2.4.18, no problemo: num_fields is set to 1 (I have one output field in my device report) and HIDIOCFIELDINFO is working (doesn't return any error). On 2.4.20, num_fields is set to 0 (??) and so when I try to do a "HIDIOCFIELDINFO" perror signals me a "Field: Invalid Argument" error.... I'm lost.... Can somebody help me ?? What happened to hiddev / hidcore between 2.4.18 and 2.4.20 ?? Thanks ! (sorry for C/C++ code mix) Julien Boibessot ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel