Results 1 to 1 of 1
hi all:
i have read this post:
w w w.at91. c o m/samphpbb/viewtopic.php?f=12&t=3255&start=0&st=0&sk=t&sd=a
now my driver works fine, in the interrupt routine i report the key:
IN KERNEL:
input_report_key(keyboard, kbd_t.lastkey, ...
- 09-18-2009 #1Just Joined!
- Join Date
- Sep 2009
- Posts
- 1
how to detect my gpio keyboard?
hi all:
i have read this post:
w w w.at91. c o m/samphpbb/viewtopic.php?f=12&t=3255&start=0&st=0&sk=t&sd=a
now my driver works fine, in the interrupt routine i report the key:
IN KERNEL:
input_report_key(keyboard, kbd_t.lastkey, KEY_IS_DOWN);
input_report_key(keyboard, kbd_t.lastkey, KEY_IS_UP);
input_sync(keyboard);
when i printk it ,the value is correct (only support press one gpio at a time);
Now,i want to detect it in my application,i use these code:
i run this code,when i donot press the gpio,it seems to work OK,that's say:Code:int main(int argc, char **argv) { int keyboard; int ret,i; char c; fd_set readfd; struct timeval timeout; keyboard = open("/dev/event0",O_RDONLY | O_NONBLOCK); assert(keyboard>0); while(1) { timeout.tv_sec=2; timeout.tv_usec=0; FD_ZERO(&readfd); FD_SET(keyboard,&readfd); ret=select(keyboard+1,&readfd,NULL,NULL,&timeout);//NULL if(ret < 0) perror("select"); else if(ret == 0) printf("time out\n"); else { printf("ret=%d\n", ret); //always enter here!!! if(FD_ISSET(keyboard,&readfd)) { i=read(keyboard,&c,1); if('\n'==c) continue; printf("input is %c,%d\n",c,c); if ('q'==c) break; } } } close(keyboard); return 0; }
the terminal will print "time out" every 2 second.
HOWEVER,when i press the gpio (and release),it always runs to last "else":
ret=1
input is ,0
ret=1
input is ,0
ret=1
input is ,0
ret=1
input is ,0
and do not STOP again.Why these happen?
BY THE WAY,can i use the gpio button to emulate a tty keyboard? I mean i can use "getchar()" through my application :)
your quick reply is appreciated!


Reply With Quote