Added 'depth limit' option to pnd_disco searchpaths, so can search recursively foreve...
[pandora-libraries.git] / lib / pnd_io_ioctl.c
1
2 #include <linux/input.h>
3 #include <sys/ioctl.h>
4 #include <strings.h>
5 #include "pnd_io_ioctl.h"
6
7 int pnd_is_key_down ( int fd, int key ) {
8   unsigned int size = KEY_MAX / 8 + 1;
9   unsigned char buf [ size ];
10   bzero ( buf, size );
11
12   if ( ioctl ( fd, EVIOCGKEY(size), buf ) < 0 ) {
13     return ( -1 ); // error
14   }
15
16   if ( buf [ key / 8 ] & ( 1<<(key%8) ) ) {
17     return ( 1 ); // down
18   }
19
20   return ( 0 ); // not down
21 }