From 1d65c02f9f5516dfdbffb27966449202a95fab48 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sat, 17 Nov 2018 10:10:04 +0100 Subject: [PATCH] hardware/ATMegaKeyboard: Don't hardcode the list of keyboards Instead of guarding the ATMegaKeyboard files with an `#if` that hard-coded which keyboards are based on the class, guard them with `KALEIDOSCOPE_WITH_ATMEGA_KEYBOARD`, set by the main hardware headers. Those headers get included early, and are as such, a perfect way to guard these things. This way if we add a new keyboard using the base class, we don't have to modify the base class itself, and the new hardware plugin can be entirely self-contained. Signed-off-by: Gergely Nagy --- src/Kaleidoscope-Hardware-OLKB-Planck.h | 2 ++ src/Kaleidoscope-Hardware-Technomancy-Atreus.h | 2 ++ src/kaleidoscope/hardware/ATMegaKeyboard.cpp | 5 +++-- src/kaleidoscope/hardware/ATMegaKeyboard.h | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Kaleidoscope-Hardware-OLKB-Planck.h b/src/Kaleidoscope-Hardware-OLKB-Planck.h index a3e5938f..cfbd49af 100644 --- a/src/Kaleidoscope-Hardware-OLKB-Planck.h +++ b/src/Kaleidoscope-Hardware-OLKB-Planck.h @@ -17,4 +17,6 @@ */ #pragma once + +#define KALEIDOSCOPE_WITH_ATMEGA_KEYBOARD 1 #include "kaleidoscope/hardware/olkb/Planck.h" diff --git a/src/Kaleidoscope-Hardware-Technomancy-Atreus.h b/src/Kaleidoscope-Hardware-Technomancy-Atreus.h index f896d7ec..1f5eb6f6 100644 --- a/src/Kaleidoscope-Hardware-Technomancy-Atreus.h +++ b/src/Kaleidoscope-Hardware-Technomancy-Atreus.h @@ -17,4 +17,6 @@ */ #pragma once + +#define KALEIDOSCOPE_WITH_ATMEGA_KEYBOARD 1 #include "kaleidoscope/hardware/technomancy/Atreus.h" diff --git a/src/kaleidoscope/hardware/ATMegaKeyboard.cpp b/src/kaleidoscope/hardware/ATMegaKeyboard.cpp index 1e1130f5..2feaa996 100644 --- a/src/kaleidoscope/hardware/ATMegaKeyboard.cpp +++ b/src/kaleidoscope/hardware/ATMegaKeyboard.cpp @@ -15,9 +15,10 @@ * this program. If not, see . */ -#if ARDUINO_AVR_PLANCK || ARDUINO_AVR_ATREUS - #include "Kaleidoscope.h" + +#if KALEIDOSCOPE_WITH_ATMEGA_KEYBOARD + #include "kaleidoscope/hardware/ATMegaKeyboard.h" namespace kaleidoscope { diff --git a/src/kaleidoscope/hardware/ATMegaKeyboard.h b/src/kaleidoscope/hardware/ATMegaKeyboard.h index d87a4cbd..e63efdde 100644 --- a/src/kaleidoscope/hardware/ATMegaKeyboard.h +++ b/src/kaleidoscope/hardware/ATMegaKeyboard.h @@ -17,7 +17,7 @@ #pragma once -#if ARDUINO_AVR_PLANCK || ARDUINO_AVR_ATREUS +#if KALEIDOSCOPE_WITH_ATMEGA_KEYBOARD #include #include