From: Nathan Baum <n@p12a.org.uk>
To: qemu-devel@nongnu.org
Cc: Nathan Baum <n@p12a.org.uk>
Subject: [Qemu-devel] [PATCH] ui/vnc: make sure necessary shift-states are in effect when sending keys
Date: Sun, 25 Jan 2015 18:52:06 +0000 [thread overview]
Message-ID: <1422211926-26548-1-git-send-email-n@p12a.org.uk> (raw)
If the keymap specifies the shift modifier for a keysym and that modifier
isn't in effect, send a fake press/release for shift around the key event.
Specifically, this resolves the issue of # producing a 3 when I press the
# on my UK keyboard with a VM with a US keyboard. (FYI the UK # key is
where the US @ key goes.)
I think this is a legit change because the RFB protocol specification says
that servers are expected to do this. It specifically highlights # as an
example of where you'd need to do this!
I wasn't sure whether to do this for all the modifiers - my use case
doesn't call for it - so I didn't.
Signed-off-by: Nathan Baum <n@p12a.org.uk>
---
ui/vnc.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/ui/vnc.c b/ui/vnc.c
index a742c90..200cdd7 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -1893,7 +1893,22 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym)
}
if (qemu_console_is_graphic(NULL)) {
- qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, down);
+ int scancode = keysym2scancode(vs->vd->kbd_layout, sym);
+ if (scancode == (scancode & SCANCODE_KEYMASK)) {
+ qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, down);
+ } else {
+ if (scancode & SCANCODE_SHIFT && !(vs->modifiers_state[0x2a] ||
+ vs->modifiers_state[0x36]) {
+ qemu_input_event_send_key_number(vs->vd->dcl.con, 0x2a, true);
+ qemu_input_event_send_key_delay(0);
+ }
+ qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, down);
+ if (scancode & SCANCODE_SHIFT && !(vs->modifiers_state[0x2a] ||
+ vs->modifiers_state[0x36]) {
+ qemu_input_event_send_key_delay(0);
+ qemu_input_event_send_key_number(vs->vd->dcl.con, 0x2a, false);
+ }
+ }
} else {
bool numlock = vs->modifiers_state[0x45];
bool control = (vs->modifiers_state[0x1d] ||
--
2.2.1
next reply other threads:[~2015-01-25 18:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-25 18:52 Nathan Baum [this message]
2015-01-25 20:14 ` [Qemu-devel] [PATCH v2] ui/vnc: make sure necessary shift-states are in effect when sending keys Nathan Baum
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=1422211926-26548-1-git-send-email-n@p12a.org.uk \
--to=n@p12a.org.uk \
--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).