From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 1/5] keymap: make struct kbd_layout_t private to ui/keymaps.c
Date: Fri, 16 Feb 2018 15:44:14 +0100 [thread overview]
Message-ID: <20180216144418.21986-2-kraxel@redhat.com> (raw)
In-Reply-To: <20180216144418.21986-1-kraxel@redhat.com>
Also use kbd_layout_t pointers instead of void pointers.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/keymaps.h | 28 +++++-----------------------
ui/keymaps.c | 31 ++++++++++++++++++++++++-------
2 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/ui/keymaps.h b/ui/keymaps.h
index 8757465529..5c0898bfcf 100644
--- a/ui/keymaps.h
+++ b/ui/keymaps.h
@@ -32,25 +32,6 @@ typedef struct {
int keysym;
} name2keysym_t;
-struct key_range {
- int start;
- int end;
- struct key_range *next;
-};
-
-#define MAX_NORMAL_KEYCODE 512
-#define MAX_EXTRA_COUNT 256
-typedef struct {
- uint16_t keysym2keycode[MAX_NORMAL_KEYCODE];
- struct {
- int keysym;
- uint16_t keycode;
- } keysym2keycode_extra[MAX_EXTRA_COUNT];
- int extra_count;
- struct key_range *keypad_range;
- struct key_range *numlock_range;
-} kbd_layout_t;
-
/* scancode without modifiers */
#define SCANCODE_KEYMASK 0xff
/* scancode without grey or up bit */
@@ -69,10 +50,11 @@ typedef struct {
#define SCANCODE_ALT 0x400
#define SCANCODE_ALTGR 0x800
+typedef struct kbd_layout_t kbd_layout_t;
-void *init_keyboard_layout(const name2keysym_t *table, const char *language);
-int keysym2scancode(void *kbd_layout, int keysym);
-int keycode_is_keypad(void *kbd_layout, int keycode);
-int keysym_is_numlock(void *kbd_layout, int keysym);
+kbd_layout_t* init_keyboard_layout(const name2keysym_t *table, const char *language);
+int keysym2scancode(kbd_layout_t *k, int keysym);
+int keycode_is_keypad(kbd_layout_t *k, int keycode);
+int keysym_is_numlock(kbd_layout_t *k, int keysym);
#endif /* QEMU_KEYMAPS_H */
diff --git a/ui/keymaps.c b/ui/keymaps.c
index f9762d1497..74d93dee63 100644
--- a/ui/keymaps.c
+++ b/ui/keymaps.c
@@ -28,6 +28,26 @@
#include "trace.h"
#include "qemu/error-report.h"
+#define MAX_NORMAL_KEYCODE 512
+#define MAX_EXTRA_COUNT 256
+
+struct key_range {
+ int start;
+ int end;
+ struct key_range *next;
+};
+
+struct kbd_layout_t {
+ uint16_t keysym2keycode[MAX_NORMAL_KEYCODE];
+ struct {
+ int keysym;
+ uint16_t keycode;
+ } keysym2keycode_extra[MAX_EXTRA_COUNT];
+ int extra_count;
+ struct key_range *keypad_range;
+ struct key_range *numlock_range;
+};
+
static int get_keysym(const name2keysym_t *table,
const char *name)
{
@@ -186,15 +206,14 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
}
-void *init_keyboard_layout(const name2keysym_t *table, const char *language)
+kbd_layout_t* init_keyboard_layout(const name2keysym_t *table, const char *language)
{
return parse_keyboard_layout(table, language, NULL);
}
-int keysym2scancode(void *kbd_layout, int keysym)
+int keysym2scancode(kbd_layout_t *k, int keysym)
{
- kbd_layout_t *k = kbd_layout;
if (keysym < MAX_NORMAL_KEYCODE) {
if (k->keysym2keycode[keysym] == 0) {
trace_keymap_unmapped(keysym);
@@ -217,9 +236,8 @@ int keysym2scancode(void *kbd_layout, int keysym)
return 0;
}
-int keycode_is_keypad(void *kbd_layout, int keycode)
+int keycode_is_keypad(kbd_layout_t *k, int keycode)
{
- kbd_layout_t *k = kbd_layout;
struct key_range *kr;
for (kr = k->keypad_range; kr; kr = kr->next) {
@@ -230,9 +248,8 @@ int keycode_is_keypad(void *kbd_layout, int keycode)
return 0;
}
-int keysym_is_numlock(void *kbd_layout, int keysym)
+int keysym_is_numlock(kbd_layout_t *k, int keysym)
{
- kbd_layout_t *k = kbd_layout;
struct key_range *kr;
for (kr = k->numlock_range; kr; kr = kr->next) {
--
2.9.3
next prev parent reply other threads:[~2018-02-16 14:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-16 14:44 [Qemu-devel] [PATCH 0/5] keymap: support kbd layouts with multiple mappings for the same key Gerd Hoffmann
2018-02-16 14:44 ` Gerd Hoffmann [this message]
2018-02-16 14:44 ` [Qemu-devel] [PATCH 2/5] keymap: use glib hash for kbd_layout_t Gerd Hoffmann
2018-02-16 14:44 ` [Qemu-devel] [PATCH 3/5] keymap: numpad keysyms and keycodes are fixed Gerd Hoffmann
2018-02-16 14:44 ` [Qemu-devel] [PATCH 4/5] keymap: record multiple keysym -> keycode mappings Gerd Hoffmann
2018-02-16 14:44 ` [Qemu-devel] [PATCH 5/5] keymap: consider modifier state when picking a mapping Gerd Hoffmann
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=20180216144418.21986-2-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.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).