Skip to contentSkip to conversation

Work around VNC clients that do not transmit shifts for uppercase characters

PATCH In review Anthony Liguori 2 participants 3 messages May 1, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Work around VNC clients that do not transmit shifts for uppercase characters

The spec isn't really clear about what a client should do. This patch is needed for RealVNC clients (at least).

Regards,

Anthony Liguori

# HG changeset patch
# User Anthony Liguori <[email protected]>
# Node ID 8a71740fc36fcaf97e126e581847983cb2a4324d
# Parent a9314fc39a5e3d78d80d385f560c922c3ce0e82b
Fix for VNC clients that do not send Shift's for uppercase characters

vnc.c +18 -2
diff -r a9314fc39a5e -r 8a71740fc36f vnc.c
@@ -591,11 +591,11 @@ static void pointer_event(VncState *vs, 
     }
 }
 
-static void key_event(VncState *vs, int down, uint32_t sym)
+static void key_event_post(kbd_layout_t *kbd_layout, int down, uint32_t sym)
 {
     int keycode;
 
-    keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF);
+    keycode = keysym2scancode(kbd_layout, sym & 0xFFFF);
 
     if (keycode & 0x80)
 	kbd_put_keycode(0xe0);
@@ -603,6 +603,22 @@ static void key_event(VncState *vs, int 
 	kbd_put_keycode(keycode & 0x7f);
     else
 	kbd_put_keycode(keycode | 0x80);
+}
+
+static void key_event(VncState *vs, int down, uint32_t sym)
+{
+
+    if (sym >= 'A' && sym <= 'Z') {
+	sym = (sym - 'A') + 'a';
+	if (down) {
+	    key_event_post(vs->kbd_layout, 1, 0xffe1);
+	    key_event_post(vs->kbd_layout, 1, sym);
+	    key_event_post(vs->kbd_layout, 0, 0xffe1);
+	    return;
+	}
+    }
+
+    key_event_post(vs->kbd_layout, down, sym);
 }
 
 static void framebuffer_update_request(VncState *vs, int incremental,
#1 lore raw

Does it mean that the caps lock keysym is not transmitted by RealVNC ? Otherwise converting the upper case to case lower case would suffice.

Fabrice.

Quoted 55 lines · Anthony Liguori

The spec isn't really clear about what a client should do. This patch is needed for RealVNC clients (at least).

Regards,

Anthony Liguori

------------------------------------------------------------------------

# HG changeset patch
# User Anthony Liguori <[email protected]>
# Node ID 8a71740fc36fcaf97e126e581847983cb2a4324d
# Parent a9314fc39a5e3d78d80d385f560c922c3ce0e82b
Fix for VNC clients that do not send Shift's for uppercase characters

diff -r a9314fc39a5e -r 8a71740fc36f vnc.c

vnc.c +18 -2
@@ -591,11 +591,11 @@ static void pointer_event(VncState *vs, 
     }
 }
 
-static void key_event(VncState *vs, int down, uint32_t sym)
+static void key_event_post(kbd_layout_t *kbd_layout, int down, uint32_t sym)
 {
     int keycode;
 
-    keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF);
+    keycode = keysym2scancode(kbd_layout, sym & 0xFFFF);
 
     if (keycode & 0x80)
 	kbd_put_keycode(0xe0);
