Process device input reports

The registered report callback (hid_report() in the demo driver) gets called when the device has new data for you to process. In other words, the report callback brings you live reports from the device. It carries out the following typical actions:

  1. Get the report instance's collection handle using hidd_report_collection. A HID collection is a meaningful grouping of HID controls and their respective HID usages. Report descriptors published by devices define one or more top-level collections, and the report items, associated with each collection, define one or more HID reports. Visit The Linux Kernel documentation for more on HID report descriptors.

  2. Get the collection's usage page (hidd_get_usage_page()), usage value (hidd_get_usage_value()), button values (hidd_get_buttons()). Refer to the handle_joystick() function in the demo for examples of how data is extracted from the reports and processed further.

You can then use a data handler to convert raw input values extracted from these reports into meaningful values. For example:

...
hidd_get_usage_value(report->instance, NULL, 1, HIDD_USAGE_X, report_data, &x);
hidd_get_usage_value(report->instance, NULL, 1, HIDD_USAGE_Y, report_data, &y);

// Process joystick data
if (x == 1) printf("Joystick moved left\n");
if (y == 1) printf("Joystick moved up\n");
...

If you'd like to use device inputs in your application, you can either send this data directly from this driver to your application, or you can modify this driver to setup a resource manager. That way, data handler functions can write device report data to the resource manager and any QNX application interested in this data can get it directly from the resource manager.

Page updated: