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