Ignore:
Timestamp:
Jul 3, 2001, 8:33:28 PM (24 years ago)
Author:
sandervl
Message:

ToAscii fixes

File:
1 edited

Legend:

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

    r6149 r6156  
    1 /* $Id: winkeyboard.cpp,v 1.9 2001-07-03 13:23:32 sandervl Exp $ */
     1/* $Id: winkeyboard.cpp,v 1.10 2001-07-03 18:33:28 sandervl Exp $ */
    22/*
    33 * Win32 <-> PM key translation
     
    563563   for(int i=1;i<nrkeys;i++) {
    564564       if(abWinVKeyToPMScan[i]) {
    565             winkey[i] = pmkey[OSLibWinTranslateChar(abWinVKeyToPMScan[i])];
     565            winkey[i] = pmkey[OSLibWinTranslateChar(abWinVKeyToPMScan[i], TC_SCANCODETOVIRTUALKEY, 0)];
    566566       }
    567567   }
     
    716716 * Status    : UNTESTED STUB
    717717 *
    718  * Author    : Based on Wine code (windows\x11drv\keyboard.c
     718 * Author    : Partly based on Wine code (windows\x11drv\keyboard.c
    719719 * Copyright 1993 Bob Amstadt
    720720 * Copyright 1996 Albrecht Kleine
     
    747747        return 0;
    748748  }
    749 #if 0
    750   /* We have a special case to handle : Shift + arrow, shift + home, ...
    751      X returns a char for it, but Windows doesn't. Let's eat it. */
    752   if(!(lpbKeyState[VK_NUMLOCK] & 0x01)  /* NumLock is off */
    753        && (lpbKeyState[VK_SHIFT] & 0x80) /* Shift is pressed */
    754        && (uVirtKey >= VK_0) && (uVirtKey >= VK_9))
    755   {
    756         *(char*)lpwTransKey = 0;
    757         ret = 0;
    758   }
    759   else       
    760 #endif
     749
    761750  /* We have another special case for delete key (XK_Delete) on an
    762751     extended keyboard. X returns a char for it, but Windows doesn't */
     
    767756  }
    768757  else {
    769        if(uVirtKey >= VK_A && uVirtKey <= VK_Z && !(lpbKeyState[VK_SHIFT] & 0x80)) {
    770              *(char*)lpwTransKey = uVirtKey + 32; //translate to lower case
    771        }
    772        else  *(char*)lpwTransKey = uVirtKey;
     758       ULONG shiftstate = 0;
     759
     760       //TODO: multiple characters returned (DBCS??)
     761
     762       if(lpbKeyState[VK_LSHIFT]   & 0x80) shiftstate |= TCF_LSHIFT;
     763       if(lpbKeyState[VK_RSHIFT]   & 0x80) shiftstate |= TCF_RSHIFT;
     764       if(lpbKeyState[VK_LCONTROL] & 0x80) shiftstate |= TCF_LCONTROL;
     765       if(lpbKeyState[VK_RCONTROL] & 0x80) shiftstate |= TCF_RCONTROL;
     766       if(lpbKeyState[VK_LMENU]    & 0x80) shiftstate |= TCF_ALT;
     767       if(lpbKeyState[VK_RMENU]    & 0x80) shiftstate |= TCF_ALTGR;
     768       if(lpbKeyState[VK_CAPITAL]  & 1)    shiftstate |= TCF_CAPSLOCK;
     769       if(lpbKeyState[VK_NUMLOCK]  & 1)    shiftstate |= TCF_NUMLOCK;
     770
     771       *(char*)lpwTransKey = OSLibWinTranslateChar(uScanCode, TC_SCANCODETOCHAR, shiftstate);
     772
    773773       ret = 1;
    774774  }
     
    815815  return (0);
    816816}
    817 //******************************************************************************
    818 //******************************************************************************
     817/*****************************************************************************
     818 * Name      : int WIN32API ToUnicode
     819 * Purpose   : The ToUnicode function translates the specified virtual-key code
     820 *             and keyboard state to the corresponding Unicode character or characters.
     821 * Parameters: UINT   wVirtKey   virtual-key code
     822 *             UINT   wScanCode  scan code
     823 *             PBYTE  lpKeyState address of key-state array
     824 *             LPWSTR pwszBuff   buffer for translated key
     825 *             int    cchBuff    size of translated key buffer
     826 *             UINT   wFlags     set of function-conditioning flags
     827 * Variables :
     828 * Result    : - 1 The specified virtual key is a dead-key character (accent or
     829 *                 diacritic). This value is returned regardless of the keyboard
     830 *                 layout, even if several characters have been typed and are
     831 *                 stored in the keyboard state. If possible, even with Unicode
     832 *                 keyboard layouts, the function has written a spacing version of
     833 *                 the dead-key character to the buffer specified by pwszBuffer.
     834 *                 For example, the function writes the character SPACING ACUTE
     835 *                 (0x00B4), rather than the character NON_SPACING ACUTE (0x0301).
     836 *               0 The specified virtual key has no translation for the current
     837 *                 state of the keyboard. Nothing was written to the buffer
     838 *                 specified by pwszBuffer.
     839 *               1 One character was written to the buffer specified by pwszBuffer.
     840 *       2 or more Two or more characters were written to the buffer specified by
     841 *                 pwszBuff. The most common cause for this is that a dead-key
     842 *                 character (accent or diacritic) stored in the keyboard layout
     843 *                 could not be combined with the specified virtual key to form a
     844 *                 single character.
     845 * Remark    :
     846 * Status    : UNTESTED STUB
     847 *
     848 * Author    : Patrick Haller [Thu, 1998/02/26 11:55]
     849 *****************************************************************************/
     850int WIN32API ToUnicode(UINT   uVirtKey,
     851                          UINT   uScanCode,
     852                          PBYTE  lpKeyState,
     853                          LPWSTR pwszBuff,
     854                          int    cchBuff,
     855                          UINT   wFlags)
     856{
     857  dprintf(("USER32:ToUnicode (%u,%u,%08xh,%08xh,%u,%08x) not implemented.\n",
     858         uVirtKey,
     859         uScanCode,
     860         lpKeyState,
     861         pwszBuff,
     862         cchBuff,
     863         wFlags));
     864
     865  return (0);
     866}
     867//******************************************************************************
     868//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.