Sign in to follow this  
Laccolith

Game Input

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this