| USB HID for Linux USB | ||
|---|---|---|
| <<< Previous | The event interface | Next >>> |
The evdev interface supports determining the version of the hiddev code, using the EVIOCGVERSION 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 EVIOCGVERSION 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. EVIOCGVERSION example
ioctl(fd, EVIOCGVERSION, &version);
/* the EVIOCGVERSION ioctl() returns an int */
/* so we unpack it and display it */
printf("evdev 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/input/evdev0). 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.
The more observant readers would have noted the similarity between this ioctl and the HIDIOCGVERSION ioctl in the previous chapter. The format is the same, and the result is in the same form.
| <<< Previous | Home | Next >>> |
| The event interface | Up | Getting information about the HID device identity |