- Change InputState::KeyStatus to be a FixedBitArray object.

This commit is contained in:
Mitchell Richters 2023-04-05 12:57:48 +10:00
parent 2658af9fd0
commit c4bd550483

View file

@ -15,7 +15,7 @@
class InputState
{
uint8_t KeyStatus[NUM_KEYS];
FixedBitArray<NUM_KEYS> KeyStatus;
bool AnyKeyStatus;
public:
@ -31,20 +31,19 @@ public:
return;
const int key = ev->data1;
const bool state = ev->type == EV_KeyDown;
KeyStatus[key] = (uint8_t)state;
KeyStatus.Set(key, ev->type == EV_KeyDown);
// Check if key is to be excluded from setting AnyKeyStatus.
const bool ignore = key == KEY_VOLUMEDOWN || key == KEY_VOLUMEUP ||
(key > KEY_LASTJOYBUTTON && key < KEY_PAD_LTHUMB_RIGHT);
if (state && !ignore)
if (KeyStatus[key] && !ignore)
AnyKeyStatus = true;
}
void ClearAllInput()
{
memset(KeyStatus, 0, sizeof(KeyStatus));
KeyStatus.Zero();
AnyKeyStatus = false;
buttonMap.ResetButtonStates(); // this is important. If all input is cleared, the buttons must be cleared as well.
}