Jump to content
  • Advertisement

Archived

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

ArnoAtWork

Keyboard class

This topic is 5544 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 looking to implement a keyboard class for an engine. I try to find a good approach but I have several questions. Should I use a huge array to store state of all keys? Should I use a list of current pushed buttons, the other ones being in up state? Should I store state for real keys or there corresponding events? And in fact, if I use an array, how many keys exist? Thanks a lot.

Share this post


Link to post
Share on other sites
Advertisement
What language do you use? I''ll assume C++.
What API do you use?
I think there are 256 possible keys (at least NeHe uses that number).

Basically you can do anything you want =)

I''d not use the third method - the task of a keyboard class is to tell about the keyboard.

The array would be quite fast, and probably OK.
The list would consume less memory (although the size of the array wouldn''t be a lot either)
You can also use a std::map. Automatic mem allocation, you don''t have to worry about the number of keys, and quite simple to use. But probably also slowest.

(That''s what I think. I''m probably not right with everything)

You decide. Either of these should be OK.


"George W. Bush Geography Simplification Initiative"
More info on George W. Bush

My Homepage (C++ SDL OpenGL Game Programming) (Mirror)


I am a signature virus. Please add me to your signature so that I may multiply.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!