Zero out arrays for input manager

This commit is contained in:
mushgunAX 2022-11-02 16:14:26 +08:00
parent 901e49cf1c
commit 6ab6cc15a9
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; std::map<std::string, SHInputManager::SHLogicalBindingData> SHInputManager::bindings;
unsigned SHInputManager::keyCount = 0; unsigned SHInputManager::keyCount = 0;
bool SHInputManager::keys[MAX_KEYS]; bool SHInputManager::keys[MAX_KEYS] = {};
bool SHInputManager::keysLast[MAX_KEYS]; bool SHInputManager::keysLast[MAX_KEYS] = {};
double SHInputManager::keysHeldTime[MAX_KEYS]; double SHInputManager::keysHeldTime[MAX_KEYS] = {};
double SHInputManager::keysReleasedTime[MAX_KEYS]; double SHInputManager::keysReleasedTime[MAX_KEYS] = {};
unsigned SHInputManager::keyToggleCount = 0; unsigned SHInputManager::keyToggleCount = 0;
bool SHInputManager::keysToggle[MAX_KEYS]; bool SHInputManager::keysToggle[MAX_KEYS] = {};
bool SHInputManager::keysToggleLast[MAX_KEYS]; bool SHInputManager::keysToggleLast[MAX_KEYS] = {};
double SHInputManager::keysToggleOnTime[MAX_KEYS]; double SHInputManager::keysToggleOnTime[MAX_KEYS] = {};
double SHInputManager::keysToggleOffTime[MAX_KEYS]; double SHInputManager::keysToggleOffTime[MAX_KEYS] = {};
int SHInputManager::mouseScreenX = 0; int SHInputManager::mouseScreenX = 0;
int SHInputManager::mouseScreenY = 0; int SHInputManager::mouseScreenY = 0;
@ -46,11 +46,11 @@ namespace SHADE
int SHInputManager::mouseWheelVerticalDeltaPoll = 0; int SHInputManager::mouseWheelVerticalDeltaPoll = 0;
unsigned char SHInputManager::controllersConnectedCount = 0; unsigned char SHInputManager::controllersConnectedCount = 0;
unsigned SHInputManager::controllersInputCount[XUSER_MAX_COUNT]; unsigned SHInputManager::controllersInputCount[XUSER_MAX_COUNT] = {};
unsigned SHInputManager::controllersButtonCount[XUSER_MAX_COUNT]; unsigned SHInputManager::controllersButtonCount[XUSER_MAX_COUNT] = {};
short SHInputManager::controllers[XUSER_MAX_COUNT][MAX_CONTROLLER_INPUT]; short SHInputManager::controllers[XUSER_MAX_COUNT][MAX_CONTROLLER_INPUT] = {};
short SHInputManager::controllersLast[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::controllersHeldTime[XUSER_MAX_COUNT][MAX_CONTROLLER_INPUT] = {};
double SHInputManager::controllersReleasedTime[XUSER_MAX_COUNT][MAX_CONTROLLER_INPUT]; double SHInputManager::controllersReleasedTime[XUSER_MAX_COUNT][MAX_CONTROLLER_INPUT];
//Internal helper function for splitting between inputs //Internal helper function for splitting between inputs
@ -106,9 +106,11 @@ namespace SHADE
memcpy(keysLast, keys, sizeof(keys)); memcpy(keysLast, keys, sizeof(keys));
//Poll //Poll
unsigned char keyboardState[MAX_KEYS]; unsigned char keyboardState[MAX_KEYS] = {};
SecureZeroMemory(keyboardState, sizeof(keyboardState));
//if (GetKeyboardState(keyboardState) == false) return; //if (GetKeyboardState(keyboardState) == false) return;
SHASSERT(GetKeyboardState(keyboardState), "SHInputManager:GetKeyboardState() failed ({})", GetLastError()); bool keyboardStateGot = GetKeyboardState(keyboardState);
SHASSERT(keyboardStateGot, "SHInputManager:GetKeyboardState() failed ({})", GetLastError());
keyCount = 0; keyCount = 0;
keyToggleCount = 0; keyToggleCount = 0;
for (size_t i = 0; i < MAX_KEYS; ++i) for (size_t i = 0; i < MAX_KEYS; ++i)