kellyjj
asked on
UNIX equiv of 'kbhit()' ??
I am working with SCO Unix using gcc for my compiler. I need to know the equiv of 'kbhit()'? thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hmmm... i'm afraid i don't; i've never needed curses myself, so don't know where you could get material from.
Just a few thoughts:
1. among the GNU stuff there is all to support C programming, so i guess they have man pages, too;
2. a net search for "man curses", or "man pages", or such, may also be of great help; there *is* stuff online (somewhere).
3. reject my answer, increase the points a bit (say 50), and wait for a better answer than mine; if nobody else comes in (not probable) you could anyway let me resubmit my answer, later.
Good luck.
Just a few thoughts:
1. among the GNU stuff there is all to support C programming, so i guess they have man pages, too;
2. a net search for "man curses", or "man pages", or such, may also be of great help; there *is* stuff online (somewhere).
3. reject my answer, increase the points a bit (say 50), and wait for a better answer than mine; if nobody else comes in (not probable) you could anyway let me resubmit my answer, later.
Good luck.
ASKER
Here you go. You at least told me that there is no equiv. And which lib deals with it. Thanks
Kellyjj - I don't know if you have solved this problem - but I have just had to deal with it.
The solution I came up with is this - use the curses.h lib and then use the function nodelay( stdwin, TRUE)
no you need to reset this at the end of your function and curse needs to be initialised first - If you want a good basic book on curses I suggest - "Programming with curses" by John Strang.
Alex
The solution I came up with is this - use the curses.h lib and then use the function nodelay( stdwin, TRUE)
no you need to reset this at the end of your function and curse needs to be initialised first - If you want a good basic book on curses I suggest - "Programming with curses" by John Strang.
Alex
Para lograrlo tienes que probar con las propiedades de la terminal...
Por default la terminal esta en modo caconico asi que la opcion es colocarla del otro modo !!!
Con esto lo lograras !!! y sin hacer uso de la libreria "ncurses.h" !!!
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <sys/time.h>
int main(){
struct termios tio0, tio1;
struct timeval tv;
fd_set rfds;
/* Modo de Edicion Canonica ki */
tcgetattr(0,&tio0);
memcpy(&tio1,&tio0,sizeof( struct termios));
tio1.c_lflag &= ~ICANON;
tcsetattr(0,TCSANOW,&tio1) ;
/* Es un kbhit() */
FD_ZERO(&rfds);
FD_SET(0,&rfds);
tv.tv_usec = 0;
tv.tv_sec = 1;
select(1,&rfds,NULL,NULL,& tv);
printf("%d\n",FD_ISSET(0,& rfds) ? 1:0);
/* Modo de edicion Canonica vissza */
tcsetattr(0,TCSANOW,&tio0) ;
return( 0 );
}
Recuerda Desactivar este modo y dejarlo como estaba antes!!!
BichiX...
Por default la terminal esta en modo caconico asi que la opcion es colocarla del otro modo !!!
Con esto lo lograras !!! y sin hacer uso de la libreria "ncurses.h" !!!
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <sys/time.h>
int main(){
struct termios tio0, tio1;
struct timeval tv;
fd_set rfds;
/* Modo de Edicion Canonica ki */
tcgetattr(0,&tio0);
memcpy(&tio1,&tio0,sizeof(
tio1.c_lflag &= ~ICANON;
tcsetattr(0,TCSANOW,&tio1)
/* Es un kbhit() */
FD_ZERO(&rfds);
FD_SET(0,&rfds);
tv.tv_usec = 0;
tv.tv_sec = 1;
select(1,&rfds,NULL,NULL,&
printf("%d\n",FD_ISSET(0,&
/* Modo de edicion Canonica vissza */
tcsetattr(0,TCSANOW,&tio0)
return( 0 );
}
Recuerda Desactivar este modo y dejarlo como estaba antes!!!
BichiX...
ASKER