[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/7] kbd: make enqueue_key public, add ascii_to_keyc
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 2/7] kbd: make enqueue_key public, add ascii_to_keycode |
Date: |
Wed, 28 Sep 2016 11:07:15 +0200 |
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 <address@hidden>
---
src/kbd.c | 18 +++++++++++++++++-
src/util.h | 2 ++
2 files changed, 19 insertions(+), 1 deletion(-)
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)
{
diff --git a/src/util.h b/src/util.h
index 557eb8b..ef65d32 100644
--- a/src/util.h
+++ b/src/util.h
@@ -185,6 +185,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;
--
1.8.3.1
- [Qemu-devel] [PATCH 0/7] serial console support, Gerd Hoffmann, 2016/09/28
- [Qemu-devel] [PATCH 7/7] [hack] ignore sgabios, enable sercon instead, Gerd Hoffmann, 2016/09/28
- [Qemu-devel] [PATCH 6/7] sercon: add compile time option, Gerd Hoffmann, 2016/09/28
- [Qemu-devel] [PATCH 3/7] paravirt: read QEMU_CFG_NOGRAPHIC, store in etc/sercon-enable romfile, Gerd Hoffmann, 2016/09/28
- [Qemu-devel] [PATCH 1/7] std: add cp437 to unicode map, Gerd Hoffmann, 2016/09/28
- [Qemu-devel] [PATCH 4/7] add serial console support, Gerd Hoffmann, 2016/09/28
- [Qemu-devel] [PATCH 2/7] kbd: make enqueue_key public, add ascii_to_keycode,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 5/7] sercon: split-output implementation, Gerd Hoffmann, 2016/09/28