]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[bios] Recognise scancodes for F5-F12 inclusive
authorMichael Brown <mcb30@ipxe.org>
Mon, 7 Mar 2011 19:17:51 +0000 (19:17 +0000)
committerMichael Brown <mcb30@ipxe.org>
Mon, 7 Mar 2011 19:22:20 +0000 (19:22 +0000)
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>
src/arch/i386/firmware/pcbios/bios_console.c
src/include/ipxe/keys.h

index bf10ebcf173bd29c7eb1c7eefafd1a00ace19268..0743fd237ccbdd45256b0c493f03a9b1907f11ff 100644 (file)
@@ -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;
index dba65ec3fbd0df830d71c0d321938c3648c30683..8b13550b9369d30668bf6d004eef7e1bccad612b 100644 (file)
@@ -70,7 +70,14 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #define KEY_DC         KEY_ANSI ( 3, '~' )     /**< Delete */
 #define KEY_PPAGE      KEY_ANSI ( 5, '~' )     /**< Page up */
 #define KEY_NPAGE      KEY_ANSI ( 6, '~' )     /**< Page down */
+#define KEY_F5         KEY_ANSI ( 15, '~' )    /**< F5 */
+#define KEY_F6         KEY_ANSI ( 17, '~' )    /**< F6 */
+#define KEY_F7         KEY_ANSI ( 18, '~' )    /**< F7 */
 #define KEY_F8         KEY_ANSI ( 19, '~' )    /**< F8 (for PXE) */
+#define KEY_F9         KEY_ANSI ( 20, '~' )    /**< F9 */
+#define KEY_F10                KEY_ANSI ( 21, '~' )    /**< F10 */
+#define KEY_F11                KEY_ANSI ( 23, '~' )    /**< F11 */
+#define KEY_F12                KEY_ANSI ( 24, '~' )    /**< F12 */
 
 /* Not in the [KEY_MIN,KEY_MAX] range; terminals seem to send these as
  * normal ASCII values.