Jump to content
  • Advertisement
Sign in to follow this  
Laccolith

Game Input

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

Okay, so right now my game is using DirectInput and I have it working in my own class and it works all right. But I want to switch to using windows messages however I cant think of a nice way of encapsulating it. Specifically how do I get the key states from the windows messages into my class and store them in a way that I can then use functions in the rest of my code to check if a key is down. Currently I have functions like KeyIsDownNow(DIK_A) that return whether its down or not as well as similar functions that return if the key has only been pressed this frame. The next thing is I would like to implement it in a way that the game code can ask iskeydown(shootkey) so that I can change "shootkey" in a settings file.

Share this post


Link to post
Share on other sites
Advertisement
If you want to emulate that functionality in your own class, the easy way would be to create your own array and set the values appropriately in WM_KEYDOWN and WM_KEYUP. To allow dynamic bindings of your keys to actions, you can create an enumeration for your action types and then create a map of some sort (in C++, std::map, unordered_map or hash_map would all work) for you actions to key codes and then use the map to index your array.

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!