DX Input and Key Descriptions ???

Started by
1 comment, last by hebertjo 23 years, 11 months ago
I am trying to use GetKeyNameText() to return to me a textual descrption of the last key the user presses. This works great for most keys but some keys return nothing, most notably the arrow keys. This is what I''m doing: char desc[64] = {''\0''}; LONG key = m_lastKey; // Say this is DIK_UPARROW int num = GetKeyNAmeText(key << 16, desc, 64); If I press the TAB key the ''desc'' buffer is "TAB" but if I press an arrow key the ''desc'' buffer is blank. I want to be sure that if I use this function that I will receive a descrpition fo all keys on all keyboards. Is this unrealistic? Should I store my own desciptions? Thanks for any help, hebertjo
hebertjo
Advertisement
Are you using DirectInput? If you are, then you can''t use GetKeyNameText unless you set up a converter function between the DIK_ codes and Windows virtual key codes. Basically, my question is how do you get the m_lastKey value in your code snippet?

If you look at the DIK_XXX mappings they follow the Windows scan code mappings. GetKeyNameText() take a scan_code as input. As I said this works for most of the keys. Yes I''am using DirectInput.

You can use MapVirtualKey() to translate between scan_codes and virtual key codes but I tried that without any luck.

To get the m_lastKey you run through the list of DIK_XXX codes and if one is pressed set that to m_lastKey.

The question still stands: Do I need to write my own text descriptions for every key or can I reliable leveragr off of Windows?

hebertjo
hebertjo

This topic is closed to new replies.

Advertisement