From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKAf9-0002u8-Qu for qemu-devel@nongnu.org; Mon, 04 Jul 2016 16:40:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKAf7-0000Wa-8T for qemu-devel@nongnu.org; Mon, 04 Jul 2016 16:40:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54075) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKAf7-0000WV-2a for qemu-devel@nongnu.org; Mon, 04 Jul 2016 16:40:13 -0400 From: Gerd Hoffmann Date: Mon, 4 Jul 2016 22:39:53 +0200 Message-Id: <1467664794-31002-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1467664794-31002-1-git-send-email-kraxel@redhat.com> References: <1467664794-31002-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 2/3] kbd: make enqueue_key public, add ascii_to_keycode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: seabios@seabios.org Cc: qemu-devel@nongnu.org, Gerd Hoffmann Signed-off-by: Gerd Hoffmann --- src/kbd.c | 17 ++++++++++++++++- src/util.h | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/kbd.c b/src/kbd.c index 61d9df0..7c43129 100644 --- a/src/kbd.c +++ b/src/kbd.c @@ -51,7 +51,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); @@ -376,6 +376,21 @@ static struct scaninfo { { 0x8600, 0x8800, 0x8a00, 0x8c00 }, /* F12 */ }; +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 __process_key(u8 scancode) diff --git a/src/util.h b/src/util.h index 7b41207..cfcf4a3 100644 --- a/src/util.h +++ b/src/util.h @@ -184,6 +184,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