diff options
| author | Michael Brown | 2011-03-07 20:17:51 +0100 |
|---|---|---|
| committer | Michael Brown | 2011-03-07 20:22:20 +0100 |
| commit | 9e98e4b9b890ceabfc1f95224015f4748e59ea35 (patch) | |
| tree | df85cbecb5691700160bd3fd15269ffd3e627996 /src/arch | |
| parent | [cmdline] Add generic concat_args() function (diff) | |
| download | ipxe-9e98e4b9b890ceabfc1f95224015f4748e59ea35.tar.gz ipxe-9e98e4b9b890ceabfc1f95224015f4748e59ea35.tar.xz ipxe-9e98e4b9b890ceabfc1f95224015f4748e59ea35.zip | |
[bios] Recognise scancodes for F5-F12 inclusive
The function keys F5-F12 all conform to the same ANSI pattern as the
other "special" keys that we currently recognise. Add these key
definitions, and shrink the representation of the ANSI sequences in
bios_console.c to compensate.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/i386/firmware/pcbios/bios_console.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/src/arch/i386/firmware/pcbios/bios_console.c b/src/arch/i386/firmware/pcbios/bios_console.c index bf10ebcf1..0743fd237 100644 --- a/src/arch/i386/firmware/pcbios/bios_console.c +++ b/src/arch/i386/firmware/pcbios/bios_console.c @@ -188,28 +188,26 @@ static void bios_putchar ( int character ) { */ static const char *ansi_input = ""; -/** - * Lowest BIOS scancode of interest - * - * Most of the BIOS key scancodes that we are interested in are in a - * dense range, so subtracting a constant and treating them as offsets - * into an array works efficiently. - */ -#define BIOS_KEY_MIN 0x42 - -/** Offset into list of interesting BIOS scancodes */ -#define BIOS_KEY(scancode) ( (scancode) - BIOS_KEY_MIN ) +/** A mapping from a BIOS scan code to an ANSI escape sequence */ +#define BIOS_KEY( key, ansi ) key ansi "\0" /** Mapping from BIOS scan codes to ANSI escape sequences */ -static const char *ansi_sequences[] = { - [ BIOS_KEY ( 0x42 ) ] = "[19~", /* F8 (required for PXE) */ - [ BIOS_KEY ( 0x47 ) ] = "[H", /* Home */ - [ BIOS_KEY ( 0x48 ) ] = "[A", /* Up arrow */ - [ BIOS_KEY ( 0x4b ) ] = "[D", /* Left arrow */ - [ BIOS_KEY ( 0x4d ) ] = "[C", /* Right arrow */ - [ BIOS_KEY ( 0x4f ) ] = "[F", /* End */ - [ BIOS_KEY ( 0x50 ) ] = "[B", /* Down arrow */ - [ BIOS_KEY ( 0x53 ) ] = "[3~", /* Delete */ +static const char ansi_sequences[] = { + BIOS_KEY ( "\x53", "[3~" ) /* Delete */ + BIOS_KEY ( "\x48", "[A" ) /* Up arrow */ + BIOS_KEY ( "\x50", "[B" ) /* Down arrow */ + BIOS_KEY ( "\x4b", "[D" ) /* Left arrow */ + BIOS_KEY ( "\x4d", "[C" ) /* Right arrow */ + BIOS_KEY ( "\x47", "[H" ) /* Home */ + BIOS_KEY ( "\x4f", "[F" ) /* End */ + BIOS_KEY ( "\x3f", "[15~" ) /* F5 */ + BIOS_KEY ( "\x40", "[17~" ) /* F6 */ + BIOS_KEY ( "\x41", "[18~" ) /* F7 */ + BIOS_KEY ( "\x42", "[19~" ) /* F8 (required for PXE) */ + BIOS_KEY ( "\x43", "[20~" ) /* F9 */ + BIOS_KEY ( "\x44", "[21~" ) /* F10 */ + BIOS_KEY ( "\x85", "[23~" ) /* F11 */ + BIOS_KEY ( "\x86", "[24~" ) /* F12 */ }; /** @@ -219,11 +217,12 @@ static const char *ansi_sequences[] = { * @ret ansi_seq ANSI escape sequence, if any, otherwise NULL */ static const char * scancode_to_ansi_seq ( unsigned int scancode ) { - unsigned int bios_key = BIOS_KEY ( scancode ); - - if ( bios_key < ( sizeof ( ansi_sequences ) / - sizeof ( ansi_sequences[0] ) ) ) { - return ansi_sequences[bios_key]; + const char *seq = ansi_sequences; + + while ( *seq ) { + if ( *(seq++) == ( ( char ) scancode ) ) + return seq; + seq += ( strlen ( seq ) + 1 ); } DBG ( "Unrecognised BIOS scancode %02x\n", scancode ); return NULL; |