@@ -603,6 +603,22 @@ static void key_event(VncState *vs, int 
 	kbd_put_keycode(keycode & 0x7f);
     else
 	kbd_put_keycode(keycode | 0x80);
+}
+
+static void key_event(VncState *vs, int down, uint32_t sym)
+{
+
+    if (sym >= 'A' && sym <= 'Z') {
+	sym = (sym - 'A') + 'a';
+	if (down) {
+	    key_event_post(vs->kbd_layout, 1, 0xffe1);
+	    key_event_post(vs->kbd_layout, 1, sym);
+	    key_event_post(vs->kbd_layout, 0, 0xffe1);
+	    return;
+	}
+    }
+
+    key_event_post(vs->kbd_layout, down, sym);
 }
 
 static void framebuffer_update_request(VncState *vs, int incremental,
#2 lore raw
Quoted 1 line · Fabrice Bellard

Does it mean that the caps lock keysym is not transmitted by RealVNC ? Otherwise converting the upper case to case lower case would suffice.

You're right. New patch attached.

Regards,

Anthony Liguori

Quoted 57 lines

Fabrice.

Quoted 54 lines · Anthony Liguori

The spec isn't really clear about what a client should do. This patch is needed for RealVNC clients (at least).

Regards,

Anthony Liguori

------------------------------------------------------------------------

# HG changeset patch
# User Anthony Liguori <[email protected]>
# Node ID 8a71740fc36fcaf97e126e581847983cb2a4324d
# Parent a9314fc39a5e3d78d80d385f560c922c3ce0e82b
Fix for VNC clients that do not send Shift's for uppercase characters

diff -r a9314fc39a5e -r 8a71740fc36f vnc.c

vnc.c Sun Apr 30 23:12:48 2006 -0500 renamed from vnc.c Sun Apr 30 19:04:17 2006 -0500 +18 -2
@@ -591,11 +591,11 @@ static void pointer_event(VncState *vs,      }
 }
 
-static void key_event(VncState *vs, int down, uint32_t sym)
+static void key_event_post(kbd_layout_t *kbd_layout, int down, 
 uint32_t sym)
 {
     int keycode;
 
-    keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF);
+    keycode = keysym2scancode(kbd_layout, sym & 0xFFFF);
 
     if (keycode & 0x80)
     kbd_put_keycode(0xe0);
@@ -603,6 +603,22 @@ static void key_event(VncState *vs, int      
 kbd_put_keycode(keycode & 0x7f);
     else
     kbd_put_keycode(keycode | 0x80);
+}
+
+static void key_event(VncState *vs, int down, uint32_t sym)
+{
+
+    if (sym >= 'A' && sym <= 'Z') {
+    sym = (sym - 'A') + 'a';
+    if (down) {
+        key_event_post(vs->kbd_layout, 1, 0xffe1);
+        key_event_post(vs->kbd_layout, 1, sym);
+        key_event_post(vs->kbd_layout, 0, 0xffe1);
+        return;
+    }
+    }
+
+    key_event_post(vs->kbd_layout, down, sym);
 }
 
Quoted 2 lines

vnc.c Sun Apr 30 23:12:48 2006 -0500 static void key_event(VncState *vs, int · line 624

Quoted 1 line
vnc.c Sun Apr 30 23:12:48 2006 -0500 renamed from vnc.c Sun Apr 30 19:04:17 2006 -0500 +0 -0
 static void framebuffer_update_request(VncState *vs, int incremental,

# HG changeset patch
# User Anthony Liguori <[email protected]> # Node ID a2d60c56904d3e2c08d628461c04b149c74b62cb # Parent c0fedc4f4e9c870fa2ececc1144596c73e9e475e Fix uppercase characters

vnc.c +8 -1
diff -r c0fedc4f4e9c -r a2d60c56904d vnc.c
@@ -591,7 +591,7 @@ static void pointer_event(VncState *vs, 
     }
 }
 
-static void key_event(VncState *vs, int down, uint32_t sym)
+static void do_key_event(VncState *vs, int down, uint32_t sym)
 {
     int keycode;
 
@@ -603,6 +603,13 @@ static void key_event(VncState *vs, int 
 	kbd_put_keycode(keycode & 0x7f);
     else
 	kbd_put_keycode(keycode | 0x80);
+}
+
+static void key_event(VncState *vs, int down, uint32_t sym)
+{
+    if (sym >= 'A' && sym <= 'Z')
+	sym = sym - 'A' + 'a';
+    do_key_event(vs, down, sym);
 }
 
 static void framebuffer_update_request(VncState *vs, int incremental,