Last change
on this file since 43 was
2,
checked in by Sam Hocevar, 17 years ago
|
- imported original 0.7.0 tarball
|
File size:
1.0 KB
|
Line | |
---|
1 | #include <fcntl.h> |
---|
2 | #include <sys/types.h> |
---|
3 | #include <sys/time.h> |
---|
4 | #include <stdlib.h> |
---|
5 | #include <stdio.h> |
---|
6 | #include <stdio.h> |
---|
7 | #include <unistd.h> |
---|
8 | #include <getopt.h> |
---|
9 | #include <signal.h> |
---|
10 | #include <termios.h> |
---|
11 | #include <linux/kd.h> |
---|
12 | #include <linux/vt.h> |
---|
13 | #include <linux/keyboard.h> |
---|
14 | #include <sys/ioctl.h> |
---|
15 | #include <sys/stat.h> |
---|
16 | |
---|
17 | |
---|
18 | int fd_ready_to_read(int fd) |
---|
19 | { |
---|
20 | struct timeval tv={0,0}; |
---|
21 | fd_set kbd_set; |
---|
22 | FD_ZERO(&kbd_set); |
---|
23 | FD_SET(fd,&kbd_set); |
---|
24 | select(FD_SETSIZE,&kbd_set,NULL,NULL,&tv); |
---|
25 | return (FD_ISSET(fd,&kbd_set)); |
---|
26 | } |
---|
27 | |
---|
28 | |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | int key_fifo() |
---|
33 | { |
---|
34 | int fd,child_pid; |
---|
35 | FILE *fp; |
---|
36 | fp=popen("keydrv","r"); |
---|
37 | fscanf(fp,"%d",&child_pid); |
---|
38 | pclose(fp); |
---|
39 | do |
---|
40 | { usleep(10000); |
---|
41 | } while (access("/tmp/jckey-driver",R_OK)); |
---|
42 | fd=open("/tmp/jckey-driver",O_RDONLY); |
---|
43 | return fd; |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | main() |
---|
48 | { |
---|
49 | unsigned char key; |
---|
50 | |
---|
51 | int console_fd=key_fifo(); |
---|
52 | while (1) |
---|
53 | { |
---|
54 | if (fd_ready_to_read(console_fd)) |
---|
55 | { |
---|
56 | read(console_fd,&key,1); |
---|
57 | printf("read key (%d)\n\r",(int)key); |
---|
58 | } else usleep(10000); |
---|
59 | } |
---|
60 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.