Zero out arrays in input manager #164

Merged
mushgunAX merged 6 commits from SP3-10-input-management into main 2022-11-02 22:35:57 +08:00
1 changed files with 17 additions and 15 deletions

View File

@ -25,16 +25,16 @@ namespace SHADE
std::map<std::string, SHInputManager::SHLogicalBindingData> SHInputManager::bindings;
unsigned SHInputManager::keyCount = 0;
bool SHInputManager::keys[MAX_KEYS];
bool SHInputManager::keysLast[MAX_KEYS];
double SHInputManager::keysHeldTime[MAX_KEYS];
double SHInputManager::keysReleasedTime[MAX_KEYS];
bool SHInputManager::keys[MAX_KEYS] = {};
bool SHInputManager::keysLast[MAX_KEYS] = {};
double SHInputManager::keysHeldTime[MAX_KEYS] = {};
double SHInputManager::keysReleasedTime[MAX_KEYS] = {};
unsigned SHInputManager::keyToggleCount = 0;
bool SHInputManager::keysToggle[MAX_KEYS];
bool SHInputManager::keysToggleLast[MAX_KEYS];
double SHInputManager::keysToggleOnTime[MAX_KEYS];
double SHInputManager::keysToggleOffTime[MAX_KEYS];
bool SHInputManager::keysToggle[MAX_KEYS] = {};
bool SHInputManager::keysToggleLast[MAX_KEYS] = {};
double SHInputManager::keysToggleOnTime[MAX_KEYS] = {};
double SHInputManager::keysToggleOffTime[MAX_KEYS] = {};
int SHInputManager::mouseScreenX = 0;
int SHInputManager::mouseScreenY = 0;
@ -46,11 +46,11 @@ namespace SHADE
int SHInputManager::mouseWheelVerticalDeltaPoll = 0;
unsigned char SHInputManager::controllersConnectedCount = 0;
unsigned SHInputManager::controllersInputCount[XUSER_MAX_COUNT];
unsigned SHInputManager::controllersButtonCount[XUSER_MAX_COUNT];
short SHInputManager::controllers[XUSER_MAX_COUNT][MAX_CONTROLLER_INPUT];
short SHInputManager::controllersLast[XUSER_MAX_COUNT][MAX_CONTROLLER_INPUT];
double SHInputManager::controllersHeldTime[XUSER_MAX_COUNT][MAX_CONTROLLER_INPUT];
unsigned SHInputManager::controllersInputCount[XUSER_MAX_COUNT] = {};
unsigned SHInputManager::controllersButtonCount[XUSER_MAX_COUNT] = {};
short SHInputManager::controllers[XUSER_MAX_COUNT][MAX_CONTROLLER_INPUT] = {};
short SHInputManager::controllersLast[XUSER_MAX_COUNT][MAX_CONTROLLER_INPUT] = {};
double SHInputManager::controllersHeldTime[XUSER_MAX_COUNT][MAX_CONTROLLER_INPUT] = {};
double SHInputManager::controllersReleasedTime[XUSER_MAX_COUNT][MAX_CONTROLLER_INPUT];
//Internal helper function for splitting between inputs
@ -106,9 +106,11 @@ namespace SHADE
memcpy(keysLast, keys, sizeof(keys));
//Poll
unsigned char keyboardState[MAX_KEYS];
unsigned char keyboardState[MAX_KEYS] = {};
SecureZeroMemory(keyboardState, sizeof(keyboardState));
//if (GetKeyboardState(keyboardState) == false) return;
SHASSERT(GetKeyboardState(keyboardState), "SHInputManager:GetKeyboardState() failed ({})", GetLastError());
bool keyboardStateGot = GetKeyboardState(keyboardState);
SHASSERT(keyboardStateGot, "SHInputManager:GetKeyboardState() failed ({})", GetLastError());
keyCount = 0;
keyToggleCount = 0;
for (size_t i = 0; i < MAX_KEYS; ++i)