Multiple Keys Down in Visual C++
I am using keys to control the camera of my MFC OpenGL app. When a key is pressed, I incriment/decriment the appropriate rotation state variable and refresh the scene. The problem is that only one key can be pressed at a time. If you press and hold two keys, it only thinks you have the first one held down. Help.
void CGLSample1View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar==''A'') {
...
} else if(nChar==''D'') {
...
} else if(nChar==''W'') {
...
} else if(nChar==''S'') {
...
} else if(nChar==''E'') {
...
} else if(nChar==''Q'') {
...
}
CView::OnKeyDown(nChar, nRepCnt, nFlags);
}
while(my_life[years++]!=null) { code();}
int ispressed = GetAsyncKeyState() & 0x8000;
check it out...
Arkon
[QSoft Systems]
check it out...
Arkon
[QSoft Systems]
it won''t help to remove the else''s
cuz the nChar has just one value at a time
altough it can use logic or...but that something else
Arkon
[QSoft Systems]
cuz the nChar has just one value at a time
altough it can use logic or...but that something else
Arkon
[QSoft Systems]
Arkon, could you be a little more specific?
while(my_life[years++]!=null) { code();}
register a shortcut in the accelerator table.
then you will get an accelerator message if more keys are pressed at the same time.
or you can use direct input .. or GetAsyncKeyState()
{ Stating the obvious never helped any situation !! }
then you will get an accelerator message if more keys are pressed at the same time.
or you can use direct input .. or GetAsyncKeyState()
{ Stating the obvious never helped any situation !! }
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement