Jump to content
  • Advertisement

Archived

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

a2k

getasynckeystate()

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

hey, i''m having problems with this. what''s wrong? #include #include void main() { while(1) { if(GetAsyncKeyState(0x53)) //s cout << "s" << endl; else cout << "no input" << endl; } } it doesn''t read in the state, and it doesn''t show "s". what''s wrong with this? (win32 console app, no extra included libraries) a2k

Share this post


Link to post
Share on other sites
Advertisement
Try this:

if((GetAsyncKeyState(VK_SPACE)&0x8000)!=0)
{
cout<<"Foobar"<}

(I used space cause I knew it off the top of my head. The 0x8000 bit is to check the high bit of the return value, as mentioned in the docs.

Jesse Chounard

Share this post


Link to post
Share on other sites
thanks. i haven''t tried it yet, but i read about the high bit. the thing is though, is that i''ve used without the test bit in all my opengl apps, with no problem, but when i reduced it to just this code, it didn''t work. i guess i''ll be filtering all my keystate funx. thanks.

a2k

Share this post


Link to post
Share on other sites
i take that back. it didn't work. what's the deal? need some help... dying... i don't get it.
a2k


Edited by - a2k on 4/29/00 6:41:11 PM

Share this post


Link to post
Share on other sites
Darn, i have a good book that explained this function in detail, but im outta town right now, so ill get back to you. NO ONE ELSE POST, i wanna get all the credit .

Share this post


Link to post
Share on other sites
Well, I tested it, and GetAsyncKeyState() doesn''t function in a normal console app. The code Jesse posted is correct, btw. It does function the way Jesse posted in a true-blue Windows app.

I like food.

Share this post


Link to post
Share on other sites
okay, so it HAS to be a true win32 app? (that''s okay, i just don''t wanna get frustrated ever again.) and i suppose when i was using glut in console mode, it sorta "simulated" a true win32 app, cuz getasynckeystate seemed to work in my glut console apps...

a2k

Share this post


Link to post
Share on other sites
Yeah - from what little I know about OpenGL and GLUT, (and I''m probably wayyy off ), OpenGl needs a pure Win32 app, so GLUT just sets one up for you without you noticing.

Of course, I really shouldn''t talk about things I don''t know about. I''m afraid that if I talk any longer, I''ll start choking on my foot.

Trigon

I like food.

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.

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!