Ignore:
Timestamp:
Oct 18, 2000, 10:12:46 PM (25 years ago)
Author:
sandervl
Message:

ToAscii implemenation started

File:
1 edited

Legend:

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

    r2803 r4498  
    1 /* $Id: winkeyboard.cpp,v 1.5 2000-02-16 14:28:27 sandervl Exp $ */
     1/* $Id: winkeyboard.cpp,v 1.6 2000-10-18 20:12:46 sandervl Exp $ */
    22/*
    33 * Win32 <-> PM key translation
     
    301301 BOOL   rc;
    302302
    303   dprintf(("USER32:  GetKeyboardState"));
     303  dprintf(("USER32: GetKeyboardState %x", lpKeyState));
    304304  rc = OSLibWinGetKeyboardStateTable((PBYTE)&PMKeyState );
    305305
     
    315315BOOL WIN32API SetKeyboardState(PBYTE lpKeyState)
    316316{
    317   dprintf(("USER32:  SetKeyboardState, not implemented"));
     317  dprintf(("USER32: SetKeyboardState %x not implemented", lpKeyState));
    318318  return(TRUE);
    319319}
     
    399399        return 1;
    400400}
    401 
    402 //******************************************************************************
    403 //******************************************************************************
     401/*****************************************************************************
     402 * Name      : int WIN32API ToAscii
     403 * Purpose   : The ToAscii function translates the specified virtual-key code
     404 *             and keyboard state to the corresponding Windows character or characters.
     405 * Parameters: UINT   uVirtKey    virtual-key code
     406 *             UINT   uScanCode   scan code
     407 *             PBYTE  lpbKeyState address of key-state array
     408 *             LPWORD lpwTransKey buffer for translated key
     409 *             UINT   fuState     active-menu flag
     410 * Variables :
     411 * Result    : 0 The specified virtual key has no translation for the current
     412 *               state of the keyboard.
     413 *             1 One Windows character was copied to the buffer.
     414 *             2 Two characters were copied to the buffer. This usually happens
     415 *               when a dead-key character (accent or diacritic) stored in the
     416 *               keyboard layout cannot be composed with the specified virtual
     417 *               key to form a single character.
     418 * Remark    :
     419 * Status    : UNTESTED STUB
     420 *
     421 * Author    : Patrick Haller [Thu, 1998/02/26 11:55]
     422 *****************************************************************************/
     423int WIN32API ToAscii(UINT   uVirtKey,
     424                     UINT   uScanCode,
     425                     PBYTE  lpbKeyState,
     426                     LPWORD lpwTransKey,
     427                     UINT   fuState)
     428{
     429  dprintf(("USER32:ToAscii (%u,%u,%08xh,%08xh,%u) not implemented.\n",
     430         uVirtKey,
     431         uScanCode,
     432         lpbKeyState,
     433         lpwTransKey,
     434         fuState));
     435
     436  INT ret;
     437
     438  if (uScanCode == 0) {
     439        /* This happens when doing Alt+letter : a fake 'down arrow' key press
     440           event is generated by windows. Just ignore it. */
     441        dprintf2(("scanCode=0, doing nothing"));
     442        return 0;
     443  }
     444  if (uScanCode & 0x8000)
     445  {
     446        dprintf2(("Key UP, doing nothing"));
     447        return 0;
     448  }
     449  /* We have a special case to handle : Shift + arrow, shift + home, ...
     450     X returns a char for it, but Windows doesn't. Let's eat it. */
     451  if(!(lpbKeyState[VK_NUMLOCK] & 0x01)  /* NumLock is off */
     452       && (lpbKeyState[VK_SHIFT] & 0x80) /* Shift is pressed */
     453       && (uVirtKey >= VK_0) && (uVirtKey >= VK_9))
     454  {
     455        *(char*)lpwTransKey = 0;
     456        ret = 0;
     457  }
     458  else       
     459  /* We have another special case for delete key (XK_Delete) on an
     460     extended keyboard. X returns a char for it, but Windows doesn't */
     461  if (uVirtKey == VK_DELETE)
     462  {
     463       *(char*)lpwTransKey = 0;
     464       ret = 0;
     465  }
     466  else {
     467       *(char*)lpwTransKey = uVirtKey;
     468       ret = 1;
     469  }
     470  return ret;
     471}
     472/*****************************************************************************
     473 * Name      : int WIN32API ToAsciiEx
     474 * Purpose   : The ToAscii function translates the specified virtual-key code
     475 *             and keyboard state to the corresponding Windows character or characters.
     476 * Parameters: UINT   uVirtKey    virtual-key code
     477 *             UINT   uScanCode   scan code
     478 *             PBYTE  lpbKeyState address of key-state array
     479 *             LPWORD lpwTransKey buffer for translated key
     480 *             UINT   fuState     active-menu flag
     481 *             HLK    hlk         keyboard layout handle
     482 * Variables :
     483 * Result    : 0 The specified virtual key has no translation for the current
     484 *               state of the keyboard.
     485 *             1 One Windows character was copied to the buffer.
     486 *             2 Two characters were copied to the buffer. This usually happens
     487 *               when a dead-key character (accent or diacritic) stored in the
     488 *               keyboard layout cannot be composed with the specified virtual
     489 *               key to form a single character.
     490 * Remark    :
     491 * Status    : UNTESTED STUB
     492 *
     493 * Author    : Patrick Haller [Thu, 1998/02/26 11:55]
     494 *****************************************************************************/
     495int WIN32API ToAsciiEx(UINT   uVirtKey,
     496                       UINT   uScanCode,
     497                       PBYTE  lpbKeyState,
     498                       LPWORD lpwTransKey,
     499                       UINT   fuState,
     500                       HKL    hkl)
     501{
     502  dprintf(("USER32:ToAsciiEx (%u,%u,%08xh,%08xh,%u,%08x) not implemented.\n",
     503         uVirtKey,
     504         uScanCode,
     505         lpbKeyState,
     506         lpwTransKey,
     507         fuState,
     508         hkl));
     509
     510  return (0);
     511}
     512//******************************************************************************
     513//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.