Extracting Button Usages That Are Set to ON

To extract the HID usages of buttons that are set to ON (1), applications and drivers call one of the following HID support routines:

HidP_GetButtons (or HidP_GetUsages)

Returns the usage ID of all buttons on a specified usage page that are set to ON.

HidP_GetButtonsEx (or HidP_GetUsagesEx)

Returns the usage page and usage ID of all buttons that are set to ON.

These routines return an array of all usage information for all buttons that are currently set to ON. Implicitly, buttons whose usage is not returned by these routines are set to OFF (zero).

To call these routines, applications and drivers must first allocate and zero-initialize the buffer used to return the array of button usages. An application or driver calls HidP_MaxUsageListLength to determine the number of button usages in a specified usage page in the report. If the application or driver specifies a usage page of zero, the routine returns the number of all the button usages in the report.

The required buffer size, in bytes, is the following:

  • (For HidP_GetButtons) The value returned by HidP_MaxUsageListLength times sizeof(USAGE)

  • (For HidP_GetButtonsEx) The value returned by HidP_MaxUsageListLength times sizeof(USAGE_AND_PAGE)

After an application or driver has used these routines to obtain information about which buttons are currently set to ON, it can determine the difference between the current state and the previous state of the buttons by calling one of the following HIDClass support routines. These routines return the difference between two arrays of usage information:

HidP_UsageListDifference

HidP_UsageAndPageListDifference

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft