From b5c9794626c78a6f24303a3c864cfb7efcd25f4e Mon Sep 17 00:00:00 2001 From: Florian Fleissner Date: Wed, 20 Nov 2019 15:54:40 +0100 Subject: [PATCH] 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 } }