   Getting key Input(Windows)
  I was just wondering what is the best way to pass key inputs from my WinMain function to my various gamestates?  So far I have just created a global variables file and put the key arrays in there.Code for the array of keysextern boolkeys[256];Code for putting information into the arrayLRESULT CALLBACK WndProc(HWNDhWnd,// Handle For This WindowUINTuMsg,// Message For This WindowWPARAMwParam,// Additional Message InformationLPARAMlParam)// Additional Message Information{switch (uMsg)// Check For Windows Messages{case WM_ACTIVATE:// Watch For Window Activate Message{if (!HIWORD(wParam))// Check Minimization State{active=TRUE;// Program Is Active}else{active=FALSE;// Program Is No Longer Active}return 0;// Return To The Message Loop}case WM_SYSCOMMAND:// Intercept System Commands{switch (wParam)// Check System Calls{case SC_SCREENSAVE:// Screensaver Trying To Start?case SC_MONITORPOWER:// Monitor Trying To Enter Powersave?return 0;// Prevent From Happening}break;// Exit}case WM_CLOSE:// Did We Receive A Close Message?{PostQuitMessage(0);// Send A Quit Messagereturn 0;// Jump Back}case WM_KEYDOWN:// Is A Key Being Held Down?{keys[wParam] = TRUE;// If So, Mark It As TRUEreturn 0;// Jump Back}case WM_KEYUP:// Has A Key Been Released?{keys[wParam] = FALSE;// If So, Mark It As FALSEreturn 0;// Jump Back}case WM_SIZE:// Resize The OpenGL Window{ReSizeGLScene(LOWORD(lParam),HIWORD(lParam));// LoWord=Width, HiWord=Heightreturn 0;// Jump Back}}// Pass All Unhandled Messages To DefWindowProcreturn DefWindowProc(hWnd,uMsg,wParam,lParam);}So any suggestions?   
  Well, in my humble opinion, you're sort of on the right track, but I certainly wouldn't use the Windows message loop to process key inputs.It all depends on just how responsive you want your application to be of course, and maybe you don't need to have low latency between a key being pressed and some action taking place, but the Windows message loop can be a bit of an unpredictable place.If it just happens to be processing a lot of messages all at once then key inputs (which if memory serves me are low priority messages), may get left behind and a noticeable lag may appear.Without seeing your main message loop I can only assume that you are calling some sort of "GameMain" function if there are no Windows messages to be processed. If so, why not just shove the key handling logic there?But if this is your preferred method than it seems reasonably sound to me.   ;  This will work, but it will require all input-dependent subsystems to poll the keystate array every frame, which may or may not be what you're looking for. Another alternative is to hook the Windows messages into your own message system (if you have one). This would allow you to have some sort of InputInterpreter class that listens for raw key-press messages and turns them into game-specific commands for consumption by all the other subsystems.   ;  I personally useif(GetAsyncKeyState('2')&0x8000) //For exampleto determine if a key is pressed.  It is much faster than waiting for windows messaging to get around to it.   