From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFSIh-00033V-Ob for qemu-devel@nongnu.org; Sun, 25 Jan 2015 13:52:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YFSId-00018i-PQ for qemu-devel@nongnu.org; Sun, 25 Jan 2015 13:52:47 -0500 Received: from smtp.p12a.org.uk ([213.138.100.29]:58058 helo=corinth.p12a.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFSId-00011y-Ad for qemu-devel@nongnu.org; Sun, 25 Jan 2015 13:52:43 -0500 From: Nathan Baum Date: Sun, 25 Jan 2015 18:52:06 +0000 Message-Id: <1422211926-26548-1-git-send-email-n@p12a.org.uk> Subject: [Qemu-devel] [PATCH] ui/vnc: make sure necessary shift-states are in effect when sending keys List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Nathan Baum 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 --- 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