Hi,

we wanted to use Latin2 characters but it is impossible. Thus
here is fast (2 hours) hack on 4.1.1 which enables it. It works
with both Unix and Win client and server.
You can add other keys, just update file x2uni_l2.h with other
X11 KeyCode vs. Unicode mappings.
I used perl script to generate current one. If there is enough
interest I can create whole unicode map.

The hack is no so clean (linear search for codes etc), it should
be in class but... it works.

Can someone create binary installer from patched vnc ? (I'm
out of time now).

best regards,
-------------------------------
     Martin Devera aka devik
Linux kernel QoS/HTB maintainer
   http://luxik.cdi.cz/~devik/
Add Latin 2 (and easily all other Unicode) support
to RealVNC Free Edition v4.1
Martin Devera, [EMAIL PROTECTED], Oct 2005

diff -puNrb old/win/rfb_win32/CKeyboard.cxx win/rfb_win32/CKeyboard.cxx
--- old/win/rfb_win32/CKeyboard.cxx     Fri Mar 11 15:31:53 2005
+++ win/rfb_win32/CKeyboard.cxx Thu Oct 13 15:48:35 2005
@@ -90,6 +90,7 @@ public:
   rdr::U32 keysym;
 };
 
+#include "x2uni_l2.h"
 // IS_PRINTABLE_LATIN1 tests if a character is either a printable latin1
 // character, or 128, which is the Euro symbol on Windows.
 #define IS_PRINTABLE_LATIN1(c) (((c) >= 32 && (c) <= 126) || (c) == 128 || \
