Partager via


Keyboard PDDs (Windows CE 5.0)

Send Feedback

The keyboard PDD is the platform-dependent code of the keyboard driver. Layout Manager is able to handle multiple, simultaneous keyboard PDDs, such as a PS/2 keyboard and a matrix keyboard, on the same device. The keyboard PDD contains initialization and power functions. It can use the common keyboard interrupt service thread (IST) or include its own. When the Graphics, Windowing, and Events Subsystem (GWES) initializes the keyboard driver, it initializes each PDD.

Each keyboard PDD has an entry function that returns a data structure containing a description of the PDD and function pointers. When Layout Manager initializes the PDD, the keyboard driver passes the PDD a unique identifier that the PDD can use to identify itself. This helps when multiple devices use the same PDD. For example, two separate PS/2 controllers.

Every PDD is in the same DLL as Layout Manager. You cannot add a PDD at run time.

You must specify the PDDs in the keyboard driver that require initialization. The NULL terminated g_rgpfnPddEntries array specifies the entry point of each PDD in the keyboard driver DLL that requires initialization. Entry functions might occur multiple times in the array if multiple keyboard controllers use the same PDD. The first entry in the array is the default PDD. MapVirtualKey uses this default PDD's device layout to convert scan codes to virtual keys.

Microsoft recommends setting the default PDD to a PS/2 entry to support HID keyboards. If your device does not have a PS/2 port, use the stub PS/2 PDD to minimize the size of your run-time image.

The following code example shows a declaration of a keyboard PDD entry point, and an initialized g_rgpfnPddEntries array.

typedef BOOL (*PFN_KEYBD_PDD_ENTRY)(
  UINT uiPddId, 
  PFN_KEYBD_EVENT pfnKeybdEvent,
  PKEYBD_PDD *ppKeybdPdd
);

PFN_KEYBD_PDD_ENTRY g_rgpfnPddEntries[] = {
  PS2Entry,
  MatrixEntry,
  NULL
};

When the PDD's IST executes, the IST sends the current keyboard event to the keyboard Layout Manager through the PFN_KEYBD_EVENT callback function that Layout Manager identifies to the PDD's entry function. The following code example shows this interface.

typedef struct tagKEYBD_PDD {
  WORD wPddMask;   // Matches the keyboard layout with its PDD
  LPCTSTR pszName; // Could be used to identify PDD to user
  PFN_KEYBD_PDD_POWER_HANDLER pfnPowerHandler;
  PFN_KEYBD_PDD_TOGGLE_LIGHTS pfnToggleLights;
} KEYBD_PDD, *PKEYBD_PDD;

typedef void (*PFN_KEYBD_EVENT)(
  UINT uiPddId,
  UINT32 uiScanCode,
  BOOL fKeyDown
);

Setting up the keyboard IST is one of the PDD entry function's responsibilities. With a PS/2 controller, the PDD entry function also sets up the mouse IST. The IST calls the keyboard event function in Layout Manager. Layout Manager passes this function to the PDD's entry function for each keyboard event. You can set up and use the generic keyboard IST by passing the keyboard driver's IST loop function a structure containing all required information.

The following code example shows applicable functions and structures for the generic keyboard IST.

typedef UINT (*PFN_KEYBD_PDD_GET_KEYBD_EVENT)(
  UINT uiPddId,
  UINT32 rguiScanCode[16],
  BOOL rgfKeyUp[16]
);

typedef struct tagKEYBD_IST {
  HANDLE hevInterrupt;
  DWORD dwSysIntr_Keybd;
  UINT uiPddId;
  PFN_KEYBD_PDD_GET_KEYBD_EVENT pfnGetKeybdEvent;
  PFN_KEYBD_EVENT pfnKeybdEvent;
} KEYBD_IST, *PKEYBD_IST;

BOOL KeybdIstLoop(
  PKEYBD_IST pKeybdIst
);

The following list shows typical IST processing:

  1. When the kernel's interrupt handler signals hevInterrupt, the generic IST calls the PDD's PFN_KEYBD_PDD_GET_KEYBD_EVENT function.

  2. The IST calls Layout Manager's keyboard event function for each event returned,

  3. The IST calls InterruptDone for dwSystIntr_Keybd.

  4. In response to calls to its keyboard event function, all auto-repeat logic occurs in Layout Manager.

    The IST and keyboard PDD are not involved with auto-repeat timings.

  5. Layout Manager calls the remapping function for that specific keyboard's current device layout.

Layout Manager calls each PDD's PFN_KEYBD_PDD_TOGGLE_LIGHTS function when an LED state must change.

Additionally, Layout Manager sends any HID keyboards an I/O control code (IOCTL), IOCTL_HID_SET_MODIFIERS, when an LED event occurs so that the HID keyboard's lights match the others. This occurs when GWES calls Layout Manager's PFN_KEYBD_DRIVER_VKEY_TO_UNICODE.

Layout Manager calls each PDD's power handler, PFN_KEYBD_PDD_POWER_HANDLER, with TRUE if powering off and FALSE if powering on.

See Also

Layout Manager

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.