bool CheckInput() { INPUT_RECORD InputRecord; // This structure holds our user input details DWORD Events=0; // This holds the number of events for input int bKeyDown = 0; // This tells us if we pressed DOWN a key HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE); // Create a handle for checking input // Read in the input from the user, storing the information into the InputRecord structure. ReadConsoleInput(hInput, &InputRecord, 1, &Events); // For Windows 2000 and up we need to check the keydown so we don't move twice bKeyDown = InputRecord.Event.KeyEvent.bKeyDown; // If we just hit a key from the keyboard, handle the input accordingly. if(InputRecord.EventType == KEY_EVENT && bKeyDown) { CheckKeyboardInput(InputRecord); return true; } // If we used the mouse in any way, let's handle those events if(InputRecord.EventType == MOUSE_EVENT) { CheckMouseInput(InputRecord); return true; } // We didn't do anything so don't draw again return false; }
bool CheckInput() { INPUT_RECORD InputRecord; // This structure holds our user input details DWORD Events=0; // This holds the number of events for input int bKeyDown = 0; // This tells us if we pressed DOWN a key HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE); // Create a handle for checking input // Read in the input from the user, storing the information into the InputRecord structure. ReadConsoleInput(hInput, &InputRecord, 1, &Events); // For Windows 2000 and up we need to check the keydown so we don't move twice bKeyDown = InputRecord.Event.KeyEvent.bKeyDown; // If we just hit a key from the keyboard, handle the input accordingly. if(InputRecord.EventType == KEY_EVENT && bKeyDown) { CheckKeyboardInput(InputRecord); return true; } //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // Since we do a check when the shift key is down, we most definitely need to // do a check for when the shift key is let go so that we know when the user // is ready to go to the destination map after setting the next exit tile. if(InputRecord.EventType == KEY_EVENT && !bKeyDown) { // Check if the key that was let up was the shift key, then reset the flag if(InputRecord.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT) g_bShiftKeyDown = false; } //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // If we used the mouse in any way, let's handle those events if(InputRecord.EventType == MOUSE_EVENT) { CheckMouseInput(InputRecord); return true; } // We didn't do anything so don't draw again return false; }
bool BaseApp::Run() { CheckKeyboardInput(); RenderFrame(); return true; }