I'm trying to make a UI system that adapts images for key binding depending on the keyboard type (azerty/qwerty/etc).

For the moment I've done the binding with DirectInput Key Codes so it does not depend on the type of keyboard, so that part is OK.

But for the choice of UI image to display I face an issue.

The nearest solution I have is to translate the tszName of DIDEVICEOBJECTINSTANCE to ASCII or Virtual-Key Codes and use this code to find the appropriate image for my UI. But tszName is localized depending on the device (eg. the tszName of a french keyboard will return "ESPACE" instead of "SPACE")

So I haven't found a way to bypass this localization in tszName to get an unique code that's consistent across devices with similar keys. Have you some idea?


1 Answer 1


I finally found two answers : First one, I didn't get that DirectInput Key Codes are called ScanCode. So with that in mind there is this answer wich is linked . So the use of MapVirtualKeyEx translate my Scan Code into VirtualCode and I choose the my UI asset with that code.

The other mean will be to create juste the background of UI asset without any string in it and use the DIDEVICEOBJECTINSTANCE.tszName to fill it.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .