Merge pull request #86 from SHADE-DP/SP3-10-input-management

Fixed timing of memcpy of keys to keysLast

This in turn fixes GetKeyDown() and GetKeyUp() as the input manager now knows changes of keys between the last frame and current frame.
This commit is contained in:
XiaoQiDigipen 2022-10-14 01:54:20 +08:00 committed by GitHub
commit ec99a6f0f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -44,6 +44,9 @@ namespace SHADE
void SHInputManager::UpdateInput(double dt) noexcept void SHInputManager::UpdateInput(double dt) noexcept
{ {
//Keyboard and Mouse Buttons//////////////////////////////////////////////// //Keyboard and Mouse Buttons////////////////////////////////////////////////
//Write to lastKeys
memcpy(keysLast, keys, sizeof(keys));
//Poll //Poll
unsigned char keyboardState[MAX_KEYS]; unsigned char keyboardState[MAX_KEYS];
//if (GetKeyboardState(keyboardState) == false) return; //if (GetKeyboardState(keyboardState) == false) return;
@ -96,9 +99,6 @@ namespace SHADE
} }
} }
//Write to lastKeys
memcpy(keysLast, keys, sizeof(keys));
//Mouse Positioning///////////////////////////////////// //Mouse Positioning/////////////////////////////////////
//https://stackoverflow.com/a/6423739 //https://stackoverflow.com/a/6423739