summaryrefslogtreecommitdiff
path: root/src/kbd.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2017-09-18 10:47:20 +0200
committerKevin O'Connor <kevin@koconnor.net>2017-09-22 11:13:22 -0400
commit90fa511527146dc098c39612478e61cdd3e1dc82 (patch)
tree82de4451419613adc514af7a5215171e24d9bf12 /src/kbd.c
parent44270bc1d285ff09981adef36ba1a2c525e79d09 (diff)
downloadqemu-seabios-90fa511527146dc098c39612478e61cdd3e1dc82.tar.gz
kbd: make enqueue_key public, add ascii_to_keycode
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>
Diffstat (limited to 'src/kbd.c')
-rw-r--r--src/kbd.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/kbd.c b/src/kbd.c
index 916358e..15e5ae7 100644
--- 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)
{