getasynckeystate()
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
------------------General Equation, this is Private Function reporting for duty, sir!a2k
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
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
Website - Third Party Ninjas | Twitter - twitter.com/Chounard
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
a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
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
a2k
Edited by - a2k on 4/29/00 6:41:11 PM
------------------General Equation, this is Private Function reporting for duty, sir!a2k
please? any ideas?
a2k
a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
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 .
outta town?!? okay, maybe i can wait...
a2k
a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
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.
I like food.
I like food.
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
a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
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.
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.
I like food.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement