keymap: pass full keyboard state to keysym2scancode
Pass the keyboard state tracker handle down to keysym2scancode(), so the code can fully inspect the keyboard state as needed. No functional change. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-id: 20190122092814.14919-8-kraxel@redhat.com
This commit is contained in:
parent
c2f2ba4983
commit
4ed26e19d9
@ -273,7 +273,7 @@ static void curses_refresh(DisplayChangeListener *dcl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
keycode = keysym2scancode(kbd_layout, keysym & KEYSYM_MASK,
|
keycode = keysym2scancode(kbd_layout, keysym & KEYSYM_MASK,
|
||||||
false, false, false);
|
NULL);
|
||||||
if (keycode == 0)
|
if (keycode == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ kbd_layout_t *init_keyboard_layout(const name2keysym_t *table,
|
|||||||
|
|
||||||
|
|
||||||
int keysym2scancode(kbd_layout_t *k, int keysym,
|
int keysym2scancode(kbd_layout_t *k, int keysym,
|
||||||
bool shift, bool altgr, bool ctrl)
|
QKbdState *kbd)
|
||||||
{
|
{
|
||||||
static const uint32_t mask =
|
static const uint32_t mask =
|
||||||
SCANCODE_SHIFT | SCANCODE_ALTGR | SCANCODE_CTRL;
|
SCANCODE_SHIFT | SCANCODE_ALTGR | SCANCODE_CTRL;
|
||||||
@ -220,13 +220,13 @@ int keysym2scancode(kbd_layout_t *k, int keysym,
|
|||||||
* If so, prefer that one.
|
* If so, prefer that one.
|
||||||
*/
|
*/
|
||||||
mods = 0;
|
mods = 0;
|
||||||
if (shift) {
|
if (kbd && qkbd_state_modifier_get(kbd, QKBD_MOD_SHIFT)) {
|
||||||
mods |= SCANCODE_SHIFT;
|
mods |= SCANCODE_SHIFT;
|
||||||
}
|
}
|
||||||
if (altgr) {
|
if (kbd && qkbd_state_modifier_get(kbd, QKBD_MOD_ALTGR)) {
|
||||||
mods |= SCANCODE_ALTGR;
|
mods |= SCANCODE_ALTGR;
|
||||||
}
|
}
|
||||||
if (ctrl) {
|
if (kbd && qkbd_state_modifier_get(kbd, QKBD_MOD_CTRL)) {
|
||||||
mods |= SCANCODE_CTRL;
|
mods |= SCANCODE_CTRL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#define QEMU_KEYMAPS_H
|
#define QEMU_KEYMAPS_H
|
||||||
|
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
|
#include "ui/kbd-state.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char* name;
|
const char* name;
|
||||||
@ -55,7 +56,7 @@ typedef struct kbd_layout_t kbd_layout_t;
|
|||||||
kbd_layout_t *init_keyboard_layout(const name2keysym_t *table,
|
kbd_layout_t *init_keyboard_layout(const name2keysym_t *table,
|
||||||
const char *language, Error **errp);
|
const char *language, Error **errp);
|
||||||
int keysym2scancode(kbd_layout_t *k, int keysym,
|
int keysym2scancode(kbd_layout_t *k, int keysym,
|
||||||
bool shift, bool altgr, bool ctrl);
|
QKbdState *kbd);
|
||||||
int keycode_is_keypad(kbd_layout_t *k, int keycode);
|
int keycode_is_keypad(kbd_layout_t *k, int keycode);
|
||||||
int keysym_is_numlock(kbd_layout_t *k, int keysym);
|
int keysym_is_numlock(kbd_layout_t *k, int keysym);
|
||||||
|
|
||||||
|
5
ui/vnc.c
5
ui/vnc.c
@ -1973,9 +1973,6 @@ static const char *code2name(int keycode)
|
|||||||
|
|
||||||
static void key_event(VncState *vs, int down, uint32_t sym)
|
static void key_event(VncState *vs, int down, uint32_t sym)
|
||||||
{
|
{
|
||||||
bool shift = qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_SHIFT);
|
|
||||||
bool altgr = qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_ALTGR);
|
|
||||||
bool ctrl = qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_CTRL);
|
|
||||||
int keycode;
|
int keycode;
|
||||||
int lsym = sym;
|
int lsym = sym;
|
||||||
|
|
||||||
@ -1984,7 +1981,7 @@ static void key_event(VncState *vs, int down, uint32_t sym)
|
|||||||
}
|
}
|
||||||
|
|
||||||
keycode = keysym2scancode(vs->vd->kbd_layout, lsym & 0xFFFF,
|
keycode = keysym2scancode(vs->vd->kbd_layout, lsym & 0xFFFF,
|
||||||
shift, altgr, ctrl) & SCANCODE_KEYMASK;
|
vs->vd->kbd) & SCANCODE_KEYMASK;
|
||||||
trace_vnc_key_event_map(down, sym, keycode, code2name(keycode));
|
trace_vnc_key_event_map(down, sym, keycode, code2name(keycode));
|
||||||
do_key_event(vs, down, keycode, sym);
|
do_key_event(vs, down, keycode, sym);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user