From: AJ <aj...@vi...> - 2005-04-27 03:43:21
|
now holding the ALT key produces a readkey() event. im not sure that is right. but the alt A-z and A-z are different.. yeah! Elias Pschernig wrote: > Hm, posting this from windows with gmail.. and of course, my reply I > sent this morning isn't here (which is really odd, since the archiv on > SF has it..) > > Anyway, the attached patch should make Alt+key always return 0 as > ascii code for readkey(). > > > ------------------------------------------------------------------------ > > Index: src/win/wkeybd.c > =================================================================== > RCS file: /cvsroot/alleg/allegro/src/win/wkeybd.c,v > retrieving revision 1.32 > diff -u -p -r1.32 wkeybd.c > --- src/win/wkeybd.c 8 Apr 2005 16:08:04 -0000 1.32 > +++ src/win/wkeybd.c 25 Apr 2005 13:33:50 -0000 > @@ -256,23 +256,29 @@ static void handle_key_press(unsigned ch > vkey = VK_RETURN; > } > > - /* 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) > - { > - WCHAR wstr[2]; > - MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (LPCSTR)chars, n, wstr, 2); > - unicode = wstr[0]; > + /* When alt key is pressed, any key always must return ASCII 0 in Allegro. */ > + if (keystate[VK_LMENU] & 0x80) { > + unicode = 0; > } > - else > - { > - /* Don't generate key presses for modifier keys. */ > - if (mycode >= KEY_MODIFIERS || n != 0) > - unicode = -1; > + else { > + /* TODO: is there an advantage using ToUnicode? 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) > + { > + WCHAR wstr[2]; > + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (LPCSTR)chars, n, wstr, 2); > + unicode = wstr[0]; > + } > else > - unicode = 0; > + { > + /* Don't generate key presses for modifier keys or dead keys */ > + if (mycode >= KEY_MODIFIERS || n != 0) > + unicode = -1; > + else > + unicode = 0; > + } > } > > _handle_key_press(unicode, mycode); |