This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: kbhit()


From: "Gad Hayisraeli" <gad@syete.co.il>
> i tried several kbhit() fucntions for linux:
> 1. the one that uses "select" and FDSET , etc.
> 2. speciall library - libkb (include <kb.h> and use the libkb.so lib)
> 
> in all methods of kbhit, i always got infinite printing on SINGLE key press,
> while i wanted simply to print one line per keypress. here's my code:
> 
> int main()
> {
> while(1)
> {
>      if (kbhit()) //in the lib function i changed to kb_kbhit()
>          printf("key pressed...\n");
> }
> }
> 
> GAD.
> 

I can't speak to the libkb method but with select() you'll be testing whether
the stream is _readable_. Which means that unless you do something to make it
unreadable, like issuing read() to get the character off the keyboard, it will
remain readable and you'll loop forever.


Enno.



------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]