Use the KeyboardHardware-provided key masking functions

Now that we have key masking functionality provided by KeyboardHardware, use
that instead of going with our own.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/389/head
Gergely Nagy 7 years ago
parent 42faebc873
commit 85336c5172

@ -28,8 +28,6 @@ uint16_t OneShot::hold_time_out = 250;
OneShot::state_t OneShot::state_; OneShot::state_t OneShot::state_;
OneShot::state_t OneShot::sticky_state_; OneShot::state_t OneShot::sticky_state_;
OneShot::state_t OneShot::pressed_state_; OneShot::state_t OneShot::pressed_state_;
uint32_t OneShot::left_mask_;
uint32_t OneShot::right_mask_;
Key OneShot::prev_key_; Key OneShot::prev_key_;
bool OneShot::should_cancel_ = false; bool OneShot::should_cancel_ = false;
bool OneShot::should_cancel_stickies_ = false; bool OneShot::should_cancel_stickies_ = false;
@ -81,42 +79,6 @@ void OneShot::cancelOneShot(uint8_t idx) {
injectNormalKey(idx, WAS_PRESSED); injectNormalKey(idx, WAS_PRESSED);
} }
void OneShot::mask(byte row, byte col) {
if (row >= ROWS || col >= COLS)
return;
if (col >= 8) {
col = col - 8;
right_mask_ |= SCANBIT(row, col);
} else {
left_mask_ |= SCANBIT(row, col);
}
}
void OneShot::unmask(byte row, byte col) {
if (row >= ROWS || col >= COLS)
return;
if (col >= 8) {
col = col - 8;
right_mask_ &= ~(SCANBIT(row, col));
} else {
left_mask_ &= ~(SCANBIT(row, col));
}
}
bool OneShot::isMasked(byte row, byte col) {
if (row >= ROWS || col >= COLS)
return false;
if (col >= 8) {
col = col - 8;
return right_mask_ & SCANBIT(row, col);
} else {
return left_mask_ & SCANBIT(row, col);
}
}
Key OneShot::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state) { Key OneShot::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state) {
uint8_t idx; uint8_t idx;
@ -125,9 +87,9 @@ Key OneShot::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_st
if (!state_.all) { if (!state_.all) {
if (!isOS(mapped_key)) { if (!isOS(mapped_key)) {
if (isMasked(row, col)) { if (KeyboardHardware.isKeyMasked(row, col)) {
if (keyToggledOff(key_state)) if (keyToggledOff(key_state))
unmask(row, col); KeyboardHardware.unMaskKey(row, col);
return Key_NoKey; return Key_NoKey;
} }
@ -192,7 +154,7 @@ Key OneShot::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_st
// ordinary key here, with some event // ordinary key here, with some event
if (keyIsPressed(key_state)) { if (keyIsPressed(key_state)) {
mask(row, col); KeyboardHardware.maskKey(row, col);
saveAsPrevious(mapped_key); saveAsPrevious(mapped_key);
should_cancel_ = true; should_cancel_ = true;
} }

@ -56,8 +56,6 @@ class OneShot : public KaleidoscopePlugin {
static state_t state_; static state_t state_;
static state_t sticky_state_; static state_t sticky_state_;
static state_t pressed_state_; static state_t pressed_state_;
static uint32_t left_mask_;
static uint32_t right_mask_;
static Key prev_key_; static Key prev_key_;
static bool should_cancel_; static bool should_cancel_;
static bool should_cancel_stickies_; static bool should_cancel_stickies_;
@ -66,10 +64,6 @@ class OneShot : public KaleidoscopePlugin {
static void activateOneShot(uint8_t idx); static void activateOneShot(uint8_t idx);
static void cancelOneShot(uint8_t idx); static void cancelOneShot(uint8_t idx);
static void mask(byte row, byte col);
static void unmask(byte row, byte col);
static bool isMasked(byte row, byte col);
static Key eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state); static Key eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state);
static void loopHook(bool is_post_clear); static void loopHook(bool is_post_clear);
}; };

Loading…
Cancel
Save