Project Homepage | Sourceforge Page | CVS Repository | Freshmeat.net Page | Download project | Author's Homepage |
Definition in file kbhit.h.
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Functions | |
void | init_keyboard () |
initialize the keyboard | |
void | close_keyboard () |
reset the keyboard terminal settings | |
int | do_kbhit () |
do a kbhit |
|
reset the keyboard terminal settings
Definition at line 88 of file kbhit.c. Referenced by do_kbhit().
00089 {
00090 //reset terminal to initial settings
00091 tcsetattr(0, TCSANOW, &initial_settings);
00092 }
|
|
do a kbhit
Definition at line 40 of file kbhit.c. References close_keyboard(), and init_keyboard(). Referenced by main().
00041 { 00042 int ch = 0; 00043 00044 printf("PRESS ANY KEY TO CONTINUE"); 00045 fflush((FILE *)0); 00046 00047 //set keyboard state - no echo, single char input 00048 init_keyboard(); 00049 00050 //get charecter 00051 read(STDIN_FILENO, &ch, 1); /* getchar() works here too */ 00052 printf("%c",ch); 00053 00054 //set keyboard back to initial state 00055 close_keyboard(); 00056 00057 return(0); 00058 } |
Here is the call graph for this function:
|
initialize the keyboard
Definition at line 65 of file kbhit.c. References new_settings. Referenced by do_kbhit().
00066 { 00067 // struct termios new_settings; 00068 00069 //save attribures for close 00070 tcgetattr(0, &initial_settings); 00071 00072 //set no echo, one char input, 00073 new_settings = initial_settings; 00074 new_settings.c_lflag &= ~ICANON; 00075 new_settings.c_lflag &= ~ECHO; 00076 new_settings.c_lflag &= ~ISIG; 00077 new_settings.c_cc[VMIN] = 1; 00078 new_settings.c_cc[VTIME] = 0; 00079 00080 tcsetattr(0, TCSANOW, &new_settings); 00081 } |