Who assigns the VK_OEM_* values in keyboards?

by Michael S. Kaplan, published on 2008/02/11 10:01 -05:00, original URI: http://blogs.msdn.com/b/michkap/archive/2008/02/11/7611812.aspx


Someone named Michael who is not me asked via the Contact link:

Hello,

I was interested in the process Windows uses for converting scan codes to virtual keys. Do you know anywhere where it is described precisely? Notably, things like what determines which scan codes get assigned to VK_OEM_x for a given keyboard layout (or whether it even differs, although I assume it must, since the VK_OEM_x must move around VK_OEM_PLUS and things).

Thanks

The actual mapping between scan code and virtual key is arbitrary and implicit in the individual keyboard layouts, and that Getting all you can out of a keyboard layout series (particularly Part 1 and Part 4) goes through how that mapping was built into the sample to get the actual mappings.

In order to reduce the complexity of things, MSKLC (Microsoft Keyboard Layout Creator) actually goes to great effort to not allow arbitrary changes to the mapping, though by letting you load any one existing layout you can inherit the arbitrary mapping that a specific, pre-existing keyboard layout uses.

And if you do want to specifically modify the mapping, you can open up a saved .KLC file directly, since the file's main layout table has as its first two columns the SC and VK values (which can be modified as needed). Though if one does down this road, try to avoid badnesses like duplicating SC or VK values. :-)

But as I pointed out at the beginning of the blog, there are no real rules determining what the mapping ought to be, so there is no real pattern to determining what it will be -- though the fact that MSKLC is used for the bulk of all new layouts, its limitations that try to stop random change here should have a positive impact on news layouts in future versions of Windows.

In prior versions before MSKLC existed, keyboard layouts were created by directly creating text files that look a lot like those .KLC files. They were mostly created by copying an existing one and changing key assignments, so the idea of VK_OEM_* values being inherited from other layouts was pretty common even back then....

 

This post brought to you by(U+1ed9, a.k.a. LATIN SMALL LETTER O WITH CIRCUMFLEX AND DOT BELOW)


no comments

Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

go to newer or older post, or back to index or month or day