다음을 통해 공유


PFN_KEYBD_PDD_POWER_HANDLER (Windows CE 5.0)

Send Feedback

This function handles system power state changes. It is called by the upper layer.

typedef void (*PFN_KEYBD_PDD_POWER_HANDLER)(  UINT uiPddId,  BOOL fTurnOff);

Parameters

  • uiPddId
    [in] Index of the PDD.
  • fTurnOff
    [in] TRUE indicates that the system is powering down. FALSE indicates that the system is powering up.

Return Values

None.

Remarks

This function runs in kernel context and assumes that interrupts are disabled because it works directly with microprocessor registers. It does not make any system calls or cause tasks to be rescheduled. This function is restricted to reading and writing to pre-allocated memory. Any subroutines called from this function must follow this restriction.

On receiving a power-down event, the sample driver empties the 8042-keyboard controller's data buffer. The following code example shows an implementation of the PFN_KEYBD_PDD_POWER_HANDLER function to actually control the power of the keyboard device; this function works in conjunction with PFN_KEYBD_DRIVER_POWER_HANDLER.

void
WINAPI
KeybdPdd_PowerHandler(
  BOOL  bOff
  )
{
  extern DWORD gdwIoBase;
  if ( bOff )
  {
    if ( KeyStateFlags == KeyStateDownFlag )
    {
      UCHAR ucKbdStatus, ucKbdData;

      // Because this function is invoked right after a key is pressed, the output buffer of
      // the keyboard must be cleaned until the corresponding key is released. Otherwise the
      // data in that buffer will prevent subsequent keystrokes from generating interrupts,
      // which might cause the keyboard to stop responding.
      if(gdwIoBase != 0) {
        do
        {
          ucKbdData = READ_PORT_UCHAR((PUCHAR)(gdwIoBase + 0x00));
        } while ( !(ucKbdData & scKeyUpMask) );
      }

      KeyStateFlags = 0;
      
      if(gdwIoBase != 0) {
        ucKbdStatus = READ_PORT_UCHAR((PUCHAR)(gdwIoBase + 0x04));
        while ( (ucKbdStatus & 0x21) == 0x01 )
        {
          ucKbdData = READ_PORT_UCHAR((PUCHAR)(gdwIoBase + 0x00));
          ucKbdStatus = READ_PORT_UCHAR((PUCHAR)(gdwIoBase + 0x04));
        }
      }
    }
  }
  return;
}

Requirements

OS Versions: Windows CE 1.0 and later.
Header: Keybdpdd.h.

See Also

PFN_KEYBD_DRIVER_POWER_HANDLER

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.