Changeset 9810 for trunk/src


Ignore:
Timestamp:
Feb 16, 2003, 4:31:12 PM (23 years ago)
Author:
sandervl
Message:

ToAscii, GetKeyState, GetAsyncKeyState & GetKeyboardState fixes

Location:
trunk/src/user32
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/Makefile

    r9001 r9810  
    1 # $Id: Makefile,v 1.104 2002-08-14 10:37:43 sandervl Exp $
     1# $Id: Makefile,v 1.105 2003-02-16 15:31:08 sandervl Exp $
    22
    33#
     
    4141$(OBJDIR)\wsprintf.obj \
    4242$(OBJDIR)\winkeyboard.obj \
     43$(OBJDIR)\oslibkbd.obj \
    4344$(OBJDIR)\winmouse.obj \
    4445$(OBJDIR)\winevent.obj \
  • trunk/src/user32/USER32.DEF

    r9523 r9810  
    1 ; $Id: USER32.DEF,v 1.75 2002-12-18 12:28:01 sandervl Exp $
     1; $Id: USER32.DEF,v 1.76 2003-02-16 15:31:08 sandervl Exp $
    22
    33LIBRARY USER32 INITINSTANCE TERMINSTANCE
     
    3030    Win32QueryClipbrdViewerChain= PMMERGE.5444
    3131    Win32QueryOpenClipbrdWindow = PMMERGE.5446
     32
     33    WINSETSCANSTATETABLE        = PMMERGE.3266
     34    WINGETSCANSTATE             = PMMERGE.3138
    3235
    3336;;;; Present in WGSS50
  • trunk/src/user32/dbglocal.cpp

    r9198 r9810  
    1 /* $Id: dbglocal.cpp,v 1.14 2002-09-03 12:34:01 sandervl Exp $ */
     1/* $Id: dbglocal.cpp,v 1.15 2003-02-16 15:31:09 sandervl Exp $ */
    22
    33/*
     
    9696"paint",
    9797"dragdrop",
    98 "oslibclip"
     98"oslibclip",
     99"oslibkbd"
    99100};
    100101//******************************************************************************
  • trunk/src/user32/dbglocal.h

    r9198 r9810  
    1 /* $Id: dbglocal.h,v 1.11 2002-09-03 12:34:01 sandervl Exp $ */
     1/* $Id: dbglocal.h,v 1.12 2003-02-16 15:31:09 sandervl Exp $ */
    22
    33/*
     
    9595#define DBG_dragdrop             73
    9696#define DBG_oslibclip            74
    97 #define DBG_MAXFILES             75
     97#define DBG_oslibkbd             75
     98#define DBG_MAXFILES             76
    9899
    99100extern USHORT DbgEnabledUSER32[DBG_MAXFILES];
  • trunk/src/user32/oslibwin.cpp

    r9694 r9810  
    1 /* $Id: oslibwin.cpp,v 1.138 2003-01-20 12:09:47 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.139 2003-02-16 15:31:10 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    315315//******************************************************************************
    316316//******************************************************************************
    317 LONG OSLibWinGetPhysKeyState(LONG scan)
    318 {
    319     return WinGetPhysKeyState(HWND_DESKTOP,scan);       
    320 }
    321 //******************************************************************************
    322 //******************************************************************************
    323317BOOL OSLibWinSetFocus(HWND hwndDeskTop,HWND hwndNewFocus, BOOL activate)
    324318{
     
    952946                      WinQuerySysValue( HWND_DESKTOP, SV_CYICON)));
    953947  return TRUE;
    954 }
    955 //******************************************************************************
    956 //******************************************************************************
    957 BOOL OSLibWinGetKeyboardStateTable(unsigned char *PMKeyState)
    958 {
    959   return WinSetKeyboardStateTable(HWND_DESKTOP, (PBYTE)PMKeyState, FALSE );
    960 }
    961 //******************************************************************************
    962 //******************************************************************************
    963 BOOL OSLibWinSetKeyboardStateTable(unsigned char *PMKeyState)
    964 {
    965   return WinSetKeyboardStateTable(HWND_DESKTOP, (PBYTE)PMKeyState, TRUE );
    966 }
    967 //******************************************************************************
    968 //******************************************************************************
    969 USHORT APIENTRY WinTranslateChar2( USHORT  /* Codepage (currently ignored) */
    970                                  , PUSHORT /* Ptr to char to translate     */
    971                                  , PULONG  /* Ptr to deadkey save info     */
    972                                  , USHORT  /* Translation option (TC_xxx)  */
    973                                  , PUSHORT /* Ptr to shift state (TCF_xxx) */
    974                                  );
    975 //******************************************************************************
    976 //******************************************************************************
    977 USHORT OSLibWinTranslateChar(USHORT usScanCode, ULONG type, USHORT shiftstate)
    978 {
    979   USHORT usResult;
    980   USHORT sel = GetFS();
    981 
    982   usResult = WinTranslateChar2(0, &usScanCode, NULL, type, &shiftstate);
    983   SetFS(sel);
    984   return usScanCode;
    985948}
    986949//******************************************************************************
  • trunk/src/user32/oslibwin.h

    r9598 r9810  
    1 /* $Id: oslibwin.h,v 1.71 2003-01-03 16:35:56 sandervl Exp $ */
     1/* $Id: oslibwin.h,v 1.72 2003-02-16 15:31:11 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    303303BOOL OSLibSetWindowMinPos(HWND hwnd, ULONG x, ULONG y);
    304304
    305 BOOL   OSLibWinGetKeyboardStateTable(unsigned char * PMKeyState);
    306 BOOL   OSLibWinSetKeyboardStateTable(unsigned char * PMKeyState);
    307 
    308 #define TCF_LSHIFT                 0x0001
    309 #define TCF_RSHIFT                 0x0002
    310 #define TCF_SHIFT                  (TCF_LSHIFT | TCF_RSHIFT)
    311 #define TCF_LCONTROL               0x0004
    312 #define TCF_RCONTROL               0x0008
    313 #define TCF_CONTROL                (TCF_LCONTROL | TCF_RCONTROL)
    314 #define TCF_ALT                    0x0010
    315 #define TCF_ALTGR                  0x0020
    316 #define TCF_CAPSLOCK               0x0040
    317 #define TCF_NUMLOCK                0x0080
    318 #define TCF_OEMSCANCODE            0x0100
    319 #define TCF_EXTENDEDKEY            0x0200
    320 
    321 #define TC_CHARTOSCANCODE          0
    322 #define TC_SCANCODETOCHAR          1
    323 #define TC_VIRTUALKEYTOSCANCODE    2
    324 #define TC_SCANCODETOVIRTUALKEY    3
    325 #define TC_SCANTOOEMSCAN           4
    326 #define TC_OEMSCANTOSCAN           5
    327 
    328 USHORT OSLibWinTranslateChar(USHORT usScanCode, ULONG type, USHORT shiftstate);
    329 
    330305#define HTOS_NORMAL                   0
    331306#define HTOS_TRANSPARENT              (-1)
  • trunk/src/user32/user32dbg.def

    r9523 r9810  
    1 ; $Id: user32dbg.def,v 1.8 2002-12-18 12:28:05 sandervl Exp $
     1; $Id: user32dbg.def,v 1.9 2003-02-16 15:31:11 sandervl Exp $
    22
    33LIBRARY USER32 INITINSTANCE TERMINSTANCE
     
    3030    Win32QueryClipbrdViewerChain= PMMERGE.5444
    3131    Win32QueryOpenClipbrdWindow = PMMERGE.5446
     32
     33    WINSETSCANSTATETABLE        = PMMERGE.3266
     34    WINGETSCANSTATE             = PMMERGE.3138
    3235
    3336;;;; Present in WGSS50
  • trunk/src/user32/winkeyboard.cpp

    r9689 r9810  
    1 /* $Id: winkeyboard.cpp,v 1.38 2003-01-17 16:35:38 sandervl Exp $ */
     1/* $Id: winkeyboard.cpp,v 1.39 2003-02-16 15:31:12 sandervl Exp $ */
    22/*
    33 * Win32 <-> PM key translation
     
    1717#include <stdio.h>
    1818#include <winkeyboard.h>
    19 #include "oslibwin.h"
     19#include "oslibkbd.h"
    2020#include <heapstring.h>
    2121#include <pmscan.h>
     
    415415/* 0x55 VK_U              */ , PMSCAN_U               , "U"
    416416/* 0x56 VK_V              */ , PMSCAN_V               , "V"
    417 /* 0x57 VK                */ , PMSCAN_W               , "W"
     417/* 0x57 VK_W              */ , PMSCAN_W               , "W"
    418418/* 0x58 VK_X              */ , PMSCAN_X               , "X"
    419419/* 0x59 VK_Y              */ , PMSCAN_Y               , "Y"
     
    861861                                     int nrkeys)
    862862{
     863   int pmvkey;
     864
     865#ifdef DEBUG
     866   for(int j=1;j<nrkeys;j++) {
     867       if(pmkey[j])
     868           dprintf2(("PM vkey %x state %x", j, pmkey[j]));
     869   }
     870#endif
     871
    863872   for(int i=1;i<nrkeys;i++) {
    864873       if(abWinVKeyToPMScan[i].bPMScanCode) {
    865             winkey[i] = pmkey[OSLibWinTranslateChar(abWinVKeyToPMScan[i].bPMScanCode, TC_SCANCODETOVIRTUALKEY, 0)];
     874            pmvkey = OSLibWinTranslateChar(abWinVKeyToPMScan[i].bPMScanCode, TC_SCANCODETOVIRTUALKEY, 0);
     875            if(pmvkey == 0) {
     876                dprintf2(("WinTranslateChar %x (%x) FAILED!!", i, abWinVKeyToPMScan[i].bPMScanCode));
     877            }
     878            winkey[i] = pmkey[pmvkey];
    866879       }
     880       else dprintf2(("key %x has no PM scancode", i));
    867881   }
    868882   winkey[VK_SHIFT]   = winkey[VK_LSHIFT] | winkey[VK_RSHIFT];
     
    970984BOOL WIN32API GetKeyboardState(PBYTE lpKeyState)
    971985{
     986#if 1
     987   int state;
     988   for(int i=0;i<256;i++) {
     989       state = GetKeyState(i);
     990       lpKeyState[i] = ((state & 0x8000) >> 8) | (state & 1);
     991       if(lpKeyState[i] & 0x80) {
     992           dprintf2(("Win key 0x%0x = %x", i, lpKeyState[i]));
     993       }
     994   }
     995   return TRUE;
     996#if 1
     997#else
     998   BYTE PMScanState[256];
     999   BOOL rc;
     1000   int  state;
     1001
     1002   memset(PMScanState, 0, sizeof(PMScanState));
     1003   memset(lpKeyState, 0, 256);
     1004
     1005   //
     1006   //OSLibWinGetKeyboardStateTable returns the state of PM virtual keys only and
     1007   //there are far fewer PM vkeys. (e.g. 0-9, A-Z are not included)
     1008   //So we need to use OSLibWinGetScanStateTable (WinSetScanState)
     1009   //
     1010   rc = OSLibWinGetScanStateTable((PBYTE)&PMScanState[0] );
     1011   if(!rc) {
     1012//       DebugInt3();
     1013       dprintf(("OSLibWinGetScanStateTable FAILED"));
     1014       return FALSE;
     1015   }
     1016   for(int i=0;i<256;i++) {
     1017       if(abWinVKeyToPMScan[i].bPMScanCode) {
     1018           lpKeyState[i] = PMScanState[abWinVKeyToPMScan[i].bPMScanCode];
     1019       }
     1020       if(lpKeyState[i] & 0x80) {
     1021           dprintf2(("Win key 0x%0x = %x", i, lpKeyState[i]));
     1022       }
     1023   }
     1024   //now process the mouse buttons (left, middle, right)
     1025   state = GetKeyState(VK_LBUTTON);
     1026   lpKeyState[VK_LBUTTON] = ((state & 0x8000) >> 8) | (state & 1);
     1027   state = GetKeyState(VK_MBUTTON);
     1028   lpKeyState[VK_MBUTTON] = ((state & 0x8000) >> 8) | (state & 1);
     1029   state = GetKeyState(VK_RBUTTON);
     1030   lpKeyState[VK_RBUTTON] = ((state & 0x8000) >> 8) | (state & 1);
     1031#ifdef DEBUG
     1032   if(lpKeyState[VK_LBUTTON]) {
     1033      dprintf2(("Win key 0x%0x = %x", VK_LBUTTON, lpKeyState[VK_LBUTTON]));
     1034   }
     1035   if(lpKeyState[VK_MBUTTON]) {
     1036      dprintf2(("Win key 0x%0x = %x", VK_MBUTTON, lpKeyState[VK_MBUTTON]));
     1037   }
     1038   if(lpKeyState[VK_RBUTTON]) {
     1039      dprintf2(("Win key 0x%0x = %x", VK_RBUTTON, lpKeyState[VK_RBUTTON]));
     1040   }
     1041#endif
     1042   return TRUE;
     1043#endif
     1044#else
    9721045 BYTE   PMKeyState[256];
    9731046 BOOL   rc;
     
    9991072  }
    10001073  return FALSE;
     1074#endif
    10011075}
    10021076//******************************************************************************
     
    11521226       if(lpbKeyState[VK_LSHIFT]   & 0x80) shiftstate |= TCF_LSHIFT;
    11531227       if(lpbKeyState[VK_RSHIFT]   & 0x80) shiftstate |= TCF_RSHIFT;
    1154        if(lpbKeyState[VK_SHIFT]    & 0x80) shiftstate |= TCF_SHIFT;
    11551228       if(lpbKeyState[VK_LCONTROL] & 0x80) shiftstate |= TCF_LCONTROL;
    11561229       if(lpbKeyState[VK_RCONTROL] & 0x80) shiftstate |= TCF_RCONTROL;
    1157        if(lpbKeyState[VK_CONTROL]  & 0x80) shiftstate |= TCF_CONTROL;
    11581230       if(lpbKeyState[VK_LMENU]    & 0x80) shiftstate |= TCF_ALT;
    11591231       if(lpbKeyState[VK_RMENU]    & 0x80) shiftstate |= TCF_ALTGR;
    1160        if(lpbKeyState[VK_MENU]     & 0x80) shiftstate |= TCF_ALT;
    11611232       if(lpbKeyState[VK_CAPITAL]  & 1)    shiftstate |= TCF_CAPSLOCK;
    11621233       if(lpbKeyState[VK_NUMLOCK]  & 1)    shiftstate |= TCF_NUMLOCK;
     
    13971468      return 0x0000;
    13981469  }
    1399   if (nVirtKey == VK_MENU)  return O32_GetKeyState(VK_LMENU) | O32_GetKeyState(VK_RMENU);
     1470
     1471  //If there's a PM scancode for this virtual key, then call WinGetScanState
     1472  //O32_GetKeyState converts windows virtual keys to PM virtual keys and there
     1473  //are far fewer PM vkeys. (e.g. 0-9, A-Z will fail)
     1474  if(nVirtKey < 256 && abWinVKeyToPMScan[nVirtKey].bPMScanCode)
     1475  {
     1476      INT  nVirtKey2 = 0;
     1477      WORD result;
     1478
     1479      if (nVirtKey == VK_MENU)  {
     1480          nVirtKey  = VK_LMENU;
     1481          nVirtKey2 = VK_RMENU;
     1482      }
     1483      else
     1484      if (nVirtKey == VK_CONTROL) {
     1485          nVirtKey  = VK_LCONTROL;
     1486          nVirtKey2 = VK_RCONTROL;
     1487      }
     1488      else
     1489      if (nVirtKey == VK_SHIFT) {
     1490          nVirtKey  = VK_LSHIFT;
     1491          nVirtKey2 = VK_RSHIFT;
     1492      }
     1493      result = OSLibWinGetScanState(abWinVKeyToPMScan[nVirtKey].bPMScanCode);
     1494      if(nVirtKey2) {
     1495          result |= OSLibWinGetScanState(abWinVKeyToPMScan[nVirtKey2].bPMScanCode);
     1496      }
     1497      return result;
     1498  }
     1499 
    14001500  return O32_GetKeyState(nVirtKey);
    14011501}
     
    14191519      return 0x0000;
    14201520  }
    1421   if (nVirtKey == VK_MENU)  return O32_GetAsyncKeyState(VK_LMENU) | O32_GetAsyncKeyState(VK_RMENU);
     1521
     1522  //If there's a PM scancode for this virtual key, then call WinGetPhysKeyState
     1523  //O32_GetAsyncKeyState converts windows virtual keys to PM virtual keys and there
     1524  //are far fewer PM vkeys. (e.g. 0-9, A-Z will fail)
     1525  if(nVirtKey < 256 && abWinVKeyToPMScan[nVirtKey].bPMScanCode)
     1526  {
     1527      INT  nVirtKey2 = 0;
     1528      WORD result;
     1529
     1530      if (nVirtKey == VK_MENU)  {
     1531          nVirtKey  = VK_LMENU;
     1532          nVirtKey2 = VK_RMENU;
     1533      }
     1534      else
     1535      if (nVirtKey == VK_CONTROL) {
     1536          nVirtKey  = VK_LCONTROL;
     1537          nVirtKey2 = VK_RCONTROL;
     1538      }
     1539      else
     1540      if (nVirtKey == VK_SHIFT) {
     1541          nVirtKey  = VK_LSHIFT;
     1542          nVirtKey2 = VK_RSHIFT;
     1543      }
     1544
     1545      result = OSLibWinGetPhysKeyState(abWinVKeyToPMScan[nVirtKey].bPMScanCode);
     1546      if(nVirtKey2) {
     1547          result |= OSLibWinGetPhysKeyState(abWinVKeyToPMScan[nVirtKey2].bPMScanCode);
     1548      }
     1549      return result;
     1550  }
     1551
    14221552  return O32_GetAsyncKeyState(nVirtKey);
    14231553}
     
    14261556UINT WIN32API MapVirtualKeyA(UINT uCode,  UINT uMapType)
    14271557{
    1428   dprintf(("imcompletely implemented"));
     1558  dprintf(("incompletely implemented"));
    14291559 
    14301560  /* A quick fix for Commandos, very incomplete */
     
    14511581UINT WIN32API MapVirtualKeyW(UINT uCode, UINT uMapType)
    14521582{
    1453   dprintf(("incorrectly implemented\n"));
     1583  dprintf(("incorrectly implemented"));
    14541584 
    14551585  // NOTE: This will not work as is (needs UNICODE support)
    1456   return O32_MapVirtualKey(uCode,uMapType);
     1586  return MapVirtualKeyA(uCode,uMapType);
    14571587}
    14581588/*****************************************************************************
Note: See TracChangeset for help on using the changeset viewer.