tools/interactive-evdev.c
static bool
is_keyboard(int fd)
{
    int i;
    unsigned long evbits[NLONGS(EV_CNT)] = { 0 };
    unsigned long keybits[NLONGS(KEY_CNT)] = { 0 };

    errno = 0;
    ioctl(fd, EVIOCGBIT(0, sizeof(evbits)), evbits);
    if (errno)
        return false;

    if (!evdev_bit_is_set(evbits, EV_KEY))
        return false;

    errno = 0;
    ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybits)), keybits);
    if (errno)
        return false;

    for (i = KEY_RESERVED; i <= KEY_MIN_INTERESTING; i++)
        if (evdev_bit_is_set(keybits, i))
            return true;

    return false;
}
/* Some heuristics to see if the device is a keyboard. */
Some heuristics to see if the device is a keyboard.
Some heuristics to see if the device is a keyboard .
static bool
is_keyboard(int fd)
{
    int i;
    unsigned long evbits[NLONGS(EV_CNT)] = { 0 };
    unsigned long keybits[NLONGS(KEY_CNT)] = { 0 };
    errno = 0;
    ioctl(fd, EVIOCGBIT(0, sizeof(evbits)), evbits);
    if (errno)
        return false;
    if (!evdev_bit_is_set(evbits, EV_KEY))
        return false;
    errno = 0;
    ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybits)), keybits);
    if (errno)
        return false;
    for (i = KEY_RESERVED; i <= KEY_MIN_INTERESTING; i++)
        if (evdev_bit_is_set(keybits, i))
            return true;
    return false;
}
static bool is_keyboard ( int fd ) { int i ; unsigned long evbits [ NLONGS ( EV_CNT ) ] = { 0 } ; unsigned long keybits [ NLONGS ( KEY_CNT ) ] = { 0 } ; errno = 0 ; ioctl ( fd , EVIOCGBIT ( 0 , sizeof ( evbits ) ) , evbits ) ; if ( errno ) return false ; if ( ! evdev_bit_is_set ( evbits , EV_KEY ) ) return false ; errno = 0 ; ioctl ( fd , EVIOCGBIT ( EV_KEY , sizeof ( keybits ) ) , keybits ) ; if ( errno ) return false ; for ( i = KEY_RESERVED ; i <= KEY_MIN_INTERESTING ; i ++ ) if ( evdev_bit_is_set ( keybits , i ) ) return true ; return false ; }
Some heuristics to see if the device is a keyboard.
Some heuristics to see if the device is a keyboard .