From b5c9794626c78a6f24303a3c864cfb7efcd25f4e Mon Sep 17 00:00:00 2001 From: Florian Fleissner Date: Wed, 20 Nov 2019 15:54:40 +0100 Subject: [PATCH 1/8] Enabled virtual build for Keyboardio/Model01 The Model01.h required some reordering of header includes and some forward defines of certain types that are used in property classes. Signed-off-by: Florian Fleissner --- src/kaleidoscope/device/ATmega32U4Keyboard.h | 7 +++- .../device/keyboardio/Model01.cpp | 10 ++++-- src/kaleidoscope/device/keyboardio/Model01.h | 35 +++++++++++++++---- src/kaleidoscope/device/keyboardio/twi.c | 2 +- src/kaleidoscope/device/keyboardio/twi.h | 3 ++ src/kaleidoscope/driver/mcu/ATmega32U4.h | 4 +++ 6 files changed, 49 insertions(+), 12 deletions(-) diff --git a/src/kaleidoscope/device/ATmega32U4Keyboard.h b/src/kaleidoscope/device/ATmega32U4Keyboard.h index b0d66fea..2f552440 100644 --- a/src/kaleidoscope/device/ATmega32U4Keyboard.h +++ b/src/kaleidoscope/device/ATmega32U4Keyboard.h @@ -17,7 +17,7 @@ #pragma once -#ifdef __AVR__ +#if defined(__AVR__) || defined(KALEIDOSCOPE_VIRTUAL_BUILD) #include #include "kaleidoscope/device/Base.h" @@ -46,6 +46,7 @@ struct ATmega32U4KeyboardProps : kaleidoscope::device::BaseProps { typedef kaleidoscope::driver::storage::AVREEPROM Storage; }; +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD template class ATmega32U4Keyboard : public kaleidoscope::device::Base<_DeviceProps> { public: @@ -53,6 +54,10 @@ class ATmega32U4Keyboard : public kaleidoscope::device::Base<_DeviceProps> { return Serial; } }; +#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +template +class ATmega32U4Keyboard; +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD } } diff --git a/src/kaleidoscope/device/keyboardio/Model01.cpp b/src/kaleidoscope/device/keyboardio/Model01.cpp index b8d1124c..ae6ecb62 100644 --- a/src/kaleidoscope/device/keyboardio/Model01.cpp +++ b/src/kaleidoscope/device/keyboardio/Model01.cpp @@ -16,11 +16,13 @@ */ #ifdef ARDUINO_AVR_MODEL01 -#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #include + +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #include #include +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD namespace kaleidoscope { namespace device { @@ -28,6 +30,8 @@ namespace keyboardio { constexpr uint8_t Model01LEDDriverProps::key_led_map[] PROGMEM; +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD + /********* Model01Hands *********/ struct Model01Hands { @@ -293,9 +297,9 @@ void Model01::enableHardwareTestMode() { KeyScanner::setKeyscanInterval(2); } +#endif + } } } - -#endif #endif diff --git a/src/kaleidoscope/device/keyboardio/Model01.h b/src/kaleidoscope/device/keyboardio/Model01.h index 37334359..ceac5c5d 100644 --- a/src/kaleidoscope/device/keyboardio/Model01.h +++ b/src/kaleidoscope/device/keyboardio/Model01.h @@ -21,15 +21,24 @@ #include -#include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h" -#include "KeyboardioScanner.h" - #define CRGB(r,g,b) (cRGB){b, g, r} +struct cRGB { + uint8_t b; + uint8_t g; + uint8_t r; +}; + +#include "kaleidoscope/device/ATmega32U4Keyboard.h" + #include "kaleidoscope/driver/keyscanner/Base.h" #include "kaleidoscope/driver/led/Base.h" +#include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h" #include "kaleidoscope/driver/bootloader/avr/Caterina.h" -#include "kaleidoscope/device/ATmega32U4Keyboard.h" + +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD +#include "KeyboardioScanner.h" +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD namespace kaleidoscope { namespace device { @@ -45,6 +54,7 @@ struct Model01LEDDriverProps : public kaleidoscope::driver::led::BaseProps { }; }; +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD class Model01LEDDriver : public kaleidoscope::driver::led::Base { public: static void syncLeds(); @@ -57,11 +67,15 @@ class Model01LEDDriver : public kaleidoscope::driver::led::Base { private: typedef Model01KeyScanner ThisType; @@ -96,8 +110,11 @@ class Model01KeyScanner : public kaleidoscope::driver::keyscanner::Base { public: static void setup(); @@ -112,8 +131,10 @@ class Model01 : public kaleidoscope::device::ATmega32U4Keyboard { static void enableHardwareTestMode(); }; -} -} +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD + +} // namespace keyboardio +} // namespace device EXPORT_DEVICE(kaleidoscope::device::keyboardio::Model01) diff --git a/src/kaleidoscope/device/keyboardio/twi.c b/src/kaleidoscope/device/keyboardio/twi.c index 38fe7e59..8b5416e0 100644 --- a/src/kaleidoscope/device/keyboardio/twi.c +++ b/src/kaleidoscope/device/keyboardio/twi.c @@ -18,7 +18,7 @@ Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts */ -#ifdef __AVR__ +#if defined(__AVR__) && !defined(KALEIDOSCOPE_VIRTUAL_BUILD) #define ENABLE_TWI_SLAVE_MODE 0 diff --git a/src/kaleidoscope/device/keyboardio/twi.h b/src/kaleidoscope/device/keyboardio/twi.h index e3753519..5b22cc40 100644 --- a/src/kaleidoscope/device/keyboardio/twi.h +++ b/src/kaleidoscope/device/keyboardio/twi.h @@ -21,6 +21,8 @@ #ifndef twi_h #define twi_h +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD + #include //#define ATMEGA8 @@ -52,5 +54,6 @@ void twi_reply(uint8_t); void twi_stop(void); void twi_releaseBus(void); +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #endif #endif diff --git a/src/kaleidoscope/driver/mcu/ATmega32U4.h b/src/kaleidoscope/driver/mcu/ATmega32U4.h index ad31c5fb..2a15fafd 100644 --- a/src/kaleidoscope/driver/mcu/ATmega32U4.h +++ b/src/kaleidoscope/driver/mcu/ATmega32U4.h @@ -23,6 +23,7 @@ namespace kaleidoscope { namespace driver { namespace mcu { +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD class ATmega32U4 : public kaleidoscope::driver::mcu::Base { public: void detachFromHost() { @@ -62,6 +63,9 @@ class ATmega32U4 : public kaleidoscope::driver::mcu::Base { void setup() {} }; +#else +typedef Base ATmega32U4; +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD } } From 57e7fe59b17d088332ec253b23feabd5e9d0ad15 Mon Sep 17 00:00:00 2001 From: Florian Fleissner Date: Wed, 20 Nov 2019 21:48:42 +0100 Subject: [PATCH 2/8] Enabled virtual build for ez/ErgoDox Signed-off-by: Florian Fleissner --- src/kaleidoscope/device/ez/ErgoDox.cpp | 2 ++ src/kaleidoscope/device/ez/ErgoDox.h | 9 +++++++-- src/kaleidoscope/device/ez/ErgoDox/ErgoDoxScanner.cpp | 2 ++ src/kaleidoscope/device/ez/ErgoDox/i2cmaster.cpp | 2 ++ src/kaleidoscope/driver/bootloader/avr/Caterina.h | 6 ++++++ src/kaleidoscope/driver/bootloader/avr/FLIP.cpp | 2 ++ src/kaleidoscope/driver/bootloader/avr/FLIP.h | 6 ++++++ src/kaleidoscope/driver/bootloader/avr/HalfKay.h | 6 ++++++ 8 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/kaleidoscope/device/ez/ErgoDox.cpp b/src/kaleidoscope/device/ez/ErgoDox.cpp index 1d6c528c..38dd0f1b 100644 --- a/src/kaleidoscope/device/ez/ErgoDox.cpp +++ b/src/kaleidoscope/device/ez/ErgoDox.cpp @@ -24,6 +24,7 @@ * along with this program. If not, see . */ +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef ARDUINO_AVR_ERGODOX #include @@ -232,3 +233,4 @@ uint8_t ErgoDox::pressedKeyswitchCount() { kaleidoscope::device::ez::ErgoDox &ErgoDox = kaleidoscope_internal::device; #endif +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD diff --git a/src/kaleidoscope/device/ez/ErgoDox.h b/src/kaleidoscope/device/ez/ErgoDox.h index d7b35626..c706b27f 100644 --- a/src/kaleidoscope/device/ez/ErgoDox.h +++ b/src/kaleidoscope/device/ez/ErgoDox.h @@ -29,8 +29,6 @@ #include -#include "kaleidoscope/device/ez/ErgoDox/ErgoDoxScanner.h" - #include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h" struct cRGB { @@ -42,6 +40,9 @@ struct cRGB { #include "kaleidoscope/driver/keyscanner/Base.h" #include "kaleidoscope/driver/bootloader/avr/HalfKay.h" #include "kaleidoscope/device/ATmega32U4Keyboard.h" +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD +#include "kaleidoscope/device/ez/ErgoDox/ErgoDoxScanner.h" +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD namespace kaleidoscope { namespace device { @@ -54,6 +55,7 @@ struct ErgoDoxProps : public kaleidoscope::device::ATmega32U4KeyboardProps { typedef kaleidoscope::driver::bootloader::avr::HalfKay Bootloader; }; +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD class ErgoDox : public kaleidoscope::device::ATmega32U4Keyboard { public: ErgoDox(void) {} @@ -93,6 +95,9 @@ class ErgoDox : public kaleidoscope::device::ATmega32U4Keyboard { static void debounceRow(uint8_t change, uint8_t row); static void readMatrixRow(uint8_t row); }; +#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +class ErgoDox; +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #define PER_KEY_DATA_STACKED(dflt, \ /* left hand, spatial positions */ \ diff --git a/src/kaleidoscope/device/ez/ErgoDox/ErgoDoxScanner.cpp b/src/kaleidoscope/device/ez/ErgoDox/ErgoDoxScanner.cpp index 660171c5..649710e5 100644 --- a/src/kaleidoscope/device/ez/ErgoDox/ErgoDoxScanner.cpp +++ b/src/kaleidoscope/device/ez/ErgoDox/ErgoDoxScanner.cpp @@ -23,6 +23,7 @@ * along with this program. If not, see . */ +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef ARDUINO_AVR_ERGODOX #include "kaleidoscope/device/ez/ErgoDox/ErgoDoxScanner.h" @@ -171,3 +172,4 @@ ErgoDoxScanner::reattachExpanderOnError() { } #endif +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD diff --git a/src/kaleidoscope/device/ez/ErgoDox/i2cmaster.cpp b/src/kaleidoscope/device/ez/ErgoDox/i2cmaster.cpp index 71400b84..abc105c1 100644 --- a/src/kaleidoscope/device/ez/ErgoDox/i2cmaster.cpp +++ b/src/kaleidoscope/device/ez/ErgoDox/i2cmaster.cpp @@ -7,6 +7,7 @@ * Usage: API compatible with I2C Software Library i2cmaster.h **************************************************************************/ +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef ARDUINO_AVR_ERGODOX #include @@ -201,3 +202,4 @@ unsigned char i2c_readNak(void) { }/* i2c_readNak */ #endif +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD diff --git a/src/kaleidoscope/driver/bootloader/avr/Caterina.h b/src/kaleidoscope/driver/bootloader/avr/Caterina.h index 7006c512..1d45939c 100644 --- a/src/kaleidoscope/driver/bootloader/avr/Caterina.h +++ b/src/kaleidoscope/driver/bootloader/avr/Caterina.h @@ -17,7 +17,9 @@ #pragma once +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #include +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #include "kaleidoscope/driver/bootloader/Base.h" namespace kaleidoscope { @@ -25,6 +27,7 @@ namespace driver { namespace bootloader { namespace avr { +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD class Caterina : public kaleidoscope::driver::bootloader::Base { public: static void rebootBootloader() { @@ -49,6 +52,9 @@ class Caterina : public kaleidoscope::driver::bootloader::Base { // happens before the watchdog reboots us } }; +#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +class Caterina; +#endif // #ifndef KALEIDOSCOPE_VIRTUAL_BUILD } } diff --git a/src/kaleidoscope/driver/bootloader/avr/FLIP.cpp b/src/kaleidoscope/driver/bootloader/avr/FLIP.cpp index 4ab4485f..fcb86068 100644 --- a/src/kaleidoscope/driver/bootloader/avr/FLIP.cpp +++ b/src/kaleidoscope/driver/bootloader/avr/FLIP.cpp @@ -15,6 +15,7 @@ * this program. If not, see . */ +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #include #ifdef KALEIDOSCOPE_BOOTLOADER_FLIP_WORKAROUND @@ -74,3 +75,4 @@ void FLIP::rebootBootloader() { } #endif +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD diff --git a/src/kaleidoscope/driver/bootloader/avr/FLIP.h b/src/kaleidoscope/driver/bootloader/avr/FLIP.h index bc79d59f..29af58c1 100644 --- a/src/kaleidoscope/driver/bootloader/avr/FLIP.h +++ b/src/kaleidoscope/driver/bootloader/avr/FLIP.h @@ -17,11 +17,13 @@ #pragma once +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #include #ifndef KALEIDOSCOPE_BOOTLOADER_FLIP_WORKAROUND #error To use the FLIP bootloader driver, KALEIDOSCOPE_BOOTLOADER_FLIP_WORKAROUND *must* be defined prior to including this header! #endif +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #include "kaleidoscope/driver/bootloader/Base.h" @@ -30,10 +32,14 @@ namespace driver { namespace bootloader { namespace avr { +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD class FLIP : public kaleidoscope::driver::bootloader::Base { public: static void rebootBootloader(); }; +#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +class FLIP; +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD } } diff --git a/src/kaleidoscope/driver/bootloader/avr/HalfKay.h b/src/kaleidoscope/driver/bootloader/avr/HalfKay.h index 651db242..7386122f 100644 --- a/src/kaleidoscope/driver/bootloader/avr/HalfKay.h +++ b/src/kaleidoscope/driver/bootloader/avr/HalfKay.h @@ -17,7 +17,9 @@ #pragma once +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #include +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #include "kaleidoscope/driver/bootloader/Base.h" namespace kaleidoscope { @@ -25,6 +27,7 @@ namespace driver { namespace bootloader { namespace avr { +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD class HalfKay : public kaleidoscope::driver::bootloader::Base { public: // To reset a Teensy with the HalfKay bootloader, we need to disable all @@ -65,6 +68,9 @@ class HalfKay : public kaleidoscope::driver::bootloader::Base { asm volatile("jmp 0x7E00"); } }; +#else +class HalfKay; +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD } } From b6fd6b02f5755c01a2eab5c0cd3b308a80a6e531 Mon Sep 17 00:00:00 2001 From: Florian Fleissner Date: Wed, 20 Nov 2019 22:23:22 +0100 Subject: [PATCH 3/8] Enabled virtual build for KBDFans/KBD4x Signed-off-by: Florian Fleissner --- src/kaleidoscope/device/avr/pins_and_ports.h | 16 ++++++++++++---- src/kaleidoscope/device/kbdfans/KBD4x.cpp | 2 ++ src/kaleidoscope/device/kbdfans/KBD4x.h | 4 ++++ .../driver/bootloader/avr/Caterina.h | 3 ++- src/kaleidoscope/driver/bootloader/avr/FLIP.h | 3 ++- src/kaleidoscope/driver/bootloader/avr/HalfKay.h | 3 ++- src/kaleidoscope/driver/keyscanner/ATmega.h | 15 +++++++++++++++ 7 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/kaleidoscope/device/avr/pins_and_ports.h b/src/kaleidoscope/device/avr/pins_and_ports.h index ba42f7ba..d2d566cc 100644 --- a/src/kaleidoscope/device/avr/pins_and_ports.h +++ b/src/kaleidoscope/device/avr/pins_and_ports.h @@ -21,7 +21,7 @@ #pragma once -#ifndef __ASSEMBLER__ +#if !defined(__ASSEMBLER__) && !defined(KALEIDOSCOPE_VIRTUAL_BUILD) #include #endif #define PORT_SHIFTER 4 // this may be 4 for all AVR chips @@ -55,13 +55,22 @@ #define PINC_ADDRESS 0x3 #define PINB_ADDRESS 0x6 #define PINA_ADDRESS 0x9 -#else +#elif !defined(KALEIDOSCOPE_VIRTUAL_BUILD) #error "Pins are not defined" #endif /* I/O pins */ +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #define PINDEF(port, pin) ((PIN##port##_ADDRESS << PORT_SHIFTER) | pin) - +#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +#define PINDEF(port, pin) 0 +#define PORTA +#define PORTB +#define PORTC +#define PORTD +#define PORTE +#define PORTF +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef PORTA #define PIN_A0 PINDEF(A, 0) @@ -124,7 +133,6 @@ #define PIN_F7 PINDEF(F, 7) #endif - /* converting pins to ports */ enum { PIN_OFFSET, DDR_OFFSET, PORT_OFFSET}; diff --git a/src/kaleidoscope/device/kbdfans/KBD4x.cpp b/src/kaleidoscope/device/kbdfans/KBD4x.cpp index 7657edc5..788100cb 100644 --- a/src/kaleidoscope/device/kbdfans/KBD4x.cpp +++ b/src/kaleidoscope/device/kbdfans/KBD4x.cpp @@ -15,6 +15,7 @@ * along with this program. If not, see . */ +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef ARDUINO_AVR_KBD4X #include @@ -32,3 +33,4 @@ ATMEGA_KEYSCANNER_BOILERPLATE kaleidoscope::device::kbdfans::KBD4x &KBD4x = kaleidoscope_internal::device; #endif +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD diff --git a/src/kaleidoscope/device/kbdfans/KBD4x.h b/src/kaleidoscope/device/kbdfans/KBD4x.h index c0a28c68..d5d83d37 100644 --- a/src/kaleidoscope/device/kbdfans/KBD4x.h +++ b/src/kaleidoscope/device/kbdfans/KBD4x.h @@ -42,6 +42,7 @@ struct KBD4xProps : kaleidoscope::device::ATmega32U4KeyboardProps { typedef kaleidoscope::driver::bootloader::avr::FLIP Bootloader; }; +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD class KBD4x: public kaleidoscope::device::ATmega32U4Keyboard { public: KBD4x() { @@ -49,6 +50,9 @@ class KBD4x: public kaleidoscope::device::ATmega32U4Keyboard { mcu_.disableClockDivision(); } }; +#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +class KBD4x; +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #define PER_KEY_DATA(dflt, \ R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, \ diff --git a/src/kaleidoscope/driver/bootloader/avr/Caterina.h b/src/kaleidoscope/driver/bootloader/avr/Caterina.h index 1d45939c..52447cb5 100644 --- a/src/kaleidoscope/driver/bootloader/avr/Caterina.h +++ b/src/kaleidoscope/driver/bootloader/avr/Caterina.h @@ -20,6 +20,7 @@ #ifndef KALEIDOSCOPE_VIRTUAL_BUILD #include #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +#include "kaleidoscope/driver/bootloader/None.h" #include "kaleidoscope/driver/bootloader/Base.h" namespace kaleidoscope { @@ -53,7 +54,7 @@ class Caterina : public kaleidoscope::driver::bootloader::Base { } }; #else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD -class Caterina; +typedef bootloader::None Caterina; #endif // #ifndef KALEIDOSCOPE_VIRTUAL_BUILD } diff --git a/src/kaleidoscope/driver/bootloader/avr/FLIP.h b/src/kaleidoscope/driver/bootloader/avr/FLIP.h index 29af58c1..c4e993e1 100644 --- a/src/kaleidoscope/driver/bootloader/avr/FLIP.h +++ b/src/kaleidoscope/driver/bootloader/avr/FLIP.h @@ -25,6 +25,7 @@ #endif #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +#include "kaleidoscope/driver/bootloader/None.h" #include "kaleidoscope/driver/bootloader/Base.h" namespace kaleidoscope { @@ -38,7 +39,7 @@ class FLIP : public kaleidoscope::driver::bootloader::Base { static void rebootBootloader(); }; #else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD -class FLIP; +typedef bootloader::None FLIP; #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD } diff --git a/src/kaleidoscope/driver/bootloader/avr/HalfKay.h b/src/kaleidoscope/driver/bootloader/avr/HalfKay.h index 7386122f..ae8d1268 100644 --- a/src/kaleidoscope/driver/bootloader/avr/HalfKay.h +++ b/src/kaleidoscope/driver/bootloader/avr/HalfKay.h @@ -20,6 +20,7 @@ #ifndef KALEIDOSCOPE_VIRTUAL_BUILD #include #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +#include "kaleidoscope/driver/bootloader/None.h" #include "kaleidoscope/driver/bootloader/Base.h" namespace kaleidoscope { @@ -69,7 +70,7 @@ class HalfKay : public kaleidoscope::driver::bootloader::Base { } }; #else -class HalfKay; +typedef bootloader::None HalfKay; #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD } diff --git a/src/kaleidoscope/driver/keyscanner/ATmega.h b/src/kaleidoscope/driver/keyscanner/ATmega.h index bf8e8ba3..8db7eaf8 100644 --- a/src/kaleidoscope/driver/keyscanner/ATmega.h +++ b/src/kaleidoscope/driver/keyscanner/ATmega.h @@ -22,17 +22,26 @@ #include "kaleidoscope/macro_helpers.h" #include "kaleidoscope/driver/keyscanner/Base.h" +#include "kaleidoscope/driver/keyscanner/None.h" + #include "kaleidoscope/device/avr/pins_and_ports.h" +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #include +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #define ROW_PIN_LIST(...) __VA_ARGS__ #define COL_PIN_LIST(...) __VA_ARGS__ +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #define ATMEGA_KEYSCANNER_PROPS(ROW_PINS_, COL_PINS_) \ KEYSCANNER_PROPS(NUM_ARGS(ROW_PINS_), 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_; +#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +#define ATMEGA_KEYSCANNER_PROPS(ROW_PINS_, COL_PINS_) \ + KEYSCANNER_PROPS(NUM_ARGS(ROW_PINS_), NUM_ARGS(COL_PINS_)); +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #define ATMEGA_KEYSCANNER_BOILERPLATE \ KEYSCANNER_PROPS_BOILERPLATE(kaleidoscope::Device::KeyScannerProps); \ @@ -66,6 +75,8 @@ struct ATmegaProps: kaleidoscope::driver::keyscanner::BaseProps { static constexpr uint8_t matrix_col_pins[] = {}; }; + +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD template class ATmega: public kaleidoscope::driver::keyscanner::Base<_KeyScannerProps> { private: @@ -233,6 +244,10 @@ class ATmega: public kaleidoscope::driver::keyscanner::Base<_KeyScannerProps> { } } }; +#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +template +class ATmega : public keyscanner::None {}; +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD } } From 9d4641a21860898921e64197aba755c6187b13ba Mon Sep 17 00:00:00 2001 From: Florian Fleissner Date: Wed, 20 Nov 2019 22:36:02 +0100 Subject: [PATCH 4/8] Enabled virtual build for OLKB/Planck Signed-off-by: Florian Fleissner --- src/kaleidoscope/device/ATmega32U4Keyboard.h | 44 ++++++++++++++++---- src/kaleidoscope/device/olkb/Planck.cpp | 2 + src/kaleidoscope/driver/storage/AVREEPROM.h | 2 +- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/kaleidoscope/device/ATmega32U4Keyboard.h b/src/kaleidoscope/device/ATmega32U4Keyboard.h index 2f552440..2570a859 100644 --- a/src/kaleidoscope/device/ATmega32U4Keyboard.h +++ b/src/kaleidoscope/device/ATmega32U4Keyboard.h @@ -27,16 +27,44 @@ #include "kaleidoscope/driver/storage/ATmega32U4EEPROMProps.h" #include "kaleidoscope/driver/storage/AVREEPROM.h" -#define ATMEGA32U4_KEYBOARD(BOARD_, BOOTLOADER_, ROW_PINS_, COL_PINS_) \ - struct BOARD_##Props : kaleidoscope::device::ATmega32U4KeyboardProps { \ - struct KeyScannerProps : public kaleidoscope::driver::keyscanner::ATmegaProps { \ - ATMEGA_KEYSCANNER_PROPS(ROW_PIN_LIST(ROW_PINS_), COL_PIN_LIST(COL_PINS_)); \ - }; \ - typedef kaleidoscope::driver::keyscanner::ATmega KeyScanner; \ - typedef kaleidoscope::driver::bootloader::avr::BOOTLOADER_ BootLoader; \ - }; \ +#define ATMEGA32U4_DEVICE_PROPS(BOARD_, BOOTLOADER_, ROW_PINS_, COL_PINS_) \ + struct BOARD_##Props : kaleidoscope::device::ATmega32U4KeyboardProps { \ + struct KeyScannerProps \ + : public kaleidoscope::driver::keyscanner::ATmegaProps \ + { \ + ATMEGA_KEYSCANNER_PROPS(ROW_PIN_LIST(ROW_PINS_), \ + COL_PIN_LIST(COL_PINS_)); \ + }; \ + typedef kaleidoscope::driver::keyscanner::ATmega KeyScanner;\ + typedef kaleidoscope::driver::bootloader::avr::BOOTLOADER_ BootLoader; \ + }; + +#define ATMEGA32U4_DEVICE(BOARD_) \ class BOARD_: public kaleidoscope::device::ATmega32U4Keyboard {}; +#define FORWARD(...) __VA_ARGS__ + +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD + +#define ATMEGA32U4_KEYBOARD(BOARD_, BOOTLOADER_, ROW_PINS_, COL_PINS_) \ + ATMEGA32U4_DEVICE_PROPS(BOARD_, BOOTLOADER_, \ + FORWARD(ROW_PINS_), FORWARD(COL_PINS_)) \ + ATMEGA32U4_DEVICE(BOARD_) + +#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD + +#define ATMEGA32U4_KEYBOARD(BOARD_, BOOTLOADER_, ROW_PINS_, COL_PINS_) \ + ATMEGA32U4_DEVICE_PROPS(BOARD_, BOOTLOADER_, \ + FORWARD(ROW_PINS_), FORWARD(COL_PINS_)) \ + /* Device definition omitted for virtual device builds. \ + * We need to forward declare the device name, though, as there are \ + * some legacy extern references to boards whose definition \ + * depends on this. \ + */ \ + class BOARD_; + +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD + namespace kaleidoscope { namespace device { diff --git a/src/kaleidoscope/device/olkb/Planck.cpp b/src/kaleidoscope/device/olkb/Planck.cpp index 66167f53..889a255f 100644 --- a/src/kaleidoscope/device/olkb/Planck.cpp +++ b/src/kaleidoscope/device/olkb/Planck.cpp @@ -15,6 +15,7 @@ * along with this program. If not, see . */ +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef ARDUINO_AVR_PLANCK #include @@ -32,3 +33,4 @@ ATMEGA_KEYSCANNER_BOILERPLATE kaleidoscope::device::olkb::Planck &Planck = kaleidoscope_internal::device; #endif +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD diff --git a/src/kaleidoscope/driver/storage/AVREEPROM.h b/src/kaleidoscope/driver/storage/AVREEPROM.h index 9871a084..691d0e68 100644 --- a/src/kaleidoscope/driver/storage/AVREEPROM.h +++ b/src/kaleidoscope/driver/storage/AVREEPROM.h @@ -17,7 +17,7 @@ #pragma once -#ifdef __AVR__ +#if defined(__AVR__) || defined(KALEIDOSCOPE_VIRTUAL_BUILD) #include "kaleidoscope/driver/storage/Base.h" #include From 7599ad44d988cdeab0d67e19fb17df90420db7cf Mon Sep 17 00:00:00 2001 From: Florian Fleissner Date: Wed, 20 Nov 2019 22:38:53 +0100 Subject: [PATCH 5/8] Enabled virtual build for SOFTHRUF/Splitography Signed-off-by: Florian Fleissner --- src/kaleidoscope/device/softhruf/Splitography.cpp | 2 ++ src/kaleidoscope/device/softhruf/Splitography.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/kaleidoscope/device/softhruf/Splitography.cpp b/src/kaleidoscope/device/softhruf/Splitography.cpp index 5d0af017..cf7f55a2 100644 --- a/src/kaleidoscope/device/softhruf/Splitography.cpp +++ b/src/kaleidoscope/device/softhruf/Splitography.cpp @@ -22,6 +22,7 @@ * along with this program. If not, see . */ +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef ARDUINO_AVR_SPLITOGRAPHY #include @@ -39,3 +40,4 @@ ATMEGA_KEYSCANNER_BOILERPLATE kaleidoscope::device::softhruf::Splitography &Splitography = kaleidoscope_internal::device; #endif +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD diff --git a/src/kaleidoscope/device/softhruf/Splitography.h b/src/kaleidoscope/device/softhruf/Splitography.h index 19ce037f..230ace30 100644 --- a/src/kaleidoscope/device/softhruf/Splitography.h +++ b/src/kaleidoscope/device/softhruf/Splitography.h @@ -49,12 +49,16 @@ struct SplitographyProps : kaleidoscope::device::ATmega32U4KeyboardProps { typedef kaleidoscope::driver::bootloader::avr::FLIP BootLoader; }; +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD class Splitography: public kaleidoscope::device::ATmega32U4Keyboard { public: Splitography() { mcu_.disableJTAG(); } }; +#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +class Splitography; +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #define PER_KEY_DATA(dflt, \ r0c0 ,r0c1 ,r0c2 ,r0c3 ,r0c4 ,r0c5 ,r0c6 ,r0c7 ,r0c8 ,r0c9 ,r0c10 ,r0c11 \ From fb64771e52741d4a13e4b1b27a32ac7b0307d322 Mon Sep 17 00:00:00 2001 From: Florian Fleissner Date: Wed, 20 Nov 2019 22:40:16 +0100 Subject: [PATCH 6/8] Enabled virtual build for Technomancy/Atreus Signed-off-by: Florian Fleissner --- src/kaleidoscope/device/technomancy/Atreus.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/kaleidoscope/device/technomancy/Atreus.cpp b/src/kaleidoscope/device/technomancy/Atreus.cpp index 31e21499..23a9cc51 100644 --- a/src/kaleidoscope/device/technomancy/Atreus.cpp +++ b/src/kaleidoscope/device/technomancy/Atreus.cpp @@ -24,6 +24,7 @@ * along with this program. If not, see . */ +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef ARDUINO_AVR_ATREUS #include @@ -41,3 +42,4 @@ ATMEGA_KEYSCANNER_BOILERPLATE kaleidoscope::device::technomancy::Atreus &Atreus = kaleidoscope_internal::device; #endif +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD From 7e5a2d0ddca40cfc32758f0dbb3c48f050b87b94 Mon Sep 17 00:00:00 2001 From: Florian Fleissner Date: Wed, 20 Nov 2019 22:42:54 +0100 Subject: [PATCH 7/8] Enabled virtual build for Technomancy/Atreus2 Signed-off-by: Florian Fleissner --- src/kaleidoscope/device/technomancy/Atreus2.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/kaleidoscope/device/technomancy/Atreus2.cpp b/src/kaleidoscope/device/technomancy/Atreus2.cpp index f3326167..5b8475d7 100644 --- a/src/kaleidoscope/device/technomancy/Atreus2.cpp +++ b/src/kaleidoscope/device/technomancy/Atreus2.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef ARDUINO_AVR_ATREUS2 #include @@ -33,3 +34,4 @@ ATMEGA_KEYSCANNER_BOILERPLATE kaleidoscope::device::technomancy::Atreus2 &Atreus2 = kaleidoscope_internal::device; #endif +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD From a114f3c1a43362158e42ad5a2765bc7a2bb5412d Mon Sep 17 00:00:00 2001 From: Florian Fleissner Date: Wed, 20 Nov 2019 23:29:23 +0100 Subject: [PATCH 8/8] Enabled virtual build for Keyboardio/Imago Signed-off-by: Florian Fleissner --- src/kaleidoscope/device/keyboardio/Imago.cpp | 4 ++++ src/kaleidoscope/device/keyboardio/Imago.h | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/kaleidoscope/device/keyboardio/Imago.cpp b/src/kaleidoscope/device/keyboardio/Imago.cpp index 0890c54c..d840ba39 100644 --- a/src/kaleidoscope/device/keyboardio/Imago.cpp +++ b/src/kaleidoscope/device/keyboardio/Imago.cpp @@ -33,6 +33,8 @@ namespace keyboardio { constexpr uint8_t ImagoLEDDriverProps::key_led_map[] PROGMEM; +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD + static constexpr uint8_t CMD_SET_REGISTER = 0xFD; static constexpr uint8_t CMD_WRITE_ENABLE = 0xFE; static constexpr uint8_t WRITE_ENABLE_ONCE = 0b11000101; @@ -172,6 +174,8 @@ void Imago::setup() { kaleidoscope::device::ATmega32U4Keyboard::setup(); } +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD + } } } diff --git a/src/kaleidoscope/device/keyboardio/Imago.h b/src/kaleidoscope/device/keyboardio/Imago.h index e580cba2..03ff9337 100644 --- a/src/kaleidoscope/device/keyboardio/Imago.h +++ b/src/kaleidoscope/device/keyboardio/Imago.h @@ -51,6 +51,7 @@ struct ImagoLEDDriverProps: public kaleidoscope::driver::led::BaseProps { }; }; +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD class ImagoLEDDriver : public kaleidoscope::driver::led::Base { public: static void setup(); @@ -68,6 +69,9 @@ class ImagoLEDDriver : public kaleidoscope::driver::led::Base { public: void setup(); }; +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #define PER_KEY_DATA(dflt, \ R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, R0C12, R0C13, R0C14, R0C15, \