Jump to content
  • Advertisement
Sign in to follow this  
White Rabbit

Pressing several keys at the same time.

This topic is 5460 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, I'm using GLUT and i can't get it to compute several keys at the same time, the callback receives just one key at a time, and it doesn't descriminate between keyup and keydown, so i don't really know how to do it. Does someone? [edit] AND, what is this glutKeyboardUpFunc(), that i read about in the opengl.org forums? I can see that there is a linux manual for it, but in the API specs, i can't find anything about it? Are the specs outdated(as GLUT) or is this funtion just working under linux? [/edit] Thanks. [Edited by - White Rabbit on October 11, 2004 10:37:08 AM]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I tend to avoid using the callback function for processing user input for exactly the same reason. I ended up writing an input handler class that uses the GetAsyncKeyState() function. Basically once a frame (or when ever i want to update it) i call an update function which loops through the 256 virtual keys and calls GetAsyncKeyState() on each one, filling an array of 256 shorts with the value. Then i can just call another function IsKeyPressed(VK_CODE) with the key i want to test and i just return the value of the short.


void Input::GetInput()
{
//save the key states
for(int i = 0; i KeyStates = GetAsyncKeyState(i);
}

bool Input::IsPressed(int _VirtualKeyCode)
{
return ((bool)(m_this->KeyStates[_VirtualKeyCode]));
}
[\code]

Hope this helps
--Ninj4D4n

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!