All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] Enable uppercase letters to be entered in QEMU monitor terminal
Date: Tue, 28 Nov 2006 22:50:47 +0000	[thread overview]
Message-ID: <20061128225047.GL24746@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1642 bytes --]

Changeset  10742:3e07ec30c445 made it possible to switch to the QEMU 
monitor terminal when using the VNC display protocol. Unfortunately
the VNC key handling is rather crazy, so even if you have the shift
key pressed, a VNC client will send a lowercase letter, expecting the
server to interpret the state of the shift key as desired. 

Normally in HVM guests, the guest OS does this interpretation just fine,
but if you switch to the monitor terminal (Ctrl+Alt+2) then the guest OS
is not involved. The end result: it is impossible to type any uppercase
letters in the monitor - which makes it hard to type in file paths for
example.

In the spirit of the original patch in changeset 10742, the attached patch
is the simplest solution to make shift keys work - it tracks the shift key
and caps lock key state. If both are active, or both inactive, then no 
transform is made; If either one, or the other (but not both) are active,
then the letters a-z are transformed to A-Z, and vica-verca.

A real long term solution would be to somehow get the monitor to use
the proper keymap tables like the SDL display does, but that's something
which should really be done upstream rather than as a Xen patch since it
would be a rather large amount of work.

    Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

[-- Attachment #2: xen-qemu-vnc-monitor-shift.patch --]
[-- Type: text/plain, Size: 1783 bytes --]

diff -r 7826e5482d42 tools/ioemu/vnc.c
--- a/tools/ioemu/vnc.c	Tue Nov 28 14:27:13 2006 +0000
+++ b/tools/ioemu/vnc.c	Tue Nov 28 17:51:08 2006 -0500
@@ -114,6 +114,7 @@ struct VncState
     int visible_h;
 
     int ctl_keys;               /* Ctrl+Alt starts calibration */
+    int shift_keys;             /* Shift / CapsLock keys */
 };
 
 #define DIRTY_PIXEL_BITS 64
@@ -442,7 +443,6 @@ static void vnc_copy(DisplayState *ds, i
     } else
 	framebuffer_set_updated(vs, dst_x, dst_y, w, h);
 }
-
 static int find_update_height(VncState *vs, int y, int maxy, int last_x, int x)
 {
     int h;
@@ -870,9 +870,15 @@ static void do_key_event(VncState *vs, i
     } else if (down) {
 	int qemu_keysym = 0;
 
-	if (sym <= 128) /* normal ascii */
-	    qemu_keysym = sym;
-	else {
+	if (sym <= 128) { /* normal ascii */
+	    int shifted = vs->shift_keys == 1 || vs->shift_keys == 2;
+	    if (sym >= 'a' && sym <= 'z' && shifted)
+	        qemu_keysym = sym + ('A' - 'a');
+	    else if (sym >= 'A' && sym <= 'Z' && !shifted)
+	        qemu_keysym = sym - ('A' - 'a');
+	    else
+	        qemu_keysym = sym;
+	} else {
 	    switch (sym) {
 	    case XK_Up: qemu_keysym = QEMU_KEY_UP; break;
 	    case XK_Down: qemu_keysym = QEMU_KEY_DOWN; break;
@@ -903,6 +909,10 @@ static void do_key_event(VncState *vs, i
 	    vs->ctl_keys |= 2;
 	    break;
 
+	case XK_Shift_L:
+	    vs->shift_keys |= 1;
+	    break;
+
 	default:
 	    break;
 	}
@@ -914,6 +924,17 @@ static void do_key_event(VncState *vs, i
 
 	case XK_Alt_L:
 	    vs->ctl_keys &= ~2;
+	    break;
+
+	case XK_Shift_L:
+	    vs->shift_keys &= ~1;
+	    break;
+
+	case XK_Caps_Lock:
+	    if (vs->shift_keys & 2)
+	        vs->shift_keys &= ~2;
+	    else
+	        vs->shift_keys |= 2;
 	    break;
 
 	case XK_1 ... XK_9:

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2006-11-28 22:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-28 22:50 Daniel P. Berrange [this message]
2006-11-29 11:45 ` [PATCH] Enable uppercase letters to be entered in QEMU monitor terminal Keir Fraser
2006-11-29 12:04   ` Daniel P. Berrange
2006-11-29 12:19     ` Keir Fraser
2006-11-29 15:48   ` Daniel P. Berrange
2006-11-29 16:09     ` Keir Fraser
2006-12-20 11:15       ` Kasai Takanori
2006-12-20 11:19         ` Keir Fraser
2006-12-21  1:31           ` Kasai Takanori

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=20061128225047.GL24746@redhat.com \
    --to=berrange@redhat.com \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.