#include <ctype.h>
#include <console.h>
#include <gpxe/process.h>
#include <gpxe/keys.h>
#include <gpxe/timer.h>
Go to the source code of this file.
Defines | |
| #define | GETKEY_TIMEOUT ( TICKS_PER_SEC / 4 ) |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| static int | getchar_timeout (unsigned long timeout) |
| Read character from console if available within timeout period. | |
| int | getkey (void) |
| Get single keypress. | |
Definition in file getkey.c.
| #define GETKEY_TIMEOUT ( TICKS_PER_SEC / 4 ) |
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| static int getchar_timeout | ( | unsigned long | timeout | ) | [static] |
Read character from console if available within timeout period.
| timeout | Timeout period, in ticks |
| character | Character read from console |
Definition at line 41 of file getkey.c.
References currticks(), getchar(), iskey(), and step().
Referenced by getkey().
00041 { 00042 unsigned long expiry = ( currticks() + timeout ); 00043 00044 while ( currticks() < expiry ) { 00045 step(); 00046 if ( iskey() ) 00047 return getchar(); 00048 } 00049 00050 return -1; 00051 }
| int getkey | ( | void | ) |
Get single keypress.
| key | Key pressed |
Definition at line 63 of file getkey.c.
References ESC, getchar(), getchar_timeout(), GETKEY_TIMEOUT, isdigit, and KEY_ANSI.
Referenced by login_ui(), main_loop(), pxe_menu_prompt_and_select(), pxe_menu_select(), and readline().
00063 { 00064 int character; 00065 unsigned int n = 0; 00066 00067 character = getchar(); 00068 if ( character != ESC ) 00069 return character; 00070 00071 while ( ( character = getchar_timeout ( GETKEY_TIMEOUT ) ) >= 0 ) { 00072 if ( character == '[' ) 00073 continue; 00074 if ( isdigit ( character ) ) { 00075 n = ( ( n * 10 ) + ( character - '0' ) ); 00076 continue; 00077 } 00078 if ( character >= 0x40 ) 00079 return KEY_ANSI ( n, character ); 00080 } 00081 00082 return ESC; 00083 }
1.5.7.1