qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: seabios@seabios.org
Cc: qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 2/3] kbd: make enqueue_key public, add ascii_to_keycode
Date: Mon,  4 Jul 2016 22:39:53 +0200	[thread overview]
Message-ID: <1467664794-31002-3-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1467664794-31002-1-git-send-email-kraxel@redhat.com>

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 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

  parent reply	other threads:[~2016-07-04 20:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-04 20:39 [Qemu-devel] [PATCH v2 0/3] seabios: add serial console support Gerd Hoffmann
2016-07-04 20:39 ` [Qemu-devel] [PATCH 1/3] std: add cp437 to unicode map Gerd Hoffmann
2016-07-05 13:49   ` [Qemu-devel] [SeaBIOS] " Kevin O'Connor
2016-07-04 20:39 ` Gerd Hoffmann [this message]
2016-07-04 20:39 ` [Qemu-devel] [PATCH 3/3] add serial console support Gerd Hoffmann
2016-07-05 14:30   ` [Qemu-devel] [SeaBIOS] " Kevin O'Connor
2016-07-05 15:07     ` Gerd Hoffmann
2016-07-05 15:23       ` Kevin O'Connor
2016-07-05  8:06 ` [Qemu-devel] [PATCH v2 0/3] seabios: " Daniel P. Berrange
2016-07-05 10:00   ` Gerd Hoffmann
2016-07-05 10:07     ` Daniel P. Berrange
2016-07-05 11:45       ` Paolo Bonzini
2016-07-05 11:59         ` Daniel P. Berrange
2016-07-05 11:15     ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467664794-31002-3-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=seabios@seabios.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).