@@ -117,9 +118,10 @@ void win32::CKeyboard::keyEvent(InputHan
 
   BYTE keystate[256];
   GetKeyboardState(keystate);
-  rdr::U8 chars[2];
+  rdr::U16 uchars[2];
 
-  int nchars = ToAscii(vkey, 0, keystate, (WORD*)&chars, 0);
+  int nchars = ToUnicode(vkey, 0, keystate, (WORD*)&uchars,2, 0);
+  vlog.debug("unic: extendedVkey 0x%x n:%d uch:%hX", 
extendedVkey,nchars,uchars[0]);
 
   // See if it's in the Windows VK code -> X keysym map.  We do this before
   // looking at the result of ToAscii so that e.g. we recognise that it's
@@ -138,8 +140,8 @@ void win32::CKeyboard::keyEvent(InputHan
     vlog.debug("ToAscii dead key (1): extendedVkey 0x%x", extendedVkey);
     return;
   }
-
-  if (nchars > 0 && IS_PRINTABLE_LATIN1(chars[0])) {
+  int xk = 0;
+  if (nchars > 0 && (IS_PRINTABLE_LATIN1(uchars[0]) || (xk = 
find_unicode_X(uchars[0])))) {
     // Got a printable latin1 character.  We must release Control and Alt
     // (AltGr) if they were both pressed, so that the latin1 character is seen
     // without them by the VNC server.
@@ -156,11 +158,11 @@ void win32::CKeyboard::keyEvent(InputHan
     }
 
     for (int i = 0; i < nchars; i++) {
-      vlog.debug("ToAscii key (1): extendedVkey 0x%x", extendedVkey);
-      if (chars[i] == 128) { // special hack for euro!
+      vlog.debug("ToUnicode key (1): extendedVkey 0x%x", extendedVkey);
+      if (uchars[i] == 128) { // special hack for euro!
         pressKey(writer, extendedVkey, XK_EuroSign);
       } else {
-        pressKey(writer, extendedVkey, chars[i]);
+               pressKey(writer, extendedVkey, xk ? xk : uchars[i]);
       }
     }
     return;
@@ -173,6 +175,7 @@ void win32::CKeyboard::keyEvent(InputHan
   keystate[VK_CONTROL] = keystate[VK_LCONTROL] = keystate[VK_RCONTROL] = 0;
   keystate[VK_MENU] = keystate[VK_LMENU] = keystate[VK_RMENU] = 0;
 
+  rdr::U8 chars[2];
   nchars = ToAscii(vkey, 0, keystate, (WORD*)&chars, 0);
 
   if (nchars < 0) {
diff -puNrb old/win/rfb_win32/SInput.cxx win/rfb_win32/SInput.cxx
--- old/win/rfb_win32/SInput.cxx        Fri Mar 11 15:31:55 2005
+++ win/rfb_win32/SInput.cxx    Thu Oct 13 14:25:33 2005
@@ -362,7 +362,7 @@ win32::SKeyboard::SKeyboard()
   }
 }
 
-
+#include "x2uni_l2.h"
 void win32::SKeyboard::keyEvent(rdr::U32 keysym, bool down)
 {
   for (int i = 0; i < sizeof(keysymToAscii) / sizeof(keysymToAscii_t); i++) {
@@ -370,6 +370,17 @@ void win32::SKeyboard::keyEvent(rdr::U32
       keysym = keysymToAscii[i].ascii;
       break;
     }
+  }
+  int unic;
+  if (unic = find_X_unicode(keysym)) {
+       SHORT s = VkKeyScanW(unic);
+       printf("K:%X, un:%X, s:%hX\n",keysym,unic,s);
+       if (s == -1) return;
+       BYTE vkCode = LOBYTE(s);
+    BYTE modifierState = HIBYTE(s);
+    vlog.debug("latin-2 key: 0x%x vkCode 0x%x mod 0x%x down %d",
+               keysym, vkCode, modifierState, down);
+    doKeyEventWithModifiers(vkCode, modifierState, down);
   }
 
   if ((keysym >= 32 && keysym <= 126) ||
diff -puNrb old/win/rfb_win32/x2uni_l2.h win/rfb_win32/x2uni_l2.h
--- old/win/rfb_win32/x2uni_l2.h        Thu Jan  1 01:00:00 1970
+++ win/rfb_win32/x2uni_l2.h    Thu Oct 13 15:28:45 2005
@@ -0,0 +1,68 @@
+static struct _l2_x2u {
+       int X,U;
+} latin2_X_unicode[]={
+{0x1a1, 260},
+{0x1a3, 321},
+{0x1a5, 317},
+{0x1a6, 346},
+{0x1a9, 352},
+{0x1aa, 350},
+{0x1ab, 356},
+{0x1ac, 377},
+{0x1ae, 381},
+{0x1af, 379},
+{0x1b1, 261},
+{0x1b3, 322},
+{0x1b5, 318},
+{0x1b6, 347},
+{0x1b9, 353},
+{0x1ba, 351},
+{0x1bb, 357},
+{0x1bc, 378},
+{0x1be, 382},
+{0x1bf, 380},
+{0x1c0, 340},
+{0x1c5, 313},
+{0x1c6, 262},
+{0x1c8, 268},
+{0x1ca, 280},
+{0x1cc, 282},
+{0x1cf, 270},
+{0x1d0, 272},
+{0x1d1, 323},
+{0x1d2, 327},
+{0x1d5, 336},
+{0x1d8, 344},
+{0x1d9, 366},
+{0x1db, 368},
+{0x1de, 354},
+{0x1e0, 341},
+{0x1e5, 314},
+{0x1e6, 263},
+{0x1e8, 269},
+{0x1ea, 281},
+{0x1ec, 283},
+{0x1ef, 271},
+{0x1f0, 273},
+{0x1f1, 324},
+{0x1f2, 328},
+{0x1f5, 337},
+{0x1fb, 369},
+{0x1f8, 345},
+{0x1f9, 367},
+{0x1fe, 355},
+{0,0}
+};
+
+static int find_X_unicode(int x)
+{
+       struct _l2_x2u *p = latin2_X_unicode;
+       for (;p->X;p++) if (p->X==x) return p->U;
+       return 0;
+}
+static int find_unicode_X(int x)
+{
+       struct _l2_x2u *p = latin2_X_unicode;
+       for (;p->X;p++) if (p->U==x) return p->X;
+       return 0;
+}
_______________________________________________
VNC-List mailing list
[email protected]
To remove yourself from the list visit:
http://www.realvnc.com/mailman/listinfo/vnc-list

Reply via email to