31.08.2013 Views

HID Sensor Usage Tables - USB.org

HID Sensor Usage Tables - USB.org

HID Sensor Usage Tables - USB.org

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

103 <strong>HID</strong> <strong>Sensor</strong> <strong>Usage</strong>s<br />

Because these structures are large (a PROPERTYKEY is 20 bytes, the GUID_OR_PROPERTYKEY struct<br />

is 30 bytes), this leaves only a modest amount of available space in the Report for the data value itself<br />

(leaves 43 bytes when using a PROPERTYKEY, and leaves 33 bytes when using a<br />

GUID_OR_PROPERTYKEY struct).<br />

In many cases, this may be acceptable. But this provides a practical limit of packing only a single Item in a<br />

Report. And some Items have a native size (narrow character strings, wide character strings, response<br />

curve structs, rotation matrix structs) that may no longer fit at all.<br />

To mitigate this, a strategy called the Generic Enumerator is introduced, whereby all the bulky<br />

“indentifying information” (specifically GUID_OR_PROPERTYKEY structs) are taken out of their<br />

“inline” positions and grouped together in their own dedicated <strong>HID</strong> top level collection.<br />

The <strong>HID</strong> Report Descriptor for this new top level collection is as follows:<br />

// Complete <strong>HID</strong> report descriptor<br />

const unsigned char enumerator_report_descriptor[] = {<br />

<strong>HID</strong>_USAGE_PAGE_SENSOR,<br />

<strong>HID</strong>_USAGE_SENSOR_TYPE_OTHER_GENERIC,<br />

<strong>HID</strong>_COLLECTION(Application),<br />

<strong>HID</strong>_REPORT_ID(1),<br />

};<br />

// Report ID 0x01: ENUMERATOR INPUT report<br />

// Data Field 1: Enumerator Table Row Index. Read-Only.<br />

// On a <strong>HID</strong> GET INPUT, auto-post-increments (use <strong>HID</strong> SET FEATURE to set the start row).<br />

<strong>HID</strong>_USAGE_SENSOR_DATA_ENUMERATOR_TABLE_ROW_INDEX,<br />

<strong>HID</strong>_LOGICAL_MIN_16(0x00, 0x00),<br />

<strong>HID</strong>_LOGICAL_MAX_16(0xff, 0xff),<br />

<strong>HID</strong>_REPORT_SIZE(16),<br />

<strong>HID</strong>_REPORT_COUNT(1),<br />

<strong>HID</strong>_INPUT(Const_Var_Abs),<br />

// Data Field 2: Enumerator Table Row Data. Read-Only.<br />

// Contents defined by GUID_OR_PROPERTYKEY struct (which is 30 bytes long).<br />

<strong>HID</strong>_USAGE_SENSOR_DATA_GENERIC_GUID_OR_PROPERTYKEY,<br />

<strong>HID</strong>_LOGICAL_MIN_8(0x00),<br />

<strong>HID</strong>_LOGICAL_MAX_8(0xff),<br />

<strong>HID</strong>_REPORT_SIZE(8),<br />

<strong>HID</strong>_REPORT_COUNT(30),<br />

<strong>HID</strong>_INPUT(Const_Arr_Abs),<br />

// Report ID 0x01: ENUMERATOR FEATURE report<br />

// Property 1: Enumerator Table Row Index. Read/Write.<br />

// On a <strong>HID</strong> SET FEATURE, used to set the start row.<br />

<strong>HID</strong>_USAGE_SENSOR_PROPERTY_ENUMERATOR_TABLE_ROW_INDEX,<br />

<strong>HID</strong>_LOGICAL_MIN_16(0x00, 0x00),<br />

<strong>HID</strong>_LOGICAL_MAX_16(0xff, 0xff),<br />

<strong>HID</strong>_REPORT_SIZE(16),<br />

<strong>HID</strong>_REPORT_COUNT(1),<br />

<strong>HID</strong>_FEATURE(Data_Var_Abs),<br />

// Property 2: Enumerator Table Row Count. Read-Only.<br />

// On a <strong>HID</strong> GET FEATURE, used to get the total count of Table Rows.<br />

<strong>HID</strong>_USAGE_SENSOR_PROPERTY_ENUMERATOR_TABLE_ROW_COUNT,<br />

<strong>HID</strong>_LOGICAL_MIN_16(0x00, 0x00),<br />

<strong>HID</strong>_LOGICAL_MAX_16(0xff, 0xff),<br />

<strong>HID</strong>_REPORT_SIZE(16),<br />

<strong>HID</strong>_REPORT_COUNT(1),<br />

<strong>HID</strong>_FEATURE(Const_Var_Abs),<br />

<strong>HID</strong>_END_COLLECTION<br />

The Generic Enumerator must be the first top level collection. The Report ID for the Input Report and<br />

Feature Report must be 0x01.<br />

The platform driver uses these pre-defined values to “bootstrap” itself by:<br />

Performing a <strong>HID</strong> Get Feature request to read the<br />

<strong>HID</strong>_USAGE_SENSOR_PROPERTY_ENUMERATOR_TABLE_ROW_COUNT;<br />

Performing a <strong>HID</strong> Set Feature request to reset the<br />

<strong>HID</strong>_USAGE_SENSOR_PROPERTY_ENUMERATOR_TABLE_ROW_INDEX to zero.<br />

Performing a loop for<br />

<strong>HID</strong>_USAGE_SENSOR_PROPERTY_ENUMERATOR_TABLE_ROW_COUNT times of:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!