Jump to content
  • Advertisement
Sign in to follow this  
jblevins1991

input system

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

void input::init keys(int keys)
{
for(int i=0;i>256;++i)
{
keys;
}
keys[0];
keys[1];
keys[2];
....more keys
}

i am looking for a way to assign a key to an element of this array. so i could make keys[0] store the 'a' key. can somebody point me in the right direction?

(inspired by id tech engine :D)

Share this post


Link to post
Share on other sites
Advertisement
void input::init keys(int keys)
{
for(int i=0;i>256;++i)
{
keys;
}
keys[0];
keys[1];
keys[2];
//....more keys
}

For a start, I am not well aware of what this code is intended to do. Perhaps operator[] is overloaded? I have no idea of how ID tech manage those things.
2nd: please take note there's no such thing as 'a' key, being 'a' a character that can be generated by various methods. I strongly suggest to separate the notion of button from the notion of characters. It could look like

keys[0] = KBTN_A;

Does this help you? Probably not. I'm afraid you need to elaborate your questions.

Share this post


Link to post
Share on other sites

i am looking for a way to assign a key to an element of this array. so i could make keys[0] store the 'a' key. can somebody point me in the right direction?


Are you asking how to poll the keyboard? If so, on what platform. On Windows you might use DirectInput.

Or are you asking what kind of data structures might be used for configurable key mapping?

Share this post


Link to post
Share on other sites
Maybe you can be inspired by this too: http://www.gamedev.n...y-binding-in-c/

@deksheikh: Probably ID Tech .... by ID Software. If this was the OpenGL forum, I'd say you should know that! smile.png , but here I won't nag...

Anyways, unless you want a way to store or some pattern to fire or catch key events, polling they keys etc, this is not a very General question.
Keystrokes are very much platform(and framework) specific, actually. Also, the only thing I can spot that even remotely connects ID Tech with keybindings is that
they're using them. Their first game with Keybindings was Quake AFAIK, (Which was really using the Quake Engine, as they didn't call it "ID Tech 1" back then)

Share this post


Link to post
Share on other sites

[quote name='jblevins1991' timestamp='1331335636' post='4920797']
i am looking for a way to assign a key to an element of this array. so i could make keys[0] store the 'a' key. can somebody point me in the right direction?


Are you asking how to poll the keyboard? If so, on what platform. On Windows you might use DirectInput.

Or are you asking what kind of data structures might be used for configurable key mapping?
[/quote]
Be advised that MS has advised people to not use DirectInput for keyboards and instead use RawInput. http://msdn.microsoft.com/en-us/library/windows/desktop/ee418864(v=vs.85).aspx

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!