| USB HID for Linux USB | ||
|---|---|---|
| <<< Previous | The HID device interface | Next >>> |
The hiddev interface supports determining the version of the hiddev code, using the HIDIOCGVERSION ioctl. The argument is an int, and it is meant to be interpreted as a major version (two high bytes), a minor version (third byte) and a patch level (low byte).
Lets look at an example of the HIDIOCVERSION ioctl call.
![]() | About example code |
|---|---|
This example, and several others in this document, are not complete, nor are they meant to show good programming style. Instead, they are meant to be illustrative of a particular feature. Real programs should, for example, check return values for all functions that can potentially fail. Complete examples (that will compile with gcc -Wall -W) are provided in the second part of this document. |
Example 1. HIDIOCVERSION example
/* ioctl() accesses the underlying driver */
ioctl(fd, HIDIOCGVERSION, &version);
/* the HIDIOCGVERSION ioctl() returns an int */
/* so we unpack it and display it */
printf("hiddev driver version is %d.%d.%d\n",
version >> 16, (version >> 8) & 0xff, version & 0xff); |
The example should be relatively obvious. The first argument is an open file descriptor for the hiddev device node (for example, /dev/usb/hiddev0). Also note that you have to pass a pointer to the integer variable, not the variable itself, as the third argument to the ioctl call.
| <<< Previous | Home | Next >>> |
| How HID devices relate to the hiddev interface | Up | Getting information about the HID device |