From 2e48ea3a0e61185ce9dd6482fe1a793230f6cdf0 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 6 Aug 2017 08:29:24 +0200 Subject: [PATCH] masking: Use keydata_t instead of uint8_t[4] Since we have a nice keydata_t union, use that, to convey it even more clearly that we are mimicking the hand states in a way. Signed-off-by: Gergely Nagy --- src/Kaleidoscope-Hardware-Model01.cpp | 20 ++++++++++---------- src/Kaleidoscope-Hardware-Model01.h | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Kaleidoscope-Hardware-Model01.cpp b/src/Kaleidoscope-Hardware-Model01.cpp index 13b19350..d23e63bc 100644 --- a/src/Kaleidoscope-Hardware-Model01.cpp +++ b/src/Kaleidoscope-Hardware-Model01.cpp @@ -5,8 +5,8 @@ KeyboardioScanner Model01::leftHand(0); KeyboardioScanner Model01::rightHand(3); bool Model01::isLEDChanged = true; -uint8_t Model01::leftHandMask[4]; -uint8_t Model01::rightHandMask[4]; +keydata_t Model01::leftHandMask; +keydata_t Model01::rightHandMask; static constexpr uint8_t key_led_map[4][16] = { {3, 4, 11, 12, 19, 20, 26, 27, 36, 37, 43, 44, 51, 52, 59, 60}, @@ -209,9 +209,9 @@ void Model01::maskKey(byte row, byte col) { return; if (col >= 8) { - rightHandMask[row] |= 1 << (7 - (col - 8)); + rightHandMask.rows[row] |= 1 << (7 - (col - 8)); } else { - leftHandMask[row] |= 1 << (7 - col); + leftHandMask.rows[row] |= 1 << (7 - col); } } @@ -220,9 +220,9 @@ void Model01::unMaskKey(byte row, byte col) { return; if (col >= 8) { - rightHandMask[row] &= ~(1 << (7 - (col - 8))); + rightHandMask.rows[row] &= ~(1 << (7 - (col - 8))); } else { - leftHandMask[row] &= ~(1 << (7 - col)); + leftHandMask.rows[row] &= ~(1 << (7 - col)); } } @@ -231,15 +231,15 @@ bool Model01::isKeyMasked(byte row, byte col) { return false; if (col >= 8) { - return rightHandMask[row] & (1 << (7 - (col - 8))); + return rightHandMask.rows[row] & (1 << (7 - (col - 8))); } else { - return leftHandMask[row] & (1 << (7 - col)); + return leftHandMask.rows[row] & (1 << (7 - col)); } } void Model01::maskHeldKeys(void) { - memcpy(leftHandMask, leftHandState.rows, sizeof(leftHandMask)); - memcpy(rightHandMask, rightHandState.rows, sizeof(rightHandMask)); + memcpy(leftHandMask.rows, leftHandState.rows, sizeof(leftHandMask)); + memcpy(rightHandMask.rows, rightHandState.rows, sizeof(rightHandMask)); } HARDWARE_IMPLEMENTATION KeyboardHardware; diff --git a/src/Kaleidoscope-Hardware-Model01.h b/src/Kaleidoscope-Hardware-Model01.h index 04b41eb4..b652e66a 100644 --- a/src/Kaleidoscope-Hardware-Model01.h +++ b/src/Kaleidoscope-Hardware-Model01.h @@ -54,8 +54,8 @@ class Model01 { static KeyboardioScanner leftHand; static KeyboardioScanner rightHand; - static uint8_t leftHandMask[4]; - static uint8_t rightHandMask[4]; + static keydata_t leftHandMask; + static keydata_t rightHandMask; }; #define SCANBIT(row,col) ((uint32_t)1 << ((row) * 8 + (7 - (col))))