Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

hebertjo

DX Input and Key Descriptions ???

This topic is 6931 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!