Re: [AD] Re: [AL] Allegro 4.2.0 beta1 released!

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Tue, 2005-04-05 at 01:10 +0200, Elias Pschernig wrote:
> > 
> 
> Yes.. ToAscii wouldn't report characters like €. But ToUnicode
> apparently doesn't work on win98. So now I came up with this somewhat
> kludgy solution inside the if(os_type == WIN98...). It works here in XP,
> that's all I know so far about it though..
> 

Ok, besides being broken on win98, the beta1 code also had a stupid
buffer overrun (for which i blame the windows api.. who measures buffer
sizes in characters instead of bytes? :P), and dead-keys produced 0
chars with readkey().

With help from Allegro.cc it's all fixed now. Already applied the
attached patch.

-- 
Elias Pschernig
Index: src/win/wkeybd.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wkeybd.c,v
retrieving revision 1.31
diff -u -r1.31 wkeybd.c
--- src/win/wkeybd.c	7 Apr 2005 22:49:08 -0000	1.31
+++ src/win/wkeybd.c	8 Apr 2005 15:43:52 -0000
@@ -256,16 +256,20 @@
          vkey = VK_RETURN;
    }
 
-   /* Nice, seems Windows has a function to just get the unicode character. */
-   n = ToUnicode(vkey, scancode, keystate, chars, 16, 0);
+   /* TODO: is there an advantage using this? maybe it would allow chinese and so on
+    * characters? For now, always ToAscii is used. */
+   //n = ToUnicode(vkey, scancode, keystate, chars, 16, 0);
+   n = ToAscii(vkey, scancode, keystate, (WORD *)chars, 0);
    if (n == 1)
    {
-      unicode = chars[0];
+      WCHAR wstr[2];
+      MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (LPCSTR)chars, n, wstr, 2);
+      unicode = wstr[0];
    }
    else
    {
       /* Don't generate key presses for modifier keys. */
-      if (mycode >= KEY_MODIFIERS)
+      if (mycode >= KEY_MODIFIERS || n != 0)
          unicode = -1;
       else
          unicode = 0;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/