Ignore:
Timestamp:
Dec 18, 2011, 10:28:22 PM (14 years ago)
Author:
dmik
Message:

Merge branch gcc-kmk to trunk.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1 bin
        2 Makefile.inc
         1env.cmd
         2LocalConfig.kmk
    • Property svn:mergeinfo set to
      /branches/gcc-kmkmergedeligible
  • trunk/src/user32/winkeyboard.cpp

    r21344 r21916  
    5555
    5656
    57 BYTE abPMScanToWinVKey[256][2] =
     57static UCHAR auchPMScanToWinVKey[256][2] =
    5858/****************************************************************************/
    5959/* PM Scancode              *    Win32 vkey                 Extended Key     */
     
    320320{
    321321  /* index is the VKey value */
    322   BYTE  bPMScanCode;
    323   LPSTR lpstrName;
     322  UCHAR  uchPMScanCode;
     323  LPCSTR lpstrName;
    324324} WINVKEYTOPMSCAN, *PWINVKEYTOPMSCAN;
    325325
    326 static WINVKEYTOPMSCAN abWinVKeyToPMScan[256] =
     326static WINVKEYTOPMSCAN auchWinVKeyToPMScan[256] =
    327327/**********************************************************************/
    328328/* Vkey                   *    Scancode               * Name          */
     
    587587
    588588// @@PF reflect Num Enter key
    589 LPSTR lpstrNumEnter = "Num Enter";
     589LPCSTR lpstrNumEnter = "Num Enter";
    590590
    591591// @@@PH
    592592// Note: windows uses different scancodes if numlock is pressed
    593593// This is not (yet) reflected here!
    594 static BYTE abPMScanToWinScan[256][2] =
     594static BYTE auchPMScanToWinScan[256][2] =
    595595/****************************************************************************/
    596596/* PM Scancode              *    Win32 Scancode             Extended Key     */
     
    858858//******************************************************************************
    859859
    860 VOID WIN32API KeyTranslatePMToWinBuf(BYTE *pmkey, BYTE *winkey,
     860VOID WIN32API KeyTranslatePMToWinBuf(PUCHAR pmkey, PUCHAR winkey,
    861861                                     int nrkeys)
    862862{
     
    871871
    872872   for(int i=1;i<nrkeys;i++) {
    873        if(abWinVKeyToPMScan[i].bPMScanCode) {
    874             pmvkey = OSLibWinTranslateChar(abWinVKeyToPMScan[i].bPMScanCode, TC_SCANCODETOVIRTUALKEY, 0);
     873       if(auchWinVKeyToPMScan[i].uchPMScanCode) {
     874            pmvkey = OSLibWinTranslateChar(auchWinVKeyToPMScan[i].uchPMScanCode, TC_SCANCODETOVIRTUALKEY, 0);
    875875            if(pmvkey == 0) {
    876                 dprintf2(("WinTranslateChar %x (%x) FAILED!!", i, abWinVKeyToPMScan[i].bPMScanCode));
     876                dprintf2(("WinTranslateChar %x (%x) FAILED!!", i, auchWinVKeyToPMScan[i].uchPMScanCode));
    877877            }
    878878            winkey[i] = pmkey[pmvkey];
     
    886886//******************************************************************************
    887887//******************************************************************************
    888 BYTE KeyTranslateWinVKeyToPMScan(BYTE bWinVKey, BOOL fExtended)
     888UCHAR KeyTranslateWinVKeyToPMScan(UCHAR uchWinVKey, BOOL fExtended)
    889889{
    890890  // if the extended bit didn't match, this is
    891891  // the closest hit
    892   BYTE bAlmost = 0;
     892  UCHAR uchAlmost = 0;
    893893 
    894894  // experiment
    895895
    896896#if 0
    897   bAlmost = abWinVKeyToPMScan[bWinVKey].bPMScanCode;
     897  bAlmost = auchWinVKeyToPMScan[bWinVKey].uchPMScanCode;
    898898#else
    899899  for(int i = 0;
    900       i < 256; // sizeof(row of abPMScanToWinVKey)
     900      i < 256; // sizeof(row of auchPMScanToWinVKey)
    901901      i++)
    902902  {
    903     if (abPMScanToWinVKey[i][0] == bWinVKey)
     903    if (auchPMScanToWinVKey[i][0] == uchWinVKey)
    904904    {
    905905      // this represents the PMScan code which is used as index     
    906       bAlmost = i;
     906      uchAlmost = i;
    907907     
    908908      // exact match!
    909       if (abPMScanToWinVKey[i][1] == fExtended)
     909      if (auchPMScanToWinVKey[i][1] == fExtended)
    910910        break;
    911911    }
     
    914914 
    915915  dprintf(("KeyTranslateWinVKeyToPMScan(%02xh,%d) = %02xh",
    916            bWinVKey,
     916           uchWinVKey,
    917917           fExtended,
    918            bAlmost));
     918           uchAlmost));
    919919 
    920920  // almost a match or no match at all.
    921   return bAlmost;
    922 }
    923 //******************************************************************************
    924 //******************************************************************************
    925 void KeyTranslatePMScanToWinVKey(BYTE bPMScan,
     921  return uchAlmost;
     922}
     923//******************************************************************************
     924//******************************************************************************
     925void KeyTranslatePMScanToWinVKey(UCHAR uchPMScan,
    926926                                 BOOL bNumLock,
    927                                  PBYTE pbWinVKey,
    928                                  WORD* pwWinScan,
     927                                 PUCHAR puchWinVKey,
     928                                 WORD *pwWinScan,
    929929                                 PBOOL pfExtended)
    930930{
    931931  // @@@PH numlock is currently ignored
    932   if (pbWinVKey)
    933     *pbWinVKey = abPMScanToWinVKey[bPMScan][0];
     932  if (puchWinVKey)
     933    *puchWinVKey = auchPMScanToWinVKey[uchPMScan][0];
    934934 
    935935  if (pfExtended)
    936     *pfExtended = abPMScanToWinVKey[bPMScan][1];
     936    *pfExtended = auchPMScanToWinVKey[uchPMScan][1];
    937937 
    938938  if (pwWinScan)
    939     *pwWinScan = abPMScanToWinScan[bPMScan][0];
    940 }
    941 //******************************************************************************
    942 //******************************************************************************
    943 BYTE KeyTranslateWinScanToPMScan(BYTE bWinScan, BOOL fExtended)
     939    *pwWinScan = auchPMScanToWinScan[uchPMScan][0];
     940}
     941//******************************************************************************
     942//******************************************************************************
     943UCHAR KeyTranslateWinScanToPMScan(UCHAR uchWinScan, BOOL fExtended)
    944944{
    945945  // Note:
     
    949949  // if the extended bit didn't match, this is
    950950  // the closest hit
    951   BYTE bAlmost = 0;
     951  UCHAR uchAlmost = 0;
    952952 
    953953  for(int i = 0;
    954       i < 256; // sizeof(row of abPMScanToWinVKey)
     954      i < 256; // sizeof(row of auchPMScanToWinVKey)
    955955      i++)
    956956  {
    957     if (abPMScanToWinScan[i][0] == bWinScan)
     957    if (auchPMScanToWinScan[i][0] == uchWinScan)
    958958    {
    959959      // this represents the PMScan code which is used as index     
    960       bAlmost = i;
     960      uchAlmost = i;
    961961     
    962962      // exact match!
    963       if (abPMScanToWinVKey[i][1] == fExtended)
     963      if (auchPMScanToWinVKey[i][1] == fExtended)
    964964        break;
    965965    }
     
    967967 
    968968  dprintf(("KeyTranslateWinScanToPMScan(%02xh,%d) = %02xh",
    969            bWinScan,
     969           uchWinScan,
    970970           fExtended,
    971            bAlmost));
     971           uchAlmost));
    972972 
    973973  // almost a match or no match at all.
    974   return bAlmost;
    975  
    976 }
    977 //******************************************************************************
    978 //******************************************************************************
    979 BYTE KeyTranslatePMScanToWinScan(BYTE bPMScan)
     974  return uchAlmost;
     975 
     976}
     977//******************************************************************************
     978//******************************************************************************
     979UCHAR KeyTranslatePMScanToWinScan(UCHAR bPMScan)
    980980{
    981981  // Note:
     
    983983  // O32_MapVirtualKeyA uses PM Scancodes only!
    984984 
    985   return abPMScanToWinScan[bPMScan][0];
     985  return auchPMScanToWinScan[bPMScan][0];
    986986}
    987987//******************************************************************************
     
    10261026   }
    10271027   for(int i=0;i<256;i++) {
    1028        if(abWinVKeyToPMScan[i].bPMScanCode) {
    1029            lpKeyState[i] = PMScanState[abWinVKeyToPMScan[i].bPMScanCode];
     1028       if(auchWinVKeyToPMScan[i].uchPMScanCode) {
     1029           lpKeyState[i] = PMScanState[auchWinVKeyToPMScan[i].uchPMScanCode];
    10301030       }
    10311031       if(lpKeyState[i] & 0x80) {
     
    13351335}
    13361336
     1337extern "C"
    13371338int WINAPI ToUnicodeEx(UINT virtKey, UINT scanCode, const BYTE *lpKeyState,
    13381339                       LPWSTR lpwStr, int size, UINT flags, HKL hkl)
     
    13711372  BOOL  fDontCare = (lParam & WIN_KEY_DONTCARE) != 0;
    13721373  BOOL  fExtended = (lParam & WIN_KEY_EXTENDED) != 0,PMExtended;
    1373   UCHAR ucWinScan = (lParam & 0x00ff0000) >> 16;
    1374   UCHAR ucWinVKey;
    1375   UCHAR ucPMScan;
     1374  UCHAR uchWinScan = (lParam & 0x00ff0000) >> 16;
     1375  UCHAR uchWinVKey;
     1376  UCHAR uchPMScan;
    13761377  int   result;
    13771378 
     
    13881389  // Note: Open32 expects PM Scancodes, NOT Winscancodes.
    13891390  // Note: this is the only way of loss-less conversion!
    1390   ucPMScan = KeyTranslateWinScanToPMScan(ucWinScan, fExtended);
     1391  uchPMScan = KeyTranslateWinScanToPMScan(uchWinScan, fExtended);
    13911392  dprintf(("ucWinScan=%02xh, fExtended=%d translated to PMscan=%02xh\n",
    1392            ucWinScan,
     1393           uchWinScan,
    13931394           fExtended,
    1394            ucPMScan));
    1395   ucWinVKey = abPMScanToWinVKey[ucPMScan][0];
    1396   PMExtended = abPMScanToWinVKey[ucPMScan][1];
     1395           uchPMScan));
     1396  uchWinVKey = auchPMScanToWinVKey[uchPMScan][0];
     1397  PMExtended = auchPMScanToWinVKey[uchPMScan][1];
    13971398
    13981399  dprintf(("ucPMScan=%02xh translated to ucWinVKey=%02xh PMExtended=%d\n",
    1399            ucPMScan,
    1400            ucWinVKey,PMExtended));
     1400           uchPMScan,
     1401           uchWinVKey,PMExtended));
    14011402
    14021403  // Bug in Open32:
     
    14081409  memset(lpString, 0, nSize);
    14091410 
    1410   LPSTR lpstrKey;
    1411   lpstrKey = abWinVKeyToPMScan[ucWinVKey].lpstrName;
     1411  LPCSTR lpstrKey;
     1412  lpstrKey = auchWinVKeyToPMScan[uchWinVKey].lpstrName;
    14121413
    14131414  // handle Enter on Numeric Keypad here
    14141415  if (PMExtended)
    14151416  {
    1416    if (ucWinVKey==VK_RETURN) lpstrKey = lpstrNumEnter;
     1417   if (uchWinVKey==VK_RETURN) lpstrKey = lpstrNumEnter;
    14171418  }
    14181419
     
    14201421  {
    14211422    dprintf(("ERROR: keyname for winscan=%02xh winvkey=%02xh, fExtended=%d not found.\n",
    1422              ucWinScan, ucWinVKey, fExtended & !fDontCare));
     1423             uchWinScan, uchWinVKey, fExtended & !fDontCare));
    14231424   
    14241425    // build artificial name
     
    14271428    sprintf(szName,
    14281429            "VKey%02x%c",
    1429             ucWinScan,
     1430            uchWinScan,
    14301431            fExtended ? '+' : 0);
    14311432    memcpy(lpString, szName, nSize);
     
    15041505  //O32_GetKeyState converts windows virtual keys to PM virtual keys and there
    15051506  //are far fewer PM vkeys. (e.g. 0-9, A-Z will fail)
    1506   if(nVirtKey < 256 && abWinVKeyToPMScan[nVirtKey].bPMScanCode)
     1507  if(nVirtKey < 256 && auchWinVKeyToPMScan[nVirtKey].uchPMScanCode)
    15071508  {
    15081509      INT  nVirtKey2 = 0;
     
    15111512      if (nVirtKey == VK_CONTROL || nVirtKey == VK_LCONTROL)
    15121513      {//if AltGr is down, then pretend VK_LCONTROL is down too
    1513           result = OSLibWinGetScanState(abWinVKeyToPMScan[VK_RMENU].bPMScanCode);
     1514          result = OSLibWinGetScanState(auchWinVKeyToPMScan[VK_RMENU].uchPMScanCode);
    15141515          if(result & 0x8000) {
    15151516              return result;
     
    15201521      if ((nVirtKey >= VK_PRIOR) && (nVirtKey <= VK_DELETE))
    15211522      {
    1522          WORD numState = OSLibWinGetScanState(abWinVKeyToPMScan[VK_NUMLOCK].bPMScanCode) & 1;
     1523         WORD numState = OSLibWinGetScanState(auchWinVKeyToPMScan[VK_NUMLOCK].uchPMScanCode) & 1;
    15231524
    15241525         if(!numState) {
     
    15441545          nVirtKey2 = VK_RSHIFT;
    15451546      }
    1546       result = OSLibWinGetScanState(abWinVKeyToPMScan[nVirtKey].bPMScanCode);
     1547      result = OSLibWinGetScanState(auchWinVKeyToPMScan[nVirtKey].uchPMScanCode);
    15471548      if(nVirtKey2) {
    1548           result |= OSLibWinGetScanState(abWinVKeyToPMScan[nVirtKey2].bPMScanCode);
     1549          result |= OSLibWinGetScanState(auchWinVKeyToPMScan[nVirtKey2].uchPMScanCode);
    15491550      }
    15501551      return result;
     
    15761577  //O32_GetAsyncKeyState converts windows virtual keys to PM virtual keys and there
    15771578  //are far fewer PM vkeys. (e.g. 0-9, A-Z will fail)
    1578   if(nVirtKey < 256 && abWinVKeyToPMScan[nVirtKey].bPMScanCode)
     1579  if(nVirtKey < 256 && auchWinVKeyToPMScan[nVirtKey].uchPMScanCode)
    15791580  {
    15801581      INT  nVirtKey2 = 0;
     
    15831584      if (nVirtKey == VK_CONTROL || nVirtKey == VK_LCONTROL)
    15841585      {//if AltGr is down, then pretend VK_LCONTROL is down too
    1585           result = OSLibWinGetPhysKeyState(abWinVKeyToPMScan[VK_RMENU].bPMScanCode);
     1586          result = OSLibWinGetPhysKeyState(auchWinVKeyToPMScan[VK_RMENU].uchPMScanCode);
    15861587          if(result & 0x8000) {
    15871588              return result;
     
    15921593      if ((nVirtKey >= VK_PRIOR) && (nVirtKey <= VK_DELETE))
    15931594      {
    1594          WORD numState = OSLibWinGetScanState(abWinVKeyToPMScan[VK_NUMLOCK].bPMScanCode) & 1;
     1595         WORD numState = OSLibWinGetScanState(auchWinVKeyToPMScan[VK_NUMLOCK].uchPMScanCode) & 1;
    15951596
    15961597         if(!numState) {
     
    16171618      }
    16181619
    1619       result = OSLibWinGetPhysKeyState(abWinVKeyToPMScan[nVirtKey].bPMScanCode);
     1620      result = OSLibWinGetPhysKeyState(auchWinVKeyToPMScan[nVirtKey].uchPMScanCode);
    16201621      if(nVirtKey2) {
    1621           result |= OSLibWinGetPhysKeyState(abWinVKeyToPMScan[nVirtKey2].bPMScanCode);
     1622          result |= OSLibWinGetPhysKeyState(auchWinVKeyToPMScan[nVirtKey2].uchPMScanCode);
    16221623      }
    16231624      return result;
Note: See TracChangeset for help on using the changeset viewer.