Translating Scan Codes to Virtual-Key Codes (Windows CE 5.0)
When a key is pressed, the keyboard controller writes the key's scan code into a buffer. A scan code is a number generated whenever a key is pressed or released. Each key on a keyboard has a unique scan code. The keyboard driver's platform development driver (PDD) relies on an interrupt to retrieve the scan code from the buffer. The keyboard driver's model device driver (MDD) converts the scan code to a virtual-key code.
Whether a keyboard transmits AT scan codes or XT scan codes depends on the keyboard. Standard PS/2 keyboard controllers convert XT scan codes into AT scan codes. Some hardware platforms that have PS/2-compatible keyboard connectors might not have controllers that perform the XT scan code to AT scan code translation. Language-specific scan code translation in the sample keyboard drivers is implemented using libraries.
Supporting languages on a hardware platform with a different type of keyboard controller requires that you write a new controller interface library, and, depending on your hardware, possibly an IST library. These new libraries can then be linked with the appropriate translation libraries to produce a complete keyboard driver. More extensive customization might be necessary for custom keyboards.
Note The Keyboard Layout Generator Tool produces Microsoft® Windows® CE input language and device layout source files for any PS/2 keyboard that Microsoft Windows XP supports. If the Keyboard Layout Generator tool or the XT scan code tables provided do not provide information for your specific keyboard, see Developing International Software, Second Edition, by Microsoft Press.
The following list shows the libraries that are combined to build a keyboard driver:
- Keyboard controller-specific library
- Keyboard interrupt service thread (IST)-handling library
- Scan code to virtual-key code translation library
- Virtual-key code to character translation library
- Virtual-key code remapping library
AT Scan Code Translation Libraries
The following table shows the location of the AT scan code to virtual-key code translation libraries for specified keyboard layouts in the %_WINCEROOT%\Public\Common\OAK\Drivers\Keybd\DeviceLayouts\PS2_AT directory. It also shows the language identifier (LANGID) for the libraries. The names of the subdirectories are derived from the input locale (HKL) code. In most cases, the keyboard names in the table corresponds to information in Developing International Software. However, the Japanese keyboard names correspond to their names in the Microsoft Platform Builder Catalog.
|AT keyboard layout||Subdirectory||LANGID|
|Japanese (IBM layout)||00010411||0x0411|
|Japanese (NEC layout)||00000411||0x0411|
|United States 101||00000409||0x0409|
XT Scan Code Translation Libraries
The following table provides links to Help topics for common keyboard layouts. These topics contain translations for various languages for XT scan code to virtual-key code and virtual-key code to Unicode characters. The table also provides the language identifiers (LANGIDs) and the input locale (HKL) codes for the XT scan code translation libraries. In most cases, the keyboard names in the table corresponds to information in Developing International Software.
|XT keyboard layout||LANGID||HKL|
|Brazilian (ABNT) Keyboard||0x0416||00000416|
|United Kingdom Keyboard||0x0809||00000809|
|United States 101 Keyboard||0x0409||00000409|
Send Feedback on this topic to the authors