Created
July 4, 2010 04:40
-
-
Save errzey/463133 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned char | |
is_keyboard(const char *file) | |
{ | |
int fd; | |
uint8_t bitmask; | |
fd = open(file, O_RDONLY); | |
if (fd < 0) { | |
return(0); | |
} | |
if (ioctl(fd, EVIOCGBIT(0, EV_MAX), &bitmask) < 0) { | |
return(0); | |
} | |
/* make sure that the device supports EV_SYN and EV_KEY */ | |
if (!(bitmask & (1 << EV_SYN))) { | |
return(0); | |
} | |
if (!(bitmask & (1 << EV_KEY))) { | |
return(0); | |
} | |
/* make sure the device does not support EV_REL */ | |
if ((bitmask & (1 << EV_REL))) { | |
return(0); | |
} | |
/* make sure the device do not support EV_ABS */ | |
if ((bitmask & (1 << EV_ABS))) { | |
return(0); | |
} | |
return(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment