]> xenbits.xensource.com Git - people/andrewcoop/seabios.git/commitdiff
kbd: make enqueue_key public, add ascii_to_keycode
authorGerd Hoffmann <kraxel@redhat.com>
Mon, 18 Sep 2017 08:47:20 +0000 (10:47 +0200)
committerKevin O'Connor <kevin@koconnor.net>
Fri, 22 Sep 2017 15:13:22 +0000 (11:13 -0400)
serial console wants queue key events and needs to map ascii chars to
the keycode, so make enqueue_key public and also exports a helper
function so sercon can use the scan_to_keycode mapping table.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
src/kbd.c
src/util.h

index 916358eed7f0bcb549d8e291068b44c6694c14a5..15e5ae789cd3a8c0aefb0f9c8d9db054e973445d 100644 (file)
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -29,7 +29,7 @@ kbd_init(void)
             , x + FIELD_SIZEOF(struct bios_data_area_s, kbd_buf));
 }
 
-static u8
+u8
 enqueue_key(u16 keycode)
 {
     u16 buffer_start = GET_BDA(kbd_buf_start_offset);
@@ -375,6 +375,22 @@ struct scaninfo key_ext_slash VAR16 = {
     0xe02f, 0xe02f, 0x9500, 0xa400
 };
 
+u16 ascii_to_keycode(u8 ascii)
+{
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(scan_to_keycode); i++) {
+        if ((GET_GLOBAL(scan_to_keycode[i].normal) & 0xff) == ascii)
+            return GET_GLOBAL(scan_to_keycode[i].normal);
+        if ((GET_GLOBAL(scan_to_keycode[i].shift) & 0xff) == ascii)
+            return GET_GLOBAL(scan_to_keycode[i].shift);
+        if ((GET_GLOBAL(scan_to_keycode[i].control) & 0xff) == ascii)
+            return GET_GLOBAL(scan_to_keycode[i].control);
+    }
+    return 0;
+}
+
+// Handle a ps2 style scancode read from the keyboard.
 static void
 kbd_set_flag(int key_release, u16 set_bit0, u8 set_bit1, u16 toggle_bit)
 {
index 8269057fe7c10e9c5c6117aaebe83a97f1de2266..da9059a9bf07870b1da0a1ab9740a8d8193c820c 100644 (file)
@@ -186,6 +186,8 @@ int jpeg_show(struct jpeg_decdata *jpeg, unsigned char *pic, int width
 void kbd_init(void);
 void handle_15c2(struct bregs *regs);
 void process_key(u8 key);
+u8 enqueue_key(u16 keycode);
+u16 ascii_to_keycode(u8 ascii);
 
 // misc.c
 extern int HaveRunPost;