I am converting an application that currently uses DirectInput to use RawInput instead. (DirectInput is a largely deprecated API.)
Unfortunately, despite RawInput being the recommended successor to DirectInput, it doesn't appear to provide keyboard data in quite the same way as DirectInput.
DirectInput uses DIK_*
constants (such as DIK_A
, DIK_RETURN
, etc...) to define specific physical keys on the keyboard. These keys are consistent across keyboard hardware but do not change depending on keyboard layout. (For example, DIK_Q
refers to whatever key is in the physical location that the Q key is at on a standard US-English QWERTY keyboard.) In my case, this is the desired behavior.
RawInput's RAWKEYBOARD
structure provides both a MakeCode
and a VKey
. I can't use VKey
because that changes depending on keyboard layout.
But the MakeCode
doesn't correspond 1:1 with the DIK_*
constants. In particular, it doesn't differentiate between left and right ctrl and alt keys, or most of the number pad keys from their other keys.
So my question is: Is it possible to use the contents of a RAWKEYBOARD
structure to figure out the equivalent DIK_*
constant? And assuming that the MakeCode
is part of figuring that out, can I rely on MakeCode
being constant across keyboard hardware, in the same way that the DIK_*
constants are?