Listing 3. Sample EVIOCGID ioctl
/* suck out some device information */
if(ioctl(fd, EVIOCGID, &device_info)) {
perror("evdev ioctl");
}
/* the EVIOCGID ioctl() returns input_devinfo
* structure - see <linux/input.h>
* So we work through the various elements,
* displaying each of them
*/
printf("vendor %04hx product %04hx version %04hx",
device_info.vendor, device_info.product,
device_info.version);
switch ( device_info.bustype)
{
case BUS_PCI :
printf(" is on a PCI bus\n");
break;
case BUS_USB :
printf(" is on a Universal Serial Bus\n");
break;
...
Copyright © 1994 - 2019 Linux Journal. All rights reserved.