diff --git a/plugins/Kaleidoscope-Hardware-STM32-Test/src/kaleidoscope/device/stm32/Test.cpp b/plugins/Kaleidoscope-Hardware-STM32-Test/src/kaleidoscope/device/stm32/Test.cpp index 8cf696f5..d9c1b62d 100644 --- a/plugins/Kaleidoscope-Hardware-STM32-Test/src/kaleidoscope/device/stm32/Test.cpp +++ b/plugins/Kaleidoscope-Hardware-STM32-Test/src/kaleidoscope/device/stm32/Test.cpp @@ -15,17 +15,17 @@ * this program. If not, see . */ -#ifdef ARDUINO_GD32F303ZE_EVAL +#ifdef KBIO_TEST #include "kaleidoscope/Runtime.h" #include "kaleidoscope/driver/keyscanner/Base_Impl.h" namespace kaleidoscope { namespace device { -namespace gd32 { +namespace stm32 { -} // namespace gd32 +} // namespace stm32 } // namespace device } // namespace kaleidoscope -#endif // ifdef ARDUINO_GD32F303ZE_EVAL +#endif // ifdef KBIO_TEST diff --git a/plugins/Kaleidoscope-Hardware-STM32-Test/src/kaleidoscope/device/stm32/Test.h b/plugins/Kaleidoscope-Hardware-STM32-Test/src/kaleidoscope/device/stm32/Test.h index 5a2129f1..f4e7feea 100644 --- a/plugins/Kaleidoscope-Hardware-STM32-Test/src/kaleidoscope/device/stm32/Test.h +++ b/plugins/Kaleidoscope-Hardware-STM32-Test/src/kaleidoscope/device/stm32/Test.h @@ -22,16 +22,25 @@ #include #include "kaleidoscope/device/Base.h" +#include "kaleidoscope/driver/hid/RCMComposite.h" namespace kaleidoscope { namespace device { namespace stm32 { -struct TestProps: kaleidoscope::device::BaseProps { +struct TestProps: public kaleidoscope::device::BaseProps { + typedef kaleidoscope::driver::hid::RCMCompositeProps HIDProps; + typedef kaleidoscope::driver::hid::RCMComposite HID; + static constexpr const char *short_name = "KBIOTest"; }; -class Test: public kaleidoscope::device::Base {}; +class Test: public kaleidoscope::device::Base { + public: + auto serialPort() -> decltype(kaleidoscope::driver::hid::rcmcomposite::CompositeSerial) & { + return kaleidoscope::driver::hid::rcmcomposite::CompositeSerial; + } +}; #define PER_KEY_DATA(dflt, \ R0C0, R0C1 \ diff --git a/src/kaleidoscope/driver/hid/RCMComposite.cpp b/src/kaleidoscope/driver/hid/RCMComposite.cpp new file mode 100644 index 00000000..7990b639 --- /dev/null +++ b/src/kaleidoscope/driver/hid/RCMComposite.cpp @@ -0,0 +1,32 @@ +// -*- mode: c++ -*- +/* Kaleidoscope - Firmware for computer input devices + * Copyright (C) 2021 Keyboard.io, Inc. + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include "kaleidoscope/driver/hid/RCMComposite.h" + +namespace kaleidoscope { +namespace driver { +namespace hid { +namespace rcmcomposite { + +USBHID RCMHID; +HIDKeyboard RCMKeyboard(RCMHID); +USBCompositeSerial CompositeSerial; + +} // namespace rcmcomposite +} // namespace hid +} // namespace driver +} // namespace kaleidoscope diff --git a/src/kaleidoscope/driver/hid/RCMComposite.h b/src/kaleidoscope/driver/hid/RCMComposite.h new file mode 100644 index 00000000..ab5ded64 --- /dev/null +++ b/src/kaleidoscope/driver/hid/RCMComposite.h @@ -0,0 +1,56 @@ +// -*- mode: c++ -*- +/* Kaleidoscope - Firmware for computer input devices + * Copyright (C) 2021 Keyboard.io, Inc. + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#pragma once + +#include +#include + +#include "kaleidoscope/driver/hid/Base.h" + +#include "rcmcomposite/Keyboard.h" +//#include "rcmcomposite/Mouse.h" + +namespace kaleidoscope { +namespace driver { +namespace hid { + +namespace rcmcomposite { +extern USBHID RCMHID; +extern HIDKeyboard RCMKeyboard; +extern USBCompositeSerial CompositeSerial; +} + +struct RCMCompositeProps: public BaseProps { + typedef rcmcomposite::KeyboardProps KeyboardProps; + typedef rcmcomposite::Keyboard Keyboard; + // typedef rcmcomposite::MouseProps MouseProps; + // typedef rcmcomposite::Mouse Mouse; +}; + +template +class RCMComposite: public Base<_Props> { + public: + void setup() { + //rcmcomposite::RCMHID.begin(rcmcomposite::CompositeSerial, HID_KEYBOARD_MOUSE); + rcmcomposite::RCMHID.begin(HID_KEYBOARD_MOUSE); + } +}; + +} // namespace hid +} // namespace driver +} // namespace kaleidoscope diff --git a/src/kaleidoscope/driver/hid/rcmcomposite/Keyboard.h b/src/kaleidoscope/driver/hid/rcmcomposite/Keyboard.h new file mode 100644 index 00000000..95dbff8c --- /dev/null +++ b/src/kaleidoscope/driver/hid/rcmcomposite/Keyboard.h @@ -0,0 +1,95 @@ +// -*- mode: c++ -*- +/* Kaleidoscope - Firmware for computer input devices + * Copyright (C) 2021 Keyboard.io, Inc. + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#pragma once + +#include +#include + +#include "kaleidoscope/driver/hid/base/Keyboard.h" + +namespace kaleidoscope { +namespace driver { +namespace hid { +namespace rcmcomposite { + +extern USBHID RCMHID; +extern HIDKeyboard RCMKeyboard; + +class BootKeyboardWrapper { + public: + BootKeyboardWrapper() {} + + void begin() {} + + uint8_t getProtocol() { + return 0; + } + void setProtocol(uint8_t protocol) {} + void setDefaultProtocol(uint8_t protocol) {} + + void sendReport() { + RCMKeyboard.sendReport(); + } + + void press(uint8_t code) { + RCMKeyboard.press(code); + } + void release(uint8_t code) { + RCMKeyboard.release(code); + } + void releaseAll() { + RCMKeyboard.releaseAll(); + } + + bool isKeyPressed(uint8_t code) { + //return BootKeyboard.isKeyPressed(code); + return 0; + } + bool isModifierActive(uint8_t code) { + //return BootKeyboard.isModifierActive(code); + return 0; + } + bool wasModifierActive(uint8_t code) { + //return BootKeyboard.wasModifierActive(code); + return 0; + } + bool isAnyModifierActive() { + //return BootKeyboard.isAnyModifierActive(); + return 0; + } + bool wasAnyModifierActive() { + //return BootKeyboard.wasAnyModifierActive(); + return 0; + } + + uint8_t getLeds() { + return RCMKeyboard.getLEDs(); + } +}; + +struct KeyboardProps: public base::KeyboardProps { + typedef BootKeyboardWrapper BootKeyboard; +}; + +template +class Keyboard: public base::Keyboard<_Props> {}; + +} // namespace rcmcomposite +} // namespace hid +} // namespace driver +} // namespace keyboardio