From a6ec540bf4753095356ad6c005bec9672b2501f3 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Thu, 19 Sep 2019 13:33:19 -0700 Subject: [PATCH 1/3] Refactor to move duplicated definition into ATMegaKeyboard.h Signed-off-by: Jesse Vincent --- src/kaleidoscope/hardware/ATMegaKeyboard.h | 1 + src/kaleidoscope/hardware/kbdfans/KBD4x.h | 1 - src/kaleidoscope/hardware/olkb/Planck.h | 1 - src/kaleidoscope/hardware/softhruf/Splitography.h | 1 - src/kaleidoscope/hardware/technomancy/Atreus.h | 1 - src/kaleidoscope/hardware/technomancy/Atreus2.h | 1 - 6 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/kaleidoscope/hardware/ATMegaKeyboard.h b/src/kaleidoscope/hardware/ATMegaKeyboard.h index 54cc51dd..e4874146 100644 --- a/src/kaleidoscope/hardware/ATMegaKeyboard.h +++ b/src/kaleidoscope/hardware/ATMegaKeyboard.h @@ -50,6 +50,7 @@ struct cRGB { static const int8_t matrix_columns = NUM_ARGS(COL_PINS_); \ static constexpr uint8_t matrix_row_pins[matrix_rows] = ROW_PINS_; \ static constexpr uint8_t matrix_col_pins[matrix_columns] = COL_PINS_; \ + typedef MatrixAddr KeyAddr; \ \ static uint16_t previousKeyState_[matrix_rows]; \ static uint16_t keyState_[matrix_rows]; \ diff --git a/src/kaleidoscope/hardware/kbdfans/KBD4x.h b/src/kaleidoscope/hardware/kbdfans/KBD4x.h index b1c4a13c..cd5dda9d 100644 --- a/src/kaleidoscope/hardware/kbdfans/KBD4x.h +++ b/src/kaleidoscope/hardware/kbdfans/KBD4x.h @@ -45,7 +45,6 @@ class KBD4x: public kaleidoscope::hardware::ATMegaKeyboard { static constexpr int8_t led_count = 0; - typedef MatrixAddr KeyAddr; static constexpr int8_t numKeys() { return matrix_columns * matrix_rows; } diff --git a/src/kaleidoscope/hardware/olkb/Planck.h b/src/kaleidoscope/hardware/olkb/Planck.h index 47540244..680527d6 100644 --- a/src/kaleidoscope/hardware/olkb/Planck.h +++ b/src/kaleidoscope/hardware/olkb/Planck.h @@ -42,7 +42,6 @@ class Planck: public kaleidoscope::hardware::ATMegaKeyboard { static constexpr int8_t led_count = 0; - typedef MatrixAddr KeyAddr; static constexpr int8_t numKeys() { return matrix_columns * matrix_rows; } diff --git a/src/kaleidoscope/hardware/softhruf/Splitography.h b/src/kaleidoscope/hardware/softhruf/Splitography.h index 1078a8a3..0ab8f2cd 100644 --- a/src/kaleidoscope/hardware/softhruf/Splitography.h +++ b/src/kaleidoscope/hardware/softhruf/Splitography.h @@ -51,7 +51,6 @@ class Splitography: public kaleidoscope::hardware::ATMegaKeyboard { static constexpr int8_t led_count = 0; - typedef MatrixAddr KeyAddr; static constexpr int8_t numKeys() { return matrix_columns * matrix_rows; } diff --git a/src/kaleidoscope/hardware/technomancy/Atreus.h b/src/kaleidoscope/hardware/technomancy/Atreus.h index 4e5fb477..46900f68 100644 --- a/src/kaleidoscope/hardware/technomancy/Atreus.h +++ b/src/kaleidoscope/hardware/technomancy/Atreus.h @@ -65,7 +65,6 @@ class Atreus: public kaleidoscope::hardware::ATMegaKeyboard { static constexpr int8_t led_count = 0; - typedef MatrixAddr KeyAddr; static constexpr int8_t numKeys() { return matrix_columns * matrix_rows; } diff --git a/src/kaleidoscope/hardware/technomancy/Atreus2.h b/src/kaleidoscope/hardware/technomancy/Atreus2.h index 170a7d61..a61f6930 100644 --- a/src/kaleidoscope/hardware/technomancy/Atreus2.h +++ b/src/kaleidoscope/hardware/technomancy/Atreus2.h @@ -43,7 +43,6 @@ class Atreus2: public kaleidoscope::hardware::ATMegaKeyboard { ) static constexpr int8_t led_count = 0; - typedef MatrixAddr KeyAddr; static constexpr int8_t numKeys() { return matrix_columns * matrix_rows; } From 8d9ff159376c92cd57bb72e75b84218821c8d296 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Thu, 19 Sep 2019 15:09:19 -0700 Subject: [PATCH 2/3] Switch to using the globally defined KeyAddr, rather than the dummy one defined in the Hardware.h baseclass Signed-off-by: Jesse Vincent --- src/kaleidoscope/hardware/ATMegaKeyboard.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/kaleidoscope/hardware/ATMegaKeyboard.cpp b/src/kaleidoscope/hardware/ATMegaKeyboard.cpp index 34ce075b..d8a6b410 100644 --- a/src/kaleidoscope/hardware/ATMegaKeyboard.cpp +++ b/src/kaleidoscope/hardware/ATMegaKeyboard.cpp @@ -80,7 +80,7 @@ bool ATMegaKeyboard::isKeyswitchPressed(KeyAddr key_addr) { bool ATMegaKeyboard::isKeyswitchPressed(uint8_t keyIndex) { keyIndex--; - return isKeyswitchPressed(KeyAddr(keyIndex)); + return isKeyswitchPressed(::KeyAddr(keyIndex)); } @@ -100,7 +100,7 @@ bool ATMegaKeyboard::wasKeyswitchPressed(KeyAddr key_addr) { bool ATMegaKeyboard::wasKeyswitchPressed(uint8_t keyIndex) { keyIndex--; - return wasKeyswitchPressed(KeyAddr(keyIndex)); + return wasKeyswitchPressed(::KeyAddr(keyIndex)); } @@ -110,8 +110,7 @@ void __attribute__((optimize(3))) ATMegaKeyboard::actOnMatrixScan() { uint8_t keyState = (bitRead(KeyboardHardware.previousKeyState_[row], col) << 0) | (bitRead(KeyboardHardware.keyState_[row], col) << 1); if (keyState) { - //handleKeyswitchEvent(Key_NoKey, KeyAddr(row, col), keyState); - handleKeyswitchEvent(Key_NoKey, row, col, keyState); + handleKeyswitchEvent(Key_NoKey, ::KeyAddr(row, col), keyState); } } KeyboardHardware.previousKeyState_[row] = KeyboardHardware.keyState_[row]; From 56c1fa9ccab4f7c3390d04ceeec344f984134a1b Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Thu, 19 Sep 2019 19:38:52 -0700 Subject: [PATCH 3/3] astyle Signed-off-by: Jesse Vincent --- src/kaleidoscope/hardware/ATMegaKeyboard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kaleidoscope/hardware/ATMegaKeyboard.cpp b/src/kaleidoscope/hardware/ATMegaKeyboard.cpp index d8a6b410..85b3a292 100644 --- a/src/kaleidoscope/hardware/ATMegaKeyboard.cpp +++ b/src/kaleidoscope/hardware/ATMegaKeyboard.cpp @@ -110,7 +110,7 @@ void __attribute__((optimize(3))) ATMegaKeyboard::actOnMatrixScan() { uint8_t keyState = (bitRead(KeyboardHardware.previousKeyState_[row], col) << 0) | (bitRead(KeyboardHardware.keyState_[row], col) << 1); if (keyState) { - handleKeyswitchEvent(Key_NoKey, ::KeyAddr(row, col), keyState); + handleKeyswitchEvent(Key_NoKey, ::KeyAddr(row, col), keyState); } } KeyboardHardware.previousKeyState_[row] = KeyboardHardware.keyState_[row];