Ignore:
Timestamp:
Jul 3, 2001, 10:36:54 PM (24 years ago)
Author:
sandervl
Message:

More ToAscii fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/winkeyboard.cpp

    r6156 r6157  
    1 /* $Id: winkeyboard.cpp,v 1.10 2001-07-03 18:33:28 sandervl Exp $ */
     1/* $Id: winkeyboard.cpp,v 1.11 2001-07-03 20:36:54 sandervl Exp $ */
    22/*
    33 * Win32 <-> PM key translation
     
    599599        }
    600600        for(i=0;i<256;i++) {
    601             if(lpKeyState[i] & 0x80) {
     601            if(lpKeyState[i]) {
    602602                dprintf2(("Win key 0x%0x = %x", i, lpKeyState[i]));
    603603            }
     
    716716 * Status    : UNTESTED STUB
    717717 *
    718  * Author    : Partly based on Wine code (windows\x11drv\keyboard.c
    719  * Copyright 1993 Bob Amstadt
    720  * Copyright 1996 Albrecht Kleine
    721  * Copyright 1997 David Faure
    722  * Copyright 1998 Morten Welinder
    723  * Copyright 1998 Ulrich Weigand
    724  * Copyright 1999 Ove Kåven
    725  *
     718 * Author    : SvL
    726719 *****************************************************************************/
    727720int WIN32API ToAscii(UINT   uVirtKey,
     
    731724                     UINT   fuState)
    732725{
    733   dprintf(("USER32:ToAscii (%u,%u,%08xh,%08xh,%u) partially implemented",
     726  dprintf(("USER32:ToAscii (%x,%x,%08xh,%08xh,%x) partially implemented",
    734727           uVirtKey, uScanCode, lpbKeyState, lpwTransKey,  fuState));
    735728
     
    755748       ret = 0;
    756749  }
     750  else
     751  if (uVirtKey == VK_ESCAPE) {
     752       //NT returns VK_ESCAPE here
     753       *(char*)lpwTransKey = VK_ESCAPE;
     754       ret = 1;
     755  }
    757756  else {
    758757       ULONG shiftstate = 0;
     
    762761       if(lpbKeyState[VK_LSHIFT]   & 0x80) shiftstate |= TCF_LSHIFT;
    763762       if(lpbKeyState[VK_RSHIFT]   & 0x80) shiftstate |= TCF_RSHIFT;
     763       if(lpbKeyState[VK_SHIFT]    & 0x80) shiftstate |= TCF_SHIFT;
    764764       if(lpbKeyState[VK_LCONTROL] & 0x80) shiftstate |= TCF_LCONTROL;
    765765       if(lpbKeyState[VK_RCONTROL] & 0x80) shiftstate |= TCF_RCONTROL;
     766       if(lpbKeyState[VK_CONTROL]  & 0x80) shiftstate |= TCF_CONTROL;
    766767       if(lpbKeyState[VK_LMENU]    & 0x80) shiftstate |= TCF_ALT;
    767768       if(lpbKeyState[VK_RMENU]    & 0x80) shiftstate |= TCF_ALTGR;
     769       if(lpbKeyState[VK_MENU]     & 0x80) shiftstate |= TCF_ALT;
    768770       if(lpbKeyState[VK_CAPITAL]  & 1)    shiftstate |= TCF_CAPSLOCK;
    769771       if(lpbKeyState[VK_NUMLOCK]  & 1)    shiftstate |= TCF_NUMLOCK;
    770772
    771        *(char*)lpwTransKey = OSLibWinTranslateChar(uScanCode, TC_SCANCODETOCHAR, shiftstate);
    772 
    773        ret = 1;
     773       //NT only modifies the bytes it returns
     774       *(char *)lpwTransKey = OSLibWinTranslateChar(uScanCode, TC_SCANCODETOCHAR, shiftstate);
     775
     776       if(shiftstate & TCF_CONTROL) {
     777           if(uVirtKey >= VK_A && uVirtKey <= VK_Z) {
     778               //NT returns key-0x60 (or so it seems) for ctrl-(shift-)-a..z
     779               if(shiftstate & TCF_SHIFT) {
     780                    *(char *)lpwTransKey -= 0x40;
     781               }
     782               else *(char *)lpwTransKey -= 0x60;
     783           }
     784           else
     785           if(uVirtKey == VK_SPACE) {
     786               if(shiftstate & TCF_SHIFT) {
     787                   //NT returns 0 for ctrl-shift-space
     788                   *lpwTransKey = 0;
     789               }
     790           }
     791           else {
     792               //NT returns 0 for ctrl-0, ctrl-.
     793               *lpwTransKey = 0;
     794           }
     795       }
     796
     797       if(*(char *)lpwTransKey == 0) {
     798            ret = 0;
     799       }
     800       else ret = 1;
    774801  }
     802  dprintf2(("USER32:ToAscii returned %x, len %d", *lpwTransKey, ret));
    775803  return ret;
    776804}
Note: See TracChangeset for help on using the changeset viewer.