Jump to content
  • Advertisement
Sign in to follow this  
Vanderry

[DX9] Textual input from keyboard state?

This topic is 3050 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

Hi everyone ! I'm currently working on a GUI for a game engine of mine and it just occurred to me that I don't really know how to extract textual data from the keyboard state array I maintain using GetDeviceState(). Well, I know I could check for "DIK"-macro matches using a big-ass switch, but surely there must be a smoother way? I would very much like to be able to recognize capital letter input (shift-modified) if possible since it is a textbox-like item for inserting character names and the likes. I thought I shouldn't provide any of my source code since it is pretty stupid so far but my idea was to check for keyboard input every time the GUI-component's Update() method is called and if any - add to it's private string both to display while typing and to pass on when the user is done. If anyone might be able to help me solve this I'd be very grateful :)

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by SiCrane
Why not just process the WM_CHAR or WM_UNICHAR window messages?


I guess my current Input class might be a bit too simple for this case. It could be extended to read input from there, but does that take into account when a character key is modified by shift?

Edit: As far to my knowledge I would have to check individually for the shift keydown and subtract 32 from the other pressed key, but this would only work in the event of an alphabetical key being pressed.

[Edited by - Vanderry on March 12, 2010 6:51:30 PM]

Share this post


Link to post
Share on other sites
To conclude this thread I found the solution in an article here on GameDev. Wish I had found it before I started the thread but just for future reference, there it is x)

Share this post


Link to post
Share on other sites
WM_CHAR/WM_UNICHAR will take things like the shift key + keyboard layout + language settings into account. It basically gives you the character that you would want to ultimately display in a text box.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!