Redesign how the hardware objects are defined

Instead of having to define `HARDWARE_IMPLEMENTATION` to the class name of the
device, and define `KeyboardHardware` from within the plugin, let all devices
set `kaleidoscope::Device` to their own class via a typedef. Furthermore,
instead of `KeyboardHardware`, use `Kaleidoscope.device()` instead. This makes
device plugins a little bit simpler, and our naming more consistent.

Because some parts of the firmware need to access the device object before the
`Kaleidoscope` object is available, we can't make it a member of that. For this
reason, the device object is `kaleidoscope_internal::device`, and
`Kaleidoscope.device()` wraps it. In general, the wrapper should be used. But if
access to the device is required before `Kaleidoscope` is available, then that's
also available.

The `Kaleidoscope` object grew a few more wrappers: `storage()` and
`serialPort()`, so that one doesn't need to use `Kaleidoscope.device()`
directly, but can use the wrappers, which are noticably shorter to write.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/710/head
Gergely Nagy 5 years ago
parent 129d37ef04
commit 0c8f998b9f
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -17,7 +17,7 @@ the box, without any further configuration:
KALEIDOSCOPE_INIT_PLUGINS(CycleTimeReport); KALEIDOSCOPE_INIT_PLUGINS(CycleTimeReport);
void setup (void) { void setup (void) {
KeyboardHardware.serialPort().begin(9600); Kaleidoscope.serialPort().begin(9600);
Kaleidoscope.setup (); Kaleidoscope.setup ();
} }
``` ```

@ -43,7 +43,7 @@ void setup () {
return; return;
} }
KeyboardHardware.storage().get(settingsBase, testSettings); Kaleidoscope.storage().get(settingsBase, testSettings);
} }
``` ```

@ -32,11 +32,11 @@ dictionary:
#include <Kaleidoscope-Leader.h> #include <Kaleidoscope-Leader.h>
static void leaderA(uint8_t seq_index) { static void leaderA(uint8_t seq_index) {
KeyboardHardware.serialPort().println("leaderA"); Kaleidoscope.serialPort().println("leaderA");
} }
static void leaderTX(uint8_t seq_index) { static void leaderTX(uint8_t seq_index) {
KeyboardHardware.serialPort().println("leaderTX"); Kaleidoscope.serialPort().println("leaderTX");
} }
static const kaleidoscope::Leader::dictionary_t leader_dictionary[] PROGMEM = static const kaleidoscope::Leader::dictionary_t leader_dictionary[] PROGMEM =
@ -46,7 +46,7 @@ static const kaleidoscope::Leader::dictionary_t leader_dictionary[] PROGMEM =
KALEIDOSCOPE_INIT_PLUGINS(Leader); KALEIDOSCOPE_INIT_PLUGINS(Leader);
void setup() { void setup() {
KeyboardHardware.serialPort().begin(9600); Kaleidoscope.serialPort().begin(9600);
Kaleidoscope.setup(); Kaleidoscope.setup();

@ -34,8 +34,8 @@ void systerAction(kaleidoscope::plugin::Syster::action_t action, const char *sym
kaleidoscope::hid::sendKeyboardReport (); kaleidoscope::hid::sendKeyboardReport ();
break; break;
case kaleidoscope::plugin::Syster::SymbolAction: case kaleidoscope::plugin::Syster::SymbolAction:
KeyboardHardware.serialPort().print ("systerAction: symbol="); Kaleidoscope.serialPort().print ("systerAction: symbol=");
KeyboardHardware.serialPort().println (symbol); Kaleidoscope.serialPort().println (symbol);
if (strcmp (symbol, "coffee") == 0) { if (strcmp (symbol, "coffee") == 0) {
Unicode.type (0x2615); Unicode.type (0x2615);
} }
@ -46,7 +46,7 @@ void systerAction(kaleidoscope::plugin::Syster::action_t action, const char *sym
KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings, HostOS, Unicode, Syster); KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings, HostOS, Unicode, Syster);
void setup() { void setup() {
KeyboardHardware.serialPort().begin(9600); Kaleidoscope.serialPort().begin(9600);
Kaleidoscope.setup (); Kaleidoscope.setup ();
} }
``` ```

@ -78,7 +78,7 @@ KALEIDOSCOPE_INIT_PLUGINS(Macros);
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
switch (macroIndex) { switch (macroIndex) {
case RESET: case RESET:
KeyboardHardware.resetDevice(); Kaleidoscope.device().resetDevice();
break; break;
default: default:
break; break;

@ -86,7 +86,7 @@ static kaleidoscope::plugin::LEDSolidColor solidViolet(70, 0, 60);
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
if (macroIndex == 1 && keyToggledOn(keyState)) { if (macroIndex == 1 && keyToggledOn(keyState)) {
KeyboardHardware.serialPort().print("Keyboard.IO keyboard driver v0.00"); Kaleidoscope.serialPort().print("Keyboard.IO keyboard driver v0.00");
return MACRO(I(25), return MACRO(I(25),
D(LeftShift), T(M), U(LeftShift), T(O), T(D), T(E), T(L), D(LeftShift), T(M), U(LeftShift), T(O), T(D), T(E), T(L),
T(Spacebar), T(Spacebar),

@ -31,7 +31,7 @@ enum { _QWERTY,
/* *INDENT-OFF* */ /* *INDENT-OFF* */
KEYMAPS( KEYMAPS(
/* Qwerty /* Qwerty
* ,-----------------------------------------------------------------------------------. * ,-----------------------------------------------------------------------------------.
@ -167,7 +167,7 @@ KALEIDOSCOPE_INIT_PLUGINS(Macros);
void setup() { void setup() {
Kaleidoscope.setup(); Kaleidoscope.setup();
KeyboardHardware.serialPort().begin(9600); Kaleidoscope.serialPort().begin(9600);
} }
void loop() { void loop() {

@ -50,7 +50,7 @@ KEYMAPS(
KALEIDOSCOPE_INIT_PLUGINS(GeminiPR); KALEIDOSCOPE_INIT_PLUGINS(GeminiPR);
void setup() { void setup() {
KeyboardHardware.serialPort().begin(9600); Kaleidoscope.serialPort().begin(9600);
Kaleidoscope.setup(); Kaleidoscope.setup();
} }

@ -83,7 +83,7 @@ KALEIDOSCOPE_INIT_PLUGINS(Macros);
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
switch (macroIndex) { switch (macroIndex) {
case RESET: case RESET:
KeyboardHardware.resetDevice(); Kaleidoscope.device().resetDevice();
break; break;
default: default:
break; break;

@ -43,7 +43,7 @@ KEYMAPS(
KALEIDOSCOPE_INIT_PLUGINS(CycleTimeReport); KALEIDOSCOPE_INIT_PLUGINS(CycleTimeReport);
void setup() { void setup() {
KeyboardHardware.serialPort().begin(9600); Kaleidoscope.serialPort().begin(9600);
Kaleidoscope.setup(); Kaleidoscope.setup();
} }

@ -56,7 +56,7 @@ KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings,
Macros); Macros);
void setup() { void setup() {
KeyboardHardware.serialPort().begin(9600); Kaleidoscope.serialPort().begin(9600);
Kaleidoscope.setup(); Kaleidoscope.setup();

@ -42,16 +42,16 @@ KEYMAPS(
KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings); KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings);
void setup() { void setup() {
KeyboardHardware.serialPort().begin(9600); Kaleidoscope.serialPort().begin(9600);
Kaleidoscope.setup(); Kaleidoscope.setup();
while (!KeyboardHardware.serialPort()) { while (!Kaleidoscope.serialPort()) {
} }
KeyboardHardware.serialPort().println(EEPROMSettings.isValid() ? F("valid EEPROM settings") : F("invalid EEPROM settings")); Kaleidoscope.serialPort().println(EEPROMSettings.isValid() ? F("valid EEPROM settings") : F("invalid EEPROM settings"));
KeyboardHardware.serialPort().println(EEPROMSettings.crc(), HEX); Kaleidoscope.serialPort().println(EEPROMSettings.crc(), HEX);
KeyboardHardware.serialPort().println(EEPROMSettings.version()); Kaleidoscope.serialPort().println(EEPROMSettings.version());
} }
void loop() { void loop() {

@ -43,12 +43,12 @@ KEYMAPS(
KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings, HostOS); KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings, HostOS);
void setup() { void setup() {
KeyboardHardware.serialPort().begin(9600); Kaleidoscope.serialPort().begin(9600);
Kaleidoscope.setup(); Kaleidoscope.setup();
KeyboardHardware.serialPort().print("Host OS id is: "); Kaleidoscope.serialPort().print("Host OS id is: ");
KeyboardHardware.serialPort().println(HostOS.os(), DEC); Kaleidoscope.serialPort().println(HostOS.os(), DEC);
} }
void loop() { void loop() {

@ -61,7 +61,7 @@ KEYMAPS(
KALEIDOSCOPE_INIT_PLUGINS(GeminiPR); KALEIDOSCOPE_INIT_PLUGINS(GeminiPR);
void setup() { void setup() {
KeyboardHardware.serialPort().begin(9600); Kaleidoscope.serialPort().begin(9600);
Kaleidoscope.setup(); Kaleidoscope.setup();
} }

@ -40,11 +40,11 @@ KEYMAPS(
// *INDENT-ON* // *INDENT-ON*
static void leaderTestA(uint8_t seq_index) { static void leaderTestA(uint8_t seq_index) {
KeyboardHardware.serialPort().println(F("leaderTestA")); Kaleidoscope.serialPort().println(F("leaderTestA"));
} }
static void leaderTestAA(uint8_t seq_index) { static void leaderTestAA(uint8_t seq_index) {
KeyboardHardware.serialPort().println(F("leaderTestAA")); Kaleidoscope.serialPort().println(F("leaderTestAA"));
} }
static const kaleidoscope::plugin::Leader::dictionary_t leader_dictionary[] PROGMEM = static const kaleidoscope::plugin::Leader::dictionary_t leader_dictionary[] PROGMEM =

@ -56,8 +56,8 @@ void systerAction(kaleidoscope::plugin::Syster::action_t action, const char *sym
kaleidoscope::hid::sendKeyboardReport(); kaleidoscope::hid::sendKeyboardReport();
break; break;
case kaleidoscope::plugin::Syster::SymbolAction: case kaleidoscope::plugin::Syster::SymbolAction:
KeyboardHardware.serialPort().print("systerAction: symbol="); Kaleidoscope.serialPort().print("systerAction: symbol=");
KeyboardHardware.serialPort().println(symbol); Kaleidoscope.serialPort().println(symbol);
if (strcmp(symbol, "coffee") == 0) { if (strcmp(symbol, "coffee") == 0) {
Unicode.type(0x2615); Unicode.type(0x2615);
} }

@ -246,7 +246,7 @@ class Hardware {
* *
* Because different hardware has different ways to accomplish this, the * Because different hardware has different ways to accomplish this, the
* hardware plugin must provide these functions. Kaleidoscope will wrap them, * hardware plugin must provide these functions. Kaleidoscope will wrap them,
* so user code does not have to deal with KeyboardHardware. * so user code does not have to deal with `Kaleidoscope.device()`.
* @{ * @{
*/ */
/** /**

@ -34,11 +34,11 @@ Kaleidoscope_::setup(void) {
// //
// TODO(anyone): Figure out a way we can get rid of this, and fix the bug // TODO(anyone): Figure out a way we can get rid of this, and fix the bug
// properly. // properly.
KeyboardHardware.serialPort().begin(9600); device().serialPort().begin(9600);
kaleidoscope::Hooks::onSetup(); kaleidoscope::Hooks::onSetup();
KeyboardHardware.setup(); device().setup();
kaleidoscope::hid::initializeKeyboard(); kaleidoscope::hid::initializeKeyboard();
kaleidoscope::hid::initializeConsumerControl(); kaleidoscope::hid::initializeConsumerControl();
@ -57,7 +57,7 @@ Kaleidoscope_::loop(void) {
kaleidoscope::Hooks::beforeEachCycle(); kaleidoscope::Hooks::beforeEachCycle();
KeyboardHardware.scanMatrix(); device().scanMatrix();
kaleidoscope::Hooks::beforeReportingState(); kaleidoscope::Hooks::beforeReportingState();

@ -38,8 +38,9 @@ void setup();
#include KALEIDOSCOPE_HARDWARE_H #include KALEIDOSCOPE_HARDWARE_H
#include "kaleidoscope/device/key_indexes.h" #include "kaleidoscope/device/key_indexes.h"
#include "kaleidoscope_internal/device.h"
extern HARDWARE_IMPLEMENTATION KeyboardHardware; static constexpr kaleidoscope::Device &KeyboardHardware = kaleidoscope_internal::device;
#ifdef PER_KEY_DATA_STACKED #ifdef PER_KEY_DATA_STACKED
#define KEYMAP_STACKED(...) { PER_KEY_DATA_STACKED(XXX, __VA_ARGS__) } #define KEYMAP_STACKED(...) { PER_KEY_DATA_STACKED(XXX, __VA_ARGS__) }
@ -49,9 +50,9 @@ extern HARDWARE_IMPLEMENTATION KeyboardHardware;
#define KEYMAP(...) { PER_KEY_DATA(XXX, __VA_ARGS__) } #define KEYMAP(...) { PER_KEY_DATA(XXX, __VA_ARGS__) }
#endif #endif
#define ROWS (KeyboardHardware.matrix_rows) static constexpr uint8_t ROWS = kaleidoscope_internal::device.matrix_rows;
#define COLS (KeyboardHardware.matrix_columns) static constexpr uint8_t COLS = kaleidoscope_internal::device.matrix_columns;
#define LED_COUNT (KeyboardHardware.led_count) static constexpr uint8_t LED_COUNT = kaleidoscope_internal::device.led_count;
#include "kaleidoscope/KeyAddr.h" #include "kaleidoscope/KeyAddr.h"
#include "kaleidoscope/key_events.h" #include "kaleidoscope/key_events.h"
@ -108,13 +109,17 @@ class Kaleidoscope_ {
void setup(void); void setup(void);
void loop(void); void loop(void);
static constexpr bool has_leds = (KeyboardHardware.led_count > 0); static constexpr kaleidoscope::Device &device() {
return kaleidoscope_internal::device;
}
static constexpr bool has_leds = (kaleidoscope_internal::device.led_count > 0);
/** Detaching from / attaching to the host. /** Detaching from / attaching to the host.
* *
* These two functions wrap the hardware plugin's similarly named functions. * These two functions wrap the hardware plugin's similarly named functions.
* We wrap them, because we'd like plugins and user-code not having to use * We wrap them, because we'd like plugins and user-code not having to use
* `KeyboardHardware` directly. * `Kaleidoscope.device()` directly.
* *
* The methods themselves implement detaching from / attaching to the host, * The methods themselves implement detaching from / attaching to the host,
* without rebooting the device, and remaining powered in between. * without rebooting the device, and remaining powered in between.
@ -123,10 +128,23 @@ class Kaleidoscope_ {
* detach and attach. * detach and attach.
*/ */
void detachFromHost() { void detachFromHost() {
KeyboardHardware.detachFromHost(); device().detachFromHost();
} }
void attachToHost() { void attachToHost() {
KeyboardHardware.attachToHost(); device().attachToHost();
}
/** Wrapper functions for some device features.
*
* The next three functions wrap methods of the device plugin, to make using
* them in user sketches easier, and require less typing.
*/
auto serialPort() -> decltype(device().serialPort()) & {
return device().serialPort();
}
auto storage() -> decltype(device().storage()) & {
return device().storage();
} }
/** Returns the timer as it was at the start of the cycle. /** Returns the timer as it was at the start of the cycle.

@ -18,6 +18,4 @@
#include KALEIDOSCOPE_HARDWARE_H #include KALEIDOSCOPE_HARDWARE_H
extern HARDWARE_IMPLEMENTATION KeyboardHardware; typedef kaleidoscope::Device::KeyAddr KeyAddr;
typedef HARDWARE_IMPLEMENTATION::KeyAddr KeyAddr;

@ -29,14 +29,14 @@ uint8_t ATMegaKeyboard::debounce = 3;
void ATMegaKeyboard::setup(void) { void ATMegaKeyboard::setup(void) {
wdt_disable(); wdt_disable();
for (uint8_t i = 0; i < KeyboardHardware.matrix_columns; i++) { for (uint8_t i = 0; i < Kaleidoscope.device().matrix_columns; i++) {
DDR_INPUT(KeyboardHardware.matrix_col_pins[i]); DDR_INPUT(Kaleidoscope.device().matrix_col_pins[i]);
ENABLE_PULLUP(KeyboardHardware.matrix_col_pins[i]); ENABLE_PULLUP(Kaleidoscope.device().matrix_col_pins[i]);
} }
for (uint8_t i = 0; i < KeyboardHardware.matrix_rows; i++) { for (uint8_t i = 0; i < Kaleidoscope.device().matrix_rows; i++) {
DDR_OUTPUT(KeyboardHardware.matrix_row_pins[i]); DDR_OUTPUT(Kaleidoscope.device().matrix_row_pins[i]);
OUTPUT_HIGH(KeyboardHardware.matrix_row_pins[i]); OUTPUT_HIGH(Kaleidoscope.device().matrix_row_pins[i]);
} }
/* Set up Timer1 for 1700usec */ /* Set up Timer1 for 1700usec */
@ -51,24 +51,24 @@ void ATMegaKeyboard::setup(void) {
} }
void __attribute__((optimize(3))) ATMegaKeyboard::readMatrix(void) { void __attribute__((optimize(3))) ATMegaKeyboard::readMatrix(void) {
for (uint8_t current_row = 0; current_row < KeyboardHardware.matrix_rows; current_row++) { for (uint8_t current_row = 0; current_row < Kaleidoscope.device().matrix_rows; current_row++) {
uint16_t mask, cols; uint16_t mask, cols;
mask = KeyboardHardware.debounceMaskForRow(current_row); mask = Kaleidoscope.device().debounceMaskForRow(current_row);
OUTPUT_TOGGLE(KeyboardHardware.matrix_row_pins[current_row]); OUTPUT_TOGGLE(Kaleidoscope.device().matrix_row_pins[current_row]);
cols = (KeyboardHardware.readCols() & mask) | (KeyboardHardware.keyState_[current_row] & ~mask); cols = (Kaleidoscope.device().readCols() & mask) | (Kaleidoscope.device().keyState_[current_row] & ~mask);
OUTPUT_TOGGLE(KeyboardHardware.matrix_row_pins[current_row]); OUTPUT_TOGGLE(Kaleidoscope.device().matrix_row_pins[current_row]);
KeyboardHardware.debounceRow(cols ^ KeyboardHardware.keyState_[current_row], current_row); Kaleidoscope.device().debounceRow(cols ^ Kaleidoscope.device().keyState_[current_row], current_row);
KeyboardHardware.keyState_[current_row] = cols; Kaleidoscope.device().keyState_[current_row] = cols;
} }
} }
uint8_t ATMegaKeyboard::pressedKeyswitchCount() { uint8_t ATMegaKeyboard::pressedKeyswitchCount() {
uint8_t count = 0; uint8_t count = 0;
for (int8_t r = 0; r < KeyboardHardware.matrix_rows; r++) { for (int8_t r = 0; r < Kaleidoscope.device().matrix_rows; r++) {
count += __builtin_popcount(KeyboardHardware.keyState_[r]); count += __builtin_popcount(Kaleidoscope.device().keyState_[r]);
} }
return count; return count;
} }
@ -76,28 +76,28 @@ uint8_t ATMegaKeyboard::pressedKeyswitchCount() {
uint8_t ATMegaKeyboard::previousPressedKeyswitchCount() { uint8_t ATMegaKeyboard::previousPressedKeyswitchCount() {
uint8_t count = 0; uint8_t count = 0;
for (int8_t r = 0; r < KeyboardHardware.matrix_rows; r++) { for (int8_t r = 0; r < Kaleidoscope.device().matrix_rows; r++) {
count += __builtin_popcount(KeyboardHardware.previousKeyState_[r]); count += __builtin_popcount(Kaleidoscope.device().previousKeyState_[r]);
} }
return count; return count;
} }
void __attribute__((optimize(3))) ATMegaKeyboard::actOnMatrixScan() { void __attribute__((optimize(3))) ATMegaKeyboard::actOnMatrixScan() {
for (byte row = 0; row < KeyboardHardware.matrix_rows; row++) { for (byte row = 0; row < Kaleidoscope.device().matrix_rows; row++) {
for (byte col = 0; col < KeyboardHardware.matrix_columns; col++) { for (byte col = 0; col < Kaleidoscope.device().matrix_columns; col++) {
uint8_t keyState = (bitRead(KeyboardHardware.previousKeyState_[row], col) << 0) | uint8_t keyState = (bitRead(Kaleidoscope.device().previousKeyState_[row], col) << 0) |
(bitRead(KeyboardHardware.keyState_[row], col) << 1); (bitRead(Kaleidoscope.device().keyState_[row], col) << 1);
if (keyState) { if (keyState) {
handleKeyswitchEvent(Key_NoKey, ::KeyAddr(row, col), keyState); handleKeyswitchEvent(Key_NoKey, ::KeyAddr(row, col), keyState);
} }
} }
KeyboardHardware.previousKeyState_[row] = KeyboardHardware.keyState_[row]; Kaleidoscope.device().previousKeyState_[row] = Kaleidoscope.device().keyState_[row];
} }
} }
void ATMegaKeyboard::scanMatrix() { void ATMegaKeyboard::scanMatrix() {
// We ALWAYS want to tell Kaleidoscope about the state of the matrix // We ALWAYS want to tell Kaleidoscope about the state of the matrix
KeyboardHardware.actOnMatrixScan(); Kaleidoscope.device().actOnMatrixScan();
} }
/* /*
@ -116,9 +116,9 @@ void ATMegaKeyboard::scanMatrix() {
__attribute__((optimize("no-unroll-loops"))) __attribute__((optimize("no-unroll-loops")))
uint16_t ATMegaKeyboard::readCols() { uint16_t ATMegaKeyboard::readCols() {
uint16_t results = 0x00 ; uint16_t results = 0x00 ;
for (uint8_t i = 0; i < KeyboardHardware.matrix_columns; i++) { for (uint8_t i = 0; i < Kaleidoscope.device().matrix_columns; i++) {
asm("NOP"); // We need to pause a beat before reading or we may read before the pin is hot asm("NOP"); // We need to pause a beat before reading or we may read before the pin is hot
results |= (!READ_PIN(KeyboardHardware.matrix_col_pins[i]) << i); results |= (!READ_PIN(Kaleidoscope.device().matrix_col_pins[i]) << i);
} }
return results; return results;
} }
@ -126,9 +126,9 @@ uint16_t ATMegaKeyboard::readCols() {
uint16_t ATMegaKeyboard::debounceMaskForRow(uint8_t row) { uint16_t ATMegaKeyboard::debounceMaskForRow(uint8_t row) {
uint16_t result = 0; uint16_t result = 0;
for (uint16_t c = 0; c < KeyboardHardware.matrix_columns; ++c) { for (uint16_t c = 0; c < Kaleidoscope.device().matrix_columns; ++c) {
if (KeyboardHardware.debounce_matrix_[row][c]) { if (Kaleidoscope.device().debounce_matrix_[row][c]) {
--KeyboardHardware.debounce_matrix_[row][c]; --Kaleidoscope.device().debounce_matrix_[row][c];
} else { } else {
result |= _BV(c); result |= _BV(c);
} }
@ -137,9 +137,9 @@ uint16_t ATMegaKeyboard::debounceMaskForRow(uint8_t row) {
} }
void ATMegaKeyboard::debounceRow(uint16_t change, uint8_t row) { void ATMegaKeyboard::debounceRow(uint16_t change, uint8_t row) {
for (uint16_t i = 0; i < KeyboardHardware.matrix_columns; ++i) { for (uint16_t i = 0; i < Kaleidoscope.device().matrix_columns; ++i) {
if (change & _BV(i)) { if (change & _BV(i)) {
KeyboardHardware.debounce_matrix_[row][i] = debounce; Kaleidoscope.device().debounce_matrix_[row][i] = debounce;
} }
} }
} }

@ -130,7 +130,7 @@ struct cRGB {
volatile uint8_t BOARD::debounce_matrix_[matrix_rows][matrix_columns]; \ volatile uint8_t BOARD::debounce_matrix_[matrix_rows][matrix_columns]; \
\ \
ISR(TIMER1_OVF_vect) { \ ISR(TIMER1_OVF_vect) { \
KeyboardHardware.readMatrix(); \ Kaleidoscope.device().readMatrix(); \
} }
namespace kaleidoscope { namespace kaleidoscope {

@ -36,10 +36,10 @@ namespace device {
namespace ez { namespace ez {
ErgoDoxScanner ErgoDox::scanner_; ErgoDoxScanner ErgoDox::scanner_;
uint8_t ErgoDox::previousKeyState_[ROWS]; uint8_t ErgoDox::previousKeyState_[matrix_rows];
uint8_t ErgoDox::keyState_[ROWS]; uint8_t ErgoDox::keyState_[matrix_rows];
uint8_t ErgoDox::masks_[ROWS]; uint8_t ErgoDox::masks_[matrix_rows];
uint8_t ErgoDox::debounce_matrix_[ROWS][COLS]; uint8_t ErgoDox::debounce_matrix_[matrix_rows][matrix_columns];
uint8_t ErgoDox::debounce = 5; uint8_t ErgoDox::debounce = 5;
static bool do_scan_ = 1; static bool do_scan_ = 1;
@ -96,20 +96,20 @@ void __attribute__((optimize(3))) ErgoDox::readMatrix() {
scanner_.reattachExpanderOnError(); scanner_.reattachExpanderOnError();
for (uint8_t row = 0; row < ROWS / 2; row++) { for (uint8_t row = 0; row < matrix_rows / 2; row++) {
scanner_.selectExtenderRow(row); scanner_.selectExtenderRow(row);
scanner_.toggleATMegaRow(row); scanner_.toggleATMegaRow(row);
readMatrixRow(row); readMatrixRow(row);
readMatrixRow(row + ROWS / 2); readMatrixRow(row + matrix_rows / 2);
scanner_.toggleATMegaRow(row); scanner_.toggleATMegaRow(row);
} }
} }
void __attribute__((optimize(3))) ErgoDox::actOnMatrixScan() { void __attribute__((optimize(3))) ErgoDox::actOnMatrixScan() {
for (byte row = 0; row < ROWS; row++) { for (byte row = 0; row < matrix_rows; row++) {
for (byte col = 0; col < COLS; col++) { for (byte col = 0; col < matrix_columns; col++) {
uint8_t keyState = (bitRead(previousKeyState_[row], col) << 0) | uint8_t keyState = (bitRead(previousKeyState_[row], col) << 0) |
(bitRead(keyState_[row], col) << 1); (bitRead(keyState_[row], col) << 1);
if (keyState) if (keyState)
@ -205,7 +205,7 @@ void ErgoDox::resetDevice() {
uint8_t ErgoDox::debounceMaskForRow(uint8_t row) { uint8_t ErgoDox::debounceMaskForRow(uint8_t row) {
uint8_t result = 0; uint8_t result = 0;
for (uint8_t c = 0; c < COLS; ++c) { for (uint8_t c = 0; c < matrix_columns; ++c) {
if (debounce_matrix_[row][c]) { if (debounce_matrix_[row][c]) {
--debounce_matrix_[row][c]; --debounce_matrix_[row][c];
} else { } else {
@ -216,7 +216,7 @@ uint8_t ErgoDox::debounceMaskForRow(uint8_t row) {
} }
void ErgoDox::debounceRow(uint8_t change, uint8_t row) { void ErgoDox::debounceRow(uint8_t change, uint8_t row) {
for (uint8_t i = 0; i < COLS; ++i) { for (uint8_t i = 0; i < matrix_columns; ++i) {
if (change & (1 << i)) { if (change & (1 << i)) {
debounce_matrix_[row][i] = debounce; debounce_matrix_[row][i] = debounce;
} }
@ -244,7 +244,7 @@ bool ErgoDox::wasKeyswitchPressed(uint8_t keyIndex) {
uint8_t ErgoDox::previousPressedKeyswitchCount() { uint8_t ErgoDox::previousPressedKeyswitchCount() {
uint8_t count = 0; uint8_t count = 0;
for (uint8_t r = 0; r < ROWS; r++) { for (uint8_t r = 0; r < matrix_rows; r++) {
count += __builtin_popcount(previousKeyState_[r]); count += __builtin_popcount(previousKeyState_[r]);
} }
return count; return count;
@ -253,7 +253,7 @@ uint8_t ErgoDox::previousPressedKeyswitchCount() {
uint8_t ErgoDox::pressedKeyswitchCount() { uint8_t ErgoDox::pressedKeyswitchCount() {
uint8_t count = 0; uint8_t count = 0;
for (uint8_t r = 0; r < ROWS; r++) { for (uint8_t r = 0; r < matrix_rows; r++) {
count += __builtin_popcount(keyState_[r]); count += __builtin_popcount(keyState_[r]);
} }
return count; return count;
@ -263,7 +263,6 @@ uint8_t ErgoDox::pressedKeyswitchCount() {
} }
} }
HARDWARE_IMPLEMENTATION KeyboardHardware; kaleidoscope::device::ez::ErgoDox &ErgoDox = kaleidoscope_internal::device;
kaleidoscope::device::ez::ErgoDox &ErgoDox = KeyboardHardware;
#endif #endif

@ -31,7 +31,6 @@
#include "kaleidoscope/device/ez/ErgoDox/ErgoDoxScanner.h" #include "kaleidoscope/device/ez/ErgoDox/ErgoDoxScanner.h"
#define HARDWARE_IMPLEMENTATION kaleidoscope::device::ez::ErgoDox
#include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h" #include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h"
#include "kaleidoscope/macro_helpers.h" #include "kaleidoscope/macro_helpers.h"
@ -154,6 +153,9 @@ class ErgoDox : public kaleidoscope::Hardware {
r0c13, r1c13, r2c13, r3c13, r4c13, dflt r0c13, r1c13, r2c13, r3c13, r4c13, dflt
} }
} }
typedef kaleidoscope::device::ez::ErgoDox Device;
} }
extern kaleidoscope::device::ez::ErgoDox DEPRECATED(NAMED_HARDWARE) &ErgoDox; extern kaleidoscope::device::ez::ErgoDox DEPRECATED(NAMED_HARDWARE) &ErgoDox;

@ -56,7 +56,6 @@ void KBD4x::resetDevice() {
} }
} }
HARDWARE_IMPLEMENTATION KeyboardHardware; kaleidoscope::device::kbdfans::KBD4x &KBD4x = kaleidoscope_internal::device;
kaleidoscope::device::kbdfans::KBD4x &KBD4x = KeyboardHardware;
#endif #endif

@ -20,7 +20,6 @@
#ifdef ARDUINO_AVR_KBD4X #ifdef ARDUINO_AVR_KBD4X
#include <Arduino.h> #include <Arduino.h>
#define HARDWARE_IMPLEMENTATION kaleidoscope::device::kbdfans::KBD4x
#include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h" #include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h"
#include "kaleidoscope/macro_helpers.h" #include "kaleidoscope/macro_helpers.h"
@ -63,8 +62,10 @@ class KBD4x: public kaleidoscope::device::ATMegaKeyboard {
R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \ R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \
R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C5, R3C7, R3C8, R3C9, R3C10, R3C11 R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C5, R3C7, R3C8, R3C9, R3C10, R3C11
} }
} }
typedef kaleidoscope::device::kbdfans::KBD4x Device;
} }
extern kaleidoscope::device::kbdfans::KBD4x DEPRECATED(NAMED_HARDWARE) &KBD4x; extern kaleidoscope::device::kbdfans::KBD4x DEPRECATED(NAMED_HARDWARE) &KBD4x;

@ -25,13 +25,10 @@
* zero as a sentinel. This is important, because when we initialize arrays with * zero as a sentinel. This is important, because when we initialize arrays with
* fewer elements than the declared array size, the remaining elements will be * fewer elements than the declared array size, the remaining elements will be
* zero. We can use this to avoid having to explicitly add a sentinel in * zero. We can use this to avoid having to explicitly add a sentinel in
* user-facing code. * user-facing code. */
* constexpr uint8_t keyIndex(uint8_t row, uint8_t col) {
* We're using a macro instead of a constexpr so that it is evaluated lazily, return KeyAddr(row, col).toInt() + 1;
* when `HARDWARE_IMPLEMENTATION` can be properly resolved. }
*/
#define keyIndex(row,col) \
(uint8_t)(KeyAddr(row, col).toInt() + 1)
constexpr uint8_t R0C0 = keyIndex(0, 0); constexpr uint8_t R0C0 = keyIndex(0, 0);
constexpr uint8_t R0C1 = keyIndex(0, 1); constexpr uint8_t R0C1 = keyIndex(0, 1);

@ -86,7 +86,7 @@ void Model01::enableHardwareTestMode() {
PORTB |= (1 << 0); PORTB |= (1 << 0);
// Disable the debouncer on the ATTinys // Disable the debouncer on the ATTinys
KeyboardHardware.setKeyscanInterval(2); Kaleidoscope.device().setKeyscanInterval(2);
} }
@ -335,7 +335,5 @@ uint8_t Model01::previousPressedKeyswitchCount() {
} }
} }
HARDWARE_IMPLEMENTATION KeyboardHardware;
#endif #endif
#endif #endif

@ -21,7 +21,6 @@
#include <Arduino.h> #include <Arduino.h>
#define HARDWARE_IMPLEMENTATION kaleidoscope::device::keyboardio::Model01
#include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h" #include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h"
#include "KeyboardioScanner.h" #include "KeyboardioScanner.h"
@ -123,6 +122,9 @@ class Model01 : public kaleidoscope::Hardware {
} }
} }
typedef kaleidoscope::device::keyboardio::Model01 Device;
} }
#define PER_KEY_DATA_STACKED(dflt, \ #define PER_KEY_DATA_STACKED(dflt, \

@ -31,7 +31,6 @@ constexpr int8_t Planck::led_count;
} }
} }
HARDWARE_IMPLEMENTATION KeyboardHardware; kaleidoscope::device::olkb::Planck &Planck = kaleidoscope_internal::device;
kaleidoscope::device::olkb::Planck &Planck = KeyboardHardware;
#endif #endif

@ -20,7 +20,6 @@
#ifdef ARDUINO_AVR_PLANCK #ifdef ARDUINO_AVR_PLANCK
#include <Arduino.h> #include <Arduino.h>
#define HARDWARE_IMPLEMENTATION kaleidoscope::device::olkb::Planck
#include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h" #include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h"
#include "kaleidoscope/macro_helpers.h" #include "kaleidoscope/macro_helpers.h"
@ -59,8 +58,10 @@ class Planck: public kaleidoscope::device::ATMegaKeyboard {
R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11
} }
} }
typedef kaleidoscope::device::olkb::Planck Device;
} }
extern kaleidoscope::device::olkb::Planck DEPRECATED(NAMED_HARDWARE) &Planck; extern kaleidoscope::device::olkb::Planck DEPRECATED(NAMED_HARDWARE) &Planck;

@ -38,7 +38,6 @@ constexpr int8_t Splitography::led_count;
} }
} }
HARDWARE_IMPLEMENTATION KeyboardHardware; kaleidoscope::device::softhruf::Splitography &Splitography = kaleidoscope_internal::device;
kaleidoscope::device::softhruf::Splitography &Splitography = KeyboardHardware;
#endif #endif

@ -27,7 +27,6 @@
#ifdef ARDUINO_AVR_SPLITOGRAPHY #ifdef ARDUINO_AVR_SPLITOGRAPHY
#include <Arduino.h> #include <Arduino.h>
#define HARDWARE_IMPLEMENTATION kaleidoscope::device::softhruf::Splitography
#include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h" #include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h"
#include "kaleidoscope/macro_helpers.h" #include "kaleidoscope/macro_helpers.h"
@ -86,6 +85,9 @@ class Splitography: public kaleidoscope::device::ATMegaKeyboard {
} }
} }
typedef kaleidoscope::device::softhruf::Splitography Device;
} }
extern kaleidoscope::device::softhruf::Splitography DEPRECATED(NAMED_HARDWARE) &Splitography; extern kaleidoscope::device::softhruf::Splitography DEPRECATED(NAMED_HARDWARE) &Splitography;

@ -76,7 +76,6 @@ void Atreus::resetDevice() {
} }
} }
HARDWARE_IMPLEMENTATION KeyboardHardware; kaleidoscope::device::technomancy::Atreus &Atreus = kaleidoscope_internal::device;
kaleidoscope::device::technomancy::Atreus &Atreus = KeyboardHardware;
#endif #endif

@ -27,7 +27,6 @@
#ifdef ARDUINO_AVR_ATREUS #ifdef ARDUINO_AVR_ATREUS
#include <Arduino.h> #include <Arduino.h>
#define HARDWARE_IMPLEMENTATION kaleidoscope::device::technomancy::Atreus
#include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h" #include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h"
#include "kaleidoscope/macro_helpers.h" #include "kaleidoscope/macro_helpers.h"
@ -103,6 +102,9 @@ class Atreus: public kaleidoscope::device::ATMegaKeyboard {
R3C0, R3C1, R3C2, R3C3, R3C4, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 R3C0, R3C1, R3C2, R3C3, R3C4, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11
} }
} }
typedef kaleidoscope::device::technomancy::Atreus Device;
} }
extern kaleidoscope::device::technomancy::Atreus DEPRECATED(NAMED_HARDWARE) &Atreus; extern kaleidoscope::device::technomancy::Atreus DEPRECATED(NAMED_HARDWARE) &Atreus;

@ -32,7 +32,6 @@ constexpr int8_t Atreus2::led_count;
} }
} }
HARDWARE_IMPLEMENTATION KeyboardHardware; kaleidoscope::device::technomancy::Atreus2 &Atreus2 = kaleidoscope_internal::device;
kaleidoscope::device::technomancy::Atreus2 &Atreus2 = KeyboardHardware;
#endif #endif

@ -21,7 +21,6 @@
#ifdef ARDUINO_AVR_ATREUS2 #ifdef ARDUINO_AVR_ATREUS2
#include <Arduino.h> #include <Arduino.h>
#define HARDWARE_IMPLEMENTATION kaleidoscope::device::technomancy::Atreus2
#include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h" #include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h"
#include "kaleidoscope/macro_helpers.h" #include "kaleidoscope/macro_helpers.h"
@ -80,6 +79,9 @@ class Atreus2: public kaleidoscope::device::ATMegaKeyboard {
R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11
} }
} }
typedef kaleidoscope::device::technomancy::Atreus2 Device;
} }
extern kaleidoscope::device::technomancy::Atreus2 DEPRECATED(NAMED_HARDWARE) &Atreus2; extern kaleidoscope::device::technomancy::Atreus2 DEPRECATED(NAMED_HARDWARE) &Atreus2;

@ -96,9 +96,9 @@ void handleKeyswitchEvent(Key mappedKey, KeyAddr key_addr, uint8_t keyState) {
* See layers.cpp for an example that masks keys, and the reason why it does * See layers.cpp for an example that masks keys, and the reason why it does
* so. * so.
*/ */
if (KeyboardHardware.isKeyMasked(key_addr)) { if (Kaleidoscope.device().isKeyMasked(key_addr)) {
if (keyToggledOff(keyState)) { if (keyToggledOff(keyState)) {
KeyboardHardware.unMaskKey(key_addr); Kaleidoscope.device().unMaskKey(key_addr);
} else { } else {
return; return;
} }

@ -18,7 +18,7 @@
#include "kaleidoscope/key_defs.h" #include "kaleidoscope/key_defs.h"
extern const Key keymaps_linear[][ROWS * COLS]; extern const Key keymaps_linear[][kaleidoscope_internal::device.matrix_rows * kaleidoscope_internal::device.matrix_columns];
namespace kaleidoscope { namespace kaleidoscope {
@ -58,7 +58,7 @@ class Keymaps2DInterface {
}; };
KeymapRow operator[](uint8_t row) { KeymapRow operator[](uint8_t row) {
return KeymapRow(keymap_layer_ + row * COLS); return KeymapRow(keymap_layer_ + row * kaleidoscope_internal::device.matrix_columns);
} }
}; };

@ -33,13 +33,13 @@ __attribute__((weak))
uint8_t layer_count = 0; uint8_t layer_count = 0;
__attribute__((weak)) __attribute__((weak))
extern const Key keymaps_linear[][ROWS * COLS] = {}; extern const Key keymaps_linear[][kaleidoscope_internal::device.matrix_rows * kaleidoscope_internal::device.matrix_columns] = {};
namespace kaleidoscope { namespace kaleidoscope {
uint32_t Layer_::layer_state_; uint32_t Layer_::layer_state_;
uint8_t Layer_::top_active_layer_; uint8_t Layer_::top_active_layer_;
Key Layer_::live_composite_keymap_[KeyboardHardware.numKeys()]; Key Layer_::live_composite_keymap_[Kaleidoscope.device().numKeys()];
uint8_t Layer_::active_layers_[KeyboardHardware.numKeys()]; uint8_t Layer_::active_layers_[Kaleidoscope.device().numKeys()];
Key(*Layer_::getKey)(uint8_t layer, KeyAddr key_addr) = Layer.getKeyFromPROGMEM; Key(*Layer_::getKey)(uint8_t layer, KeyAddr key_addr) = Layer.getKeyFromPROGMEM;
void Layer_::handleKeymapKeyswitchEvent(Key keymapEntry, uint8_t keyState) { void Layer_::handleKeymapKeyswitchEvent(Key keymapEntry, uint8_t keyState) {
@ -111,7 +111,7 @@ void Layer_::updateLiveCompositeKeymap(KeyAddr key_addr) {
} }
void Layer_::updateActiveLayers(void) { void Layer_::updateActiveLayers(void) {
memset(active_layers_, 0, KeyboardHardware.numKeys()); memset(active_layers_, 0, Kaleidoscope.device().numKeys());
for (auto key_addr : KeyAddr::all()) { for (auto key_addr : KeyAddr::all()) {
int8_t layer = top_active_layer_; int8_t layer = top_active_layer_;

@ -20,12 +20,13 @@
#include "kaleidoscope/key_defs.h" #include "kaleidoscope/key_defs.h"
#include "kaleidoscope/keymaps.h" #include "kaleidoscope/keymaps.h"
#include KALEIDOSCOPE_HARDWARE_H #include KALEIDOSCOPE_HARDWARE_H
#include "kaleidoscope_internal/device.h"
// Macro for defining the keymap. This should be used in the sketch // Macro for defining the keymap. This should be used in the sketch
// file (*.ino) to define the keymap[] array that holds the user's // file (*.ino) to define the keymap[] array that holds the user's
// layers. It also computes the number of layers in that keymap. // layers. It also computes the number of layers in that keymap.
#define KEYMAPS(layers...) __NL__ \ #define KEYMAPS(layers...) __NL__ \
const Key keymaps_linear[][ROWS*COLS] PROGMEM = { layers }; __NL__ \ const Key keymaps_linear[][kaleidoscope_internal::device.matrix_rows * kaleidoscope_internal::device.matrix_columns] PROGMEM = { layers }; __NL__ \
uint8_t layer_count __NL__ \ uint8_t layer_count __NL__ \
= sizeof(keymaps_linear) / sizeof(*keymaps_linear); __NL__ \ = sizeof(keymaps_linear) / sizeof(*keymaps_linear); __NL__ \
__NL__ \ __NL__ \
@ -134,8 +135,8 @@ class Layer_ {
private: private:
static uint32_t layer_state_; static uint32_t layer_state_;
static uint8_t top_active_layer_; static uint8_t top_active_layer_;
static Key live_composite_keymap_[KeyboardHardware.numKeys()]; static Key live_composite_keymap_[kaleidoscope_internal::device.numKeys()];
static uint8_t active_layers_[KeyboardHardware.numKeys()]; static uint8_t active_layers_[kaleidoscope_internal::device.numKeys()];
static void handleKeymapKeyswitchEvent(Key keymapEntry, uint8_t keyState); static void handleKeymapKeyswitchEvent(Key keymapEntry, uint8_t keyState);
static void updateTopActiveLayer(void); static void updateTopActiveLayer(void);

@ -49,7 +49,7 @@ static void playKeyCode(Key key, uint8_t keyStates, bool explicit_report) {
static void readKeyCodeAndPlay(uint16_t pos, uint8_t flags, uint8_t keyStates, bool explicit_report) { static void readKeyCodeAndPlay(uint16_t pos, uint8_t flags, uint8_t keyStates, bool explicit_report) {
Key key; Key key;
key.flags = flags; key.flags = flags;
key.keyCode = KeyboardHardware.storage().read(pos++); key.keyCode = Kaleidoscope.storage().read(pos++);
playKeyCode(key, keyStates, explicit_report); playKeyCode(key, keyStates, explicit_report);
} }
@ -63,7 +63,7 @@ void DynamicMacros::updateDynamicMacroCache(void) {
map_[0] = 0; map_[0] = 0;
while (pos < storage_base_ + storage_size_) { while (pos < storage_base_ + storage_size_) {
macro = KeyboardHardware.storage().read(pos++); macro = Kaleidoscope.storage().read(pos++);
switch (macro) { switch (macro) {
case MACRO_ACTION_STEP_EXPLICIT_REPORT: case MACRO_ACTION_STEP_EXPLICIT_REPORT:
case MACRO_ACTION_STEP_IMPLICIT_REPORT: case MACRO_ACTION_STEP_IMPLICIT_REPORT:
@ -91,8 +91,8 @@ void DynamicMacros::updateDynamicMacroCache(void) {
previous_macro_ended = false; previous_macro_ended = false;
uint8_t keyCode, flags; uint8_t keyCode, flags;
do { do {
flags = KeyboardHardware.storage().read(pos++); flags = Kaleidoscope.storage().read(pos++);
keyCode = KeyboardHardware.storage().read(pos++); keyCode = Kaleidoscope.storage().read(pos++);
} while (!(flags == 0 && keyCode == 0)); } while (!(flags == 0 && keyCode == 0));
break; break;
} }
@ -101,7 +101,7 @@ void DynamicMacros::updateDynamicMacroCache(void) {
previous_macro_ended = false; previous_macro_ended = false;
uint8_t keyCode, flags; uint8_t keyCode, flags;
do { do {
keyCode = KeyboardHardware.storage().read(pos++); keyCode = Kaleidoscope.storage().read(pos++);
} while (keyCode != 0); } while (keyCode != 0);
break; break;
} }
@ -128,7 +128,7 @@ void DynamicMacros::play(uint8_t macro_id) {
pos = storage_base_ + map_[macro_id]; pos = storage_base_ + map_[macro_id];
while (true) { while (true) {
switch (macro = KeyboardHardware.storage().read(pos++)) { switch (macro = Kaleidoscope.storage().read(pos++)) {
case MACRO_ACTION_STEP_EXPLICIT_REPORT: case MACRO_ACTION_STEP_EXPLICIT_REPORT:
explicit_report = true; explicit_report = true;
break; break;
@ -140,23 +140,23 @@ void DynamicMacros::play(uint8_t macro_id) {
kaleidoscope::hid::sendMouseReport(); kaleidoscope::hid::sendMouseReport();
break; break;
case MACRO_ACTION_STEP_INTERVAL: case MACRO_ACTION_STEP_INTERVAL:
interval = KeyboardHardware.storage().read(pos++); interval = Kaleidoscope.storage().read(pos++);
break; break;
case MACRO_ACTION_STEP_WAIT: { case MACRO_ACTION_STEP_WAIT: {
uint8_t wait = KeyboardHardware.storage().read(pos++); uint8_t wait = Kaleidoscope.storage().read(pos++);
delay(wait); delay(wait);
break; break;
} }
case MACRO_ACTION_STEP_KEYDOWN: case MACRO_ACTION_STEP_KEYDOWN:
flags = KeyboardHardware.storage().read(pos++); flags = Kaleidoscope.storage().read(pos++);
readKeyCodeAndPlay(pos++, flags, IS_PRESSED, explicit_report); readKeyCodeAndPlay(pos++, flags, IS_PRESSED, explicit_report);
break; break;
case MACRO_ACTION_STEP_KEYUP: case MACRO_ACTION_STEP_KEYUP:
flags = KeyboardHardware.storage().read(pos++); flags = Kaleidoscope.storage().read(pos++);
readKeyCodeAndPlay(pos++, flags, WAS_PRESSED, explicit_report); readKeyCodeAndPlay(pos++, flags, WAS_PRESSED, explicit_report);
break; break;
case MACRO_ACTION_STEP_TAP: case MACRO_ACTION_STEP_TAP:
flags = KeyboardHardware.storage().read(pos++); flags = Kaleidoscope.storage().read(pos++);
readKeyCodeAndPlay(pos++, flags, IS_PRESSED | WAS_PRESSED, false); readKeyCodeAndPlay(pos++, flags, IS_PRESSED | WAS_PRESSED, false);
break; break;
@ -173,8 +173,8 @@ void DynamicMacros::play(uint8_t macro_id) {
case MACRO_ACTION_STEP_TAP_SEQUENCE: { case MACRO_ACTION_STEP_TAP_SEQUENCE: {
uint8_t keyCode; uint8_t keyCode;
do { do {
flags = KeyboardHardware.storage().read(pos++); flags = Kaleidoscope.storage().read(pos++);
keyCode = KeyboardHardware.storage().read(pos++); keyCode = Kaleidoscope.storage().read(pos++);
playKeyCode(Key(keyCode, flags), IS_PRESSED | WAS_PRESSED, false); playKeyCode(Key(keyCode, flags), IS_PRESSED | WAS_PRESSED, false);
delay(interval); delay(interval);
} while (!(flags == 0 && keyCode == 0)); } while (!(flags == 0 && keyCode == 0));
@ -183,7 +183,7 @@ void DynamicMacros::play(uint8_t macro_id) {
case MACRO_ACTION_STEP_TAP_CODE_SEQUENCE: { case MACRO_ACTION_STEP_TAP_CODE_SEQUENCE: {
uint8_t keyCode; uint8_t keyCode;
do { do {
keyCode = KeyboardHardware.storage().read(pos++); keyCode = Kaleidoscope.storage().read(pos++);
playKeyCode(Key(keyCode, 0), IS_PRESSED | WAS_PRESSED, false); playKeyCode(Key(keyCode, 0), IS_PRESSED | WAS_PRESSED, false);
delay(interval); delay(interval);
} while (keyCode != 0); } while (keyCode != 0);
@ -221,7 +221,7 @@ EventHandlerResult DynamicMacros::onFocusEvent(const char *command) {
if (::Focus.isEOL()) { if (::Focus.isEOL()) {
for (uint16_t i = 0; i < storage_size_; i++) { for (uint16_t i = 0; i < storage_size_; i++) {
uint8_t b; uint8_t b;
b = KeyboardHardware.storage().read(storage_base_ + i); b = Kaleidoscope.storage().read(storage_base_ + i);
::Focus.send(b); ::Focus.send(b);
} }
} else { } else {
@ -231,7 +231,7 @@ EventHandlerResult DynamicMacros::onFocusEvent(const char *command) {
uint8_t b; uint8_t b;
::Focus.read(b); ::Focus.read(b);
KeyboardHardware.storage().update(storage_base_ + pos++, b); Kaleidoscope.storage().update(storage_base_ + pos++, b);
} }
updateDynamicMacroCache(); updateDynamicMacroCache();
} }

@ -56,10 +56,10 @@ EventHandlerResult EEPROMKeymapProgrammer::onKeyswitchEvent(Key &mapped_key, Key
if (state_ == WAIT_FOR_KEY) { if (state_ == WAIT_FOR_KEY) {
if (keyToggledOn(key_state)) { if (keyToggledOn(key_state)) {
update_position_ = Layer.top() * KeyboardHardware.numKeys() + key_addr.toInt(); update_position_ = Layer.top() * Kaleidoscope.device().numKeys() + key_addr.toInt();
} }
if (keyToggledOff(key_state)) { if (keyToggledOff(key_state)) {
if ((uint16_t)(Layer.top() * KeyboardHardware.numKeys() + key_addr.toInt()) == update_position_) if ((uint16_t)(Layer.top() * Kaleidoscope.device().numKeys() + key_addr.toInt()) == update_position_)
nextState(); nextState();
} }
return EventHandlerResult::EVENT_CONSUMED; return EventHandlerResult::EVENT_CONSUMED;

@ -44,7 +44,7 @@ void EEPROMKeymap::setup(uint8_t max) {
void EEPROMKeymap::max_layers(uint8_t max) { void EEPROMKeymap::max_layers(uint8_t max) {
max_layers_ = max; max_layers_ = max;
keymap_base_ = ::EEPROMSettings.requestSlice(max_layers_ * KeyboardHardware.numKeys() * 2); keymap_base_ = ::EEPROMSettings.requestSlice(max_layers_ * Kaleidoscope.device().numKeys() * 2);
} }
Key EEPROMKeymap::getKey(uint8_t layer, KeyAddr key_addr) { Key EEPROMKeymap::getKey(uint8_t layer, KeyAddr key_addr) {
@ -53,10 +53,10 @@ Key EEPROMKeymap::getKey(uint8_t layer, KeyAddr key_addr) {
if (layer >= max_layers_) if (layer >= max_layers_)
return Key_NoKey; return Key_NoKey;
uint16_t pos = ((layer * KeyboardHardware.numKeys()) + key_addr.toInt()) * 2; uint16_t pos = ((layer * Kaleidoscope.device().numKeys()) + key_addr.toInt()) * 2;
key.flags = KeyboardHardware.storage().read(keymap_base_ + pos); key.flags = Kaleidoscope.storage().read(keymap_base_ + pos);
key.keyCode = KeyboardHardware.storage().read(keymap_base_ + pos + 1); key.keyCode = Kaleidoscope.storage().read(keymap_base_ + pos + 1);
return key; return key;
} }
@ -77,8 +77,8 @@ uint16_t EEPROMKeymap::keymap_base(void) {
} }
void EEPROMKeymap::updateKey(uint16_t base_pos, Key key) { void EEPROMKeymap::updateKey(uint16_t base_pos, Key key) {
KeyboardHardware.storage().update(keymap_base_ + base_pos * 2, key.flags); Kaleidoscope.storage().update(keymap_base_ + base_pos * 2, key.flags);
KeyboardHardware.storage().update(keymap_base_ + base_pos * 2 + 1, key.keyCode); Kaleidoscope.storage().update(keymap_base_ + base_pos * 2 + 1, key.keyCode);
} }
void EEPROMKeymap::dumpKeymap(uint8_t layers, Key(*getkey)(uint8_t, KeyAddr)) { void EEPROMKeymap::dumpKeymap(uint8_t layers, Key(*getkey)(uint8_t, KeyAddr)) {
@ -150,7 +150,7 @@ EventHandlerResult EEPROMKeymap::onFocusEvent(const char *command) {
} else { } else {
uint16_t i = 0; uint16_t i = 0;
while (!::Focus.isEOL() && (i < (uint16_t)KeyboardHardware.numKeys() * max_layers_)) { while (!::Focus.isEOL() && (i < (uint16_t)Kaleidoscope.device().numKeys() * max_layers_)) {
Key k; Key k;
::Focus.read(k); ::Focus.read(k);

@ -28,7 +28,7 @@ bool EEPROMSettings::sealed_;
uint16_t EEPROMSettings::next_start_ = sizeof(EEPROMSettings::settings); uint16_t EEPROMSettings::next_start_ = sizeof(EEPROMSettings::settings);
EventHandlerResult EEPROMSettings::onSetup() { EventHandlerResult EEPROMSettings::onSetup() {
KeyboardHardware.storage().get(0, settings_); Kaleidoscope.storage().get(0, settings_);
/* If the version is undefined, set up sensible defaults. */ /* If the version is undefined, set up sensible defaults. */
if (settings_.version == VERSION_UNDEFINED) { if (settings_.version == VERSION_UNDEFINED) {
@ -49,7 +49,7 @@ EventHandlerResult EEPROMSettings::onSetup() {
* not able to catch all writes yet. For the sake of consistency, if we * not able to catch all writes yet. For the sake of consistency, if we
* encounter a firmware with no version defined, we'll set sensible * encounter a firmware with no version defined, we'll set sensible
* defaults. */ * defaults. */
KeyboardHardware.storage().put(0, settings_); Kaleidoscope.storage().put(0, settings_);
} }
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
@ -146,7 +146,7 @@ uint16_t EEPROMSettings::used(void) {
} }
void EEPROMSettings::update(void) { void EEPROMSettings::update(void) {
KeyboardHardware.storage().put(0, settings_); Kaleidoscope.storage().put(0, settings_);
is_valid_ = true; is_valid_ = true;
} }
@ -220,22 +220,22 @@ EventHandlerResult FocusEEPROMCommand::onFocusEvent(const char *command) {
switch (sub_command) { switch (sub_command) {
case CONTENTS: { case CONTENTS: {
if (::Focus.isEOL()) { if (::Focus.isEOL()) {
for (uint16_t i = 0; i < KeyboardHardware.storage().length(); i++) { for (uint16_t i = 0; i < Kaleidoscope.storage().length(); i++) {
uint8_t d = KeyboardHardware.storage().read(i); uint8_t d = Kaleidoscope.storage().read(i);
::Focus.send(d); ::Focus.send(d);
} }
} else { } else {
for (uint16_t i = 0; i < KeyboardHardware.storage().length() && !::Focus.isEOL(); i++) { for (uint16_t i = 0; i < Kaleidoscope.storage().length() && !::Focus.isEOL(); i++) {
uint8_t d; uint8_t d;
::Focus.read(d); ::Focus.read(d);
KeyboardHardware.storage().update(i, d); Kaleidoscope.storage().update(i, d);
} }
} }
break; break;
} }
case FREE: case FREE:
::Focus.send(KeyboardHardware.storage().length() - ::EEPROMSettings.used()); ::Focus.send(Kaleidoscope.storage().length() - ::EEPROMSettings.used());
break; break;
} }

@ -32,7 +32,7 @@ EventHandlerResult EscapeOneShot::onKeyswitchEvent(Key &mapped_key, KeyAddr key_
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
KeyboardHardware.maskKey(key_addr); Kaleidoscope.device().maskKey(key_addr);
::OneShot.cancel(true); ::OneShot.cancel(true);
return EventHandlerResult::EVENT_CONSUMED; return EventHandlerResult::EVENT_CONSUMED;

@ -58,7 +58,7 @@ EventHandlerResult FingerPainter::onKeyswitchEvent(Key &mapped_key, KeyAddr key_
// TODO: The following works only for keyboards with LEDs for each key. // TODO: The following works only for keyboards with LEDs for each key.
uint8_t color_index = ::LEDPaletteTheme.lookupColorIndexAtPosition(color_base_, KeyboardHardware.getLedIndex(key_addr)); uint8_t color_index = ::LEDPaletteTheme.lookupColorIndexAtPosition(color_base_, Kaleidoscope.device().getLedIndex(key_addr));
// Find the next color in the palette that is different. // Find the next color in the palette that is different.
// But do not loop forever! // But do not loop forever!
@ -75,7 +75,7 @@ EventHandlerResult FingerPainter::onKeyswitchEvent(Key &mapped_key, KeyAddr key_
new_color = ::LEDPaletteTheme.lookupPaletteColor(color_index); new_color = ::LEDPaletteTheme.lookupPaletteColor(color_index);
} }
::LEDPaletteTheme.updateColorIndexAtPosition(color_base_, KeyboardHardware.getLedIndex(key_addr), color_index); ::LEDPaletteTheme.updateColorIndexAtPosition(color_base_, Kaleidoscope.device().getLedIndex(key_addr), color_index);
return EventHandlerResult::EVENT_CONSUMED; return EventHandlerResult::EVENT_CONSUMED;
} }
@ -100,8 +100,8 @@ EventHandlerResult FingerPainter::onFocusEvent(const char *command) {
return EventHandlerResult::OK; return EventHandlerResult::OK;
if (sub_command == CLEAR) { if (sub_command == CLEAR) {
for (uint16_t i = 0; i < KeyboardHardware.numKeys() / 2; i++) { for (uint16_t i = 0; i < Kaleidoscope.device().numKeys() / 2; i++) {
KeyboardHardware.storage().update(color_base_ + i, 0); Kaleidoscope.storage().update(color_base_ + i, 0);
} }
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }

@ -27,20 +27,20 @@ namespace plugin {
char FocusSerial::command_[32]; char FocusSerial::command_[32];
void FocusSerial::drain(void) { void FocusSerial::drain(void) {
if (KeyboardHardware.serialPort().available()) if (Kaleidoscope.serialPort().available())
while (KeyboardHardware.serialPort().peek() != '\n') while (Kaleidoscope.serialPort().peek() != '\n')
KeyboardHardware.serialPort().read(); Kaleidoscope.serialPort().read();
} }
EventHandlerResult FocusSerial::beforeReportingState() { EventHandlerResult FocusSerial::beforeReportingState() {
if (KeyboardHardware.serialPort().available() == 0) if (Kaleidoscope.serialPort().available() == 0)
return EventHandlerResult::OK; return EventHandlerResult::OK;
uint8_t i = 0; uint8_t i = 0;
do { do {
command_[i++] = KeyboardHardware.serialPort().read(); command_[i++] = Kaleidoscope.serialPort().read();
if (KeyboardHardware.serialPort().peek() == '\n') if (Kaleidoscope.serialPort().peek() == '\n')
break; break;
} while (command_[i - 1] != ' ' && i < 32); } while (command_[i - 1] != ' ' && i < 32);
if (command_[i - 1] == ' ') if (command_[i - 1] == ' ')
@ -50,12 +50,12 @@ EventHandlerResult FocusSerial::beforeReportingState() {
Kaleidoscope.onFocusEvent(command_); Kaleidoscope.onFocusEvent(command_);
KeyboardHardware.serialPort().println(F("\r\n.")); Kaleidoscope.serialPort().println(F("\r\n."));
drain(); drain();
if (KeyboardHardware.serialPort().peek() == '\n') if (Kaleidoscope.serialPort().peek() == '\n')
KeyboardHardware.serialPort().read(); Kaleidoscope.serialPort().read();
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
@ -65,7 +65,7 @@ bool FocusSerial::handleHelp(const char *command,
if (strcmp_P(command, PSTR("help")) != 0) if (strcmp_P(command, PSTR("help")) != 0)
return false; return false;
KeyboardHardware.serialPort().println((const __FlashStringHelper *)help_message); Kaleidoscope.serialPort().println((const __FlashStringHelper *)help_message);
return true; return true;
} }
@ -75,7 +75,7 @@ EventHandlerResult FocusSerial::onFocusEvent(const char *command) {
} }
void FocusSerial::printBool(bool b) { void FocusSerial::printBool(bool b) {
KeyboardHardware.serialPort().print((b) ? F("true") : F("false")); Kaleidoscope.serialPort().print((b) ? F("true") : F("false"));
} }
} }

@ -37,12 +37,12 @@ class FocusSerial : public kaleidoscope::Plugin {
} }
void send(const bool b) { void send(const bool b) {
printBool(b); printBool(b);
KeyboardHardware.serialPort().print(SEPARATOR); Kaleidoscope.serialPort().print(SEPARATOR);
} }
template <typename V> template <typename V>
void send(V v) { void send(V v) {
KeyboardHardware.serialPort().print(v); Kaleidoscope.serialPort().print(v);
KeyboardHardware.serialPort().print(SEPARATOR); Kaleidoscope.serialPort().print(SEPARATOR);
} }
template <typename Var, typename... Vars> template <typename Var, typename... Vars>
void send(Var v, const Vars&... vars) { void send(Var v, const Vars&... vars) {
@ -53,31 +53,31 @@ class FocusSerial : public kaleidoscope::Plugin {
void sendRaw() {} void sendRaw() {}
template <typename Var, typename... Vars> template <typename Var, typename... Vars>
void sendRaw(Var v, const Vars&... vars) { void sendRaw(Var v, const Vars&... vars) {
KeyboardHardware.serialPort().print(v); Kaleidoscope.serialPort().print(v);
sendRaw(vars...); sendRaw(vars...);
} }
const char peek() { const char peek() {
return KeyboardHardware.serialPort().peek(); return Kaleidoscope.serialPort().peek();
} }
void read(Key &key) { void read(Key &key) {
key.raw = KeyboardHardware.serialPort().parseInt(); key.raw = Kaleidoscope.serialPort().parseInt();
} }
void read(cRGB &color) { void read(cRGB &color) {
color.r = KeyboardHardware.serialPort().parseInt(); color.r = Kaleidoscope.serialPort().parseInt();
color.g = KeyboardHardware.serialPort().parseInt(); color.g = Kaleidoscope.serialPort().parseInt();
color.b = KeyboardHardware.serialPort().parseInt(); color.b = Kaleidoscope.serialPort().parseInt();
} }
void read(uint8_t &u8) { void read(uint8_t &u8) {
u8 = KeyboardHardware.serialPort().parseInt(); u8 = Kaleidoscope.serialPort().parseInt();
} }
void read(uint16_t &u16) { void read(uint16_t &u16) {
u16 = KeyboardHardware.serialPort().parseInt(); u16 = Kaleidoscope.serialPort().parseInt();
} }
bool isEOL() { bool isEOL() {
return KeyboardHardware.serialPort().peek() == '\n'; return Kaleidoscope.serialPort().peek() == '\n';
} }
static constexpr char COMMENT = '#'; static constexpr char COMMENT = '#';

@ -39,7 +39,7 @@ EventHandlerResult GeminiPR::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr,
if (keys_held_ == 0) { if (keys_held_ == 0) {
state_[0] |= 0x80; state_[0] |= 0x80;
KeyboardHardware.serialPort().write(state_, sizeof(state_)); Kaleidoscope.serialPort().write(state_, sizeof(state_));
memset(state_, 0, sizeof(state_)); memset(state_, 0, sizeof(state_));
} }
} }

@ -32,9 +32,9 @@ void HardwareTestMode::setActionKey(uint8_t key) {
void HardwareTestMode::waitForKeypress() { void HardwareTestMode::waitForKeypress() {
while (1) { while (1) {
KeyboardHardware.readMatrix(); Kaleidoscope.device().readMatrix();
if (KeyboardHardware.isKeyswitchPressed(actionKey) && if (Kaleidoscope.device().isKeyswitchPressed(actionKey) &&
! KeyboardHardware.wasKeyswitchPressed(actionKey)) { ! Kaleidoscope.device().wasKeyswitchPressed(actionKey)) {
break; break;
} }
} }
@ -76,7 +76,7 @@ void HardwareTestMode::testLeds(void) {
void HardwareTestMode::testMatrix() { void HardwareTestMode::testMatrix() {
// Reset bad keys from previous tests. // Reset bad keys from previous tests.
chatter_data state[KeyboardHardware.numKeys()] = {0, 0, 0}; chatter_data state[Kaleidoscope.device().numKeys()] = {0, 0, 0};
constexpr cRGB red = CRGB(201, 0, 0); constexpr cRGB red = CRGB(201, 0, 0);
constexpr cRGB blue = CRGB(0, 0, 201); constexpr cRGB blue = CRGB(0, 0, 201);
@ -84,12 +84,12 @@ void HardwareTestMode::testMatrix() {
constexpr cRGB yellow = CRGB(201, 100, 0); constexpr cRGB yellow = CRGB(201, 100, 0);
while (1) { while (1) {
KeyboardHardware.readMatrix(); Kaleidoscope.device().readMatrix();
for (auto key_addr : KeyAddr::all()) { for (auto key_addr : KeyAddr::all()) {
uint8_t keynum = key_addr.toInt(); uint8_t keynum = key_addr.toInt();
// If the key is toggled on // If the key is toggled on
if (KeyboardHardware.isKeyswitchPressed(key_addr) && ! KeyboardHardware.wasKeyswitchPressed(key_addr)) { if (Kaleidoscope.device().isKeyswitchPressed(key_addr) && ! Kaleidoscope.device().wasKeyswitchPressed(key_addr)) {
// And it's too soon (in terms of cycles between changes) // And it's too soon (in terms of cycles between changes)
state[keynum].tested = 1; state[keynum].tested = 1;
if (state[keynum].cyclesSinceStateChange < CHATTER_CYCLE_LIMIT) { if (state[keynum].cyclesSinceStateChange < CHATTER_CYCLE_LIMIT) {
@ -100,19 +100,19 @@ void HardwareTestMode::testMatrix() {
state[keynum].cyclesSinceStateChange++; state[keynum].cyclesSinceStateChange++;
} }
// If the key is held down // If the key is held down
if (KeyboardHardware.isKeyswitchPressed(key_addr) && KeyboardHardware.wasKeyswitchPressed(key_addr)) { if (Kaleidoscope.device().isKeyswitchPressed(key_addr) && Kaleidoscope.device().wasKeyswitchPressed(key_addr)) {
KeyboardHardware.setCrgbAt(key_addr, green); Kaleidoscope.device().setCrgbAt(key_addr, green);
} }
// If we triggered chatter detection ever on this key // If we triggered chatter detection ever on this key
else if (state[keynum].bad == 1) { else if (state[keynum].bad == 1) {
KeyboardHardware.setCrgbAt(key_addr, red); Kaleidoscope.device().setCrgbAt(key_addr, red);
} else if (state[keynum].tested == 0) { } else if (state[keynum].tested == 0) {
KeyboardHardware.setCrgbAt(key_addr, yellow); Kaleidoscope.device().setCrgbAt(key_addr, yellow);
} }
// If the key is not currently pressed and was not just released and is not marked bad // If the key is not currently pressed and was not just released and is not marked bad
else if (! KeyboardHardware.isKeyswitchPressed(key_addr)) { else if (! Kaleidoscope.device().isKeyswitchPressed(key_addr)) {
KeyboardHardware.setCrgbAt(key_addr, blue); Kaleidoscope.device().setCrgbAt(key_addr, blue);
} }
} }
::LEDControl.syncLeds(); ::LEDControl.syncLeds();
@ -124,7 +124,7 @@ void HardwareTestMode::runTests() {
// out and send a new report // out and send a new report
kaleidoscope::hid::releaseAllKeys(); kaleidoscope::hid::releaseAllKeys();
kaleidoscope::hid::sendKeyboardReport(); kaleidoscope::hid::sendKeyboardReport();
KeyboardHardware.enableHardwareTestMode(); Kaleidoscope.device().enableHardwareTestMode();
testLeds(); testLeds();
testMatrix(); testMatrix();
} }

@ -59,7 +59,7 @@ class Heatmap : public Plugin,
const Heatmap *parent_; const Heatmap *parent_;
uint16_t heatmap_[KeyboardHardware.numKeys()]; uint16_t heatmap_[Kaleidoscope.device().numKeys()];
uint16_t highest_; uint16_t highest_;
uint16_t last_heatmap_comp_time_; uint16_t last_heatmap_comp_time_;

@ -33,14 +33,14 @@ EventHandlerResult HostOS::onSetup(void) {
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
os_ = (hostos::Type)KeyboardHardware.storage().read(eeprom_slice_); os_ = (hostos::Type)Kaleidoscope.storage().read(eeprom_slice_);
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
void HostOS::os(hostos::Type new_os) { void HostOS::os(hostos::Type new_os) {
os_ = new_os; os_ = new_os;
KeyboardHardware.storage().update(eeprom_slice_, os_); Kaleidoscope.storage().update(eeprom_slice_, os_);
} }
} }

@ -48,7 +48,7 @@ void AlphaSquareEffect::TransientLEDMode::refreshAt(KeyAddr key_addr) {
uint8_t display_col = 2; uint8_t display_col = 2;
Key key = last_key_left_; Key key = last_key_left_;
if (key_addr.col() < COLS / 2) { if (key_addr.col() < Kaleidoscope.device().matrix_columns / 2) {
timed_out = Kaleidoscope.hasTimeExpired(start_time_left_, length); timed_out = Kaleidoscope.hasTimeExpired(start_time_left_, length);
} else { } else {
key = last_key_right_; key = last_key_right_;
@ -81,7 +81,7 @@ EventHandlerResult AlphaSquareEffect::onKeyswitchEvent(Key &mappedKey, KeyAddr k
Key prev_key = this_led_mode->last_key_left_; Key prev_key = this_led_mode->last_key_left_;
if (key_addr.col() < COLS / 2) { if (key_addr.col() < Kaleidoscope.device().matrix_columns / 2) {
this_led_mode->last_key_left_ = mappedKey; this_led_mode->last_key_left_ = mappedKey;
this_led_mode->start_time_left_ = Kaleidoscope.millisAtCycleStart(); this_led_mode->start_time_left_ = Kaleidoscope.millisAtCycleStart();
} else { } else {

@ -28,16 +28,16 @@ uint16_t LEDPaletteTheme::reserveThemes(uint8_t max_themes) {
if (!palette_base_) if (!palette_base_)
palette_base_ = ::EEPROMSettings.requestSlice(16 * sizeof(cRGB)); palette_base_ = ::EEPROMSettings.requestSlice(16 * sizeof(cRGB));
return ::EEPROMSettings.requestSlice(max_themes * KeyboardHardware.led_count / 2); return ::EEPROMSettings.requestSlice(max_themes * Kaleidoscope.device().led_count / 2);
} }
void LEDPaletteTheme::updateHandler(uint16_t theme_base, uint8_t theme) { void LEDPaletteTheme::updateHandler(uint16_t theme_base, uint8_t theme) {
if (!Kaleidoscope.has_leds) if (!Kaleidoscope.has_leds)
return; return;
uint16_t map_base = theme_base + (theme * KeyboardHardware.led_count / 2); uint16_t map_base = theme_base + (theme * Kaleidoscope.device().led_count / 2);
for (uint8_t pos = 0; pos < KeyboardHardware.led_count; pos++) { for (uint8_t pos = 0; pos < Kaleidoscope.device().led_count; pos++) {
cRGB color = lookupColorAtPosition(map_base, pos); cRGB color = lookupColorAtPosition(map_base, pos);
::LEDControl.setCrgbAt(pos, color); ::LEDControl.setCrgbAt(pos, color);
} }
@ -47,8 +47,8 @@ void LEDPaletteTheme::refreshAt(uint16_t theme_base, uint8_t theme, KeyAddr key_
if (!Kaleidoscope.has_leds) if (!Kaleidoscope.has_leds)
return; return;
uint16_t map_base = theme_base + (theme * KeyboardHardware.led_count / 2); uint16_t map_base = theme_base + (theme * Kaleidoscope.device().led_count / 2);
uint8_t pos = KeyboardHardware.getLedIndex(key_addr); uint8_t pos = Kaleidoscope.device().getLedIndex(key_addr);
cRGB color = lookupColorAtPosition(map_base, pos); cRGB color = lookupColorAtPosition(map_base, pos);
::LEDControl.setCrgbAt(key_addr, color); ::LEDControl.setCrgbAt(key_addr, color);
@ -58,7 +58,7 @@ void LEDPaletteTheme::refreshAt(uint16_t theme_base, uint8_t theme, KeyAddr key_
const uint8_t LEDPaletteTheme::lookupColorIndexAtPosition(uint16_t map_base, uint16_t position) { const uint8_t LEDPaletteTheme::lookupColorIndexAtPosition(uint16_t map_base, uint16_t position) {
uint8_t color_index; uint8_t color_index;
color_index = KeyboardHardware.storage().read(map_base + position / 2); color_index = Kaleidoscope.storage().read(map_base + position / 2);
if (position % 2) if (position % 2)
color_index &= ~0xf0; color_index &= ~0xf0;
else else
@ -76,7 +76,7 @@ const cRGB LEDPaletteTheme::lookupColorAtPosition(uint16_t map_base, uint16_t po
const cRGB LEDPaletteTheme::lookupPaletteColor(uint8_t color_index) { const cRGB LEDPaletteTheme::lookupPaletteColor(uint8_t color_index) {
cRGB color; cRGB color;
KeyboardHardware.storage().get(palette_base_ + color_index * sizeof(cRGB), color); Kaleidoscope.storage().get(palette_base_ + color_index * sizeof(cRGB), color);
color.r ^= 0xff; color.r ^= 0xff;
color.g ^= 0xff; color.g ^= 0xff;
color.b ^= 0xff; color.b ^= 0xff;
@ -87,7 +87,7 @@ const cRGB LEDPaletteTheme::lookupPaletteColor(uint8_t color_index) {
void LEDPaletteTheme::updateColorIndexAtPosition(uint16_t map_base, uint16_t position, uint8_t color_index) { void LEDPaletteTheme::updateColorIndexAtPosition(uint16_t map_base, uint16_t position, uint8_t color_index) {
uint8_t indexes; uint8_t indexes;
indexes = KeyboardHardware.storage().read(map_base + position / 2); indexes = Kaleidoscope.storage().read(map_base + position / 2);
if (position % 2) { if (position % 2) {
uint8_t other = indexes >> 4; uint8_t other = indexes >> 4;
indexes = (other << 4) + color_index; indexes = (other << 4) + color_index;
@ -95,7 +95,7 @@ void LEDPaletteTheme::updateColorIndexAtPosition(uint16_t map_base, uint16_t pos
uint8_t other = indexes & ~0xf0; uint8_t other = indexes & ~0xf0;
indexes = (color_index << 4) + other; indexes = (color_index << 4) + other;
} }
KeyboardHardware.storage().update(map_base + position / 2, indexes); Kaleidoscope.storage().update(map_base + position / 2, indexes);
} }
EventHandlerResult LEDPaletteTheme::onFocusEvent(const char *command) { EventHandlerResult LEDPaletteTheme::onFocusEvent(const char *command) {
@ -129,7 +129,7 @@ EventHandlerResult LEDPaletteTheme::onFocusEvent(const char *command) {
color.g ^= 0xff; color.g ^= 0xff;
color.b ^= 0xff; color.b ^= 0xff;
KeyboardHardware.storage().put(palette_base_ + i * sizeof(color), color); Kaleidoscope.storage().put(palette_base_ + i * sizeof(color), color);
i++; i++;
} }
@ -151,11 +151,11 @@ EventHandlerResult LEDPaletteTheme::themeFocusEvent(const char *command,
if (strcmp_P(command, expected_command) != 0) if (strcmp_P(command, expected_command) != 0)
return EventHandlerResult::OK; return EventHandlerResult::OK;
uint16_t max_index = (max_themes * KeyboardHardware.led_count) / 2; uint16_t max_index = (max_themes * Kaleidoscope.device().led_count) / 2;
if (::Focus.isEOL()) { if (::Focus.isEOL()) {
for (uint16_t pos = 0; pos < max_index; pos++) { for (uint16_t pos = 0; pos < max_index; pos++) {
uint8_t indexes = KeyboardHardware.storage().read(theme_base + pos); uint8_t indexes = Kaleidoscope.storage().read(theme_base + pos);
::Focus.send((uint8_t)(indexes >> 4), indexes & ~0xf0); ::Focus.send((uint8_t)(indexes >> 4), indexes & ~0xf0);
} }
@ -171,7 +171,7 @@ EventHandlerResult LEDPaletteTheme::themeFocusEvent(const char *command,
uint8_t indexes = (idx1 << 4) + idx2; uint8_t indexes = (idx1 << 4) + idx2;
KeyboardHardware.storage().update(theme_base + pos, indexes); Kaleidoscope.storage().update(theme_base + pos, indexes);
pos++; pos++;
} }

@ -61,7 +61,7 @@ class StalkerEffect : public Plugin,
const StalkerEffect *parent_; const StalkerEffect *parent_;
uint16_t step_start_time_; uint16_t step_start_time_;
uint8_t map_[KeyboardHardware.numKeys()]; uint8_t map_[Kaleidoscope.device().numKeys()];
friend class StalkerEffect; friend class StalkerEffect;
}; };

@ -31,7 +31,7 @@ uint16_t WavepoolEffect::idle_timeout = 5000; // 5 seconds
int16_t WavepoolEffect::ripple_hue = WavepoolEffect::rainbow_hue; // automatic hue int16_t WavepoolEffect::ripple_hue = WavepoolEffect::rainbow_hue; // automatic hue
// map native keyboard coordinates (16x4) into geometric space (14x5) // map native keyboard coordinates (16x4) into geometric space (14x5)
PROGMEM const uint8_t WavepoolEffect::TransientLEDMode::rc2pos[KeyboardHardware.numKeys()] = { PROGMEM const uint8_t WavepoolEffect::TransientLEDMode::rc2pos[Kaleidoscope.device().numKeys()] = {
0, 1, 2, 3, 4, 5, 6, 59, 66, 7, 8, 9, 10, 11, 12, 13, 0, 1, 2, 3, 4, 5, 6, 59, 66, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 34, 60, 65, 35, 22, 23, 24, 25, 26, 27, 14, 15, 16, 17, 18, 19, 34, 60, 65, 35, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 33, 48, 61, 64, 49, 36, 37, 38, 39, 40, 41, 28, 29, 30, 31, 32, 33, 48, 61, 64, 49, 36, 37, 38, 39, 40, 41,

@ -66,7 +66,7 @@ class WavepoolEffect : public Plugin,
uint8_t frames_since_event_; uint8_t frames_since_event_;
int8_t surface_[2][WP_WID * WP_HGT]; int8_t surface_[2][WP_WID * WP_HGT];
uint8_t page_; uint8_t page_;
static PROGMEM const uint8_t rc2pos[KeyboardHardware.numKeys()]; static PROGMEM const uint8_t rc2pos[Kaleidoscope.device().numKeys()];
void raindrop(uint8_t x, uint8_t y, int8_t *page); void raindrop(uint8_t x, uint8_t y, int8_t *page);
uint8_t wp_rand(); uint8_t wp_rand();

@ -96,31 +96,31 @@ void LEDControl::set_all_leds_to(uint8_t r, uint8_t g, uint8_t b) {
} }
void LEDControl::set_all_leds_to(cRGB color) { void LEDControl::set_all_leds_to(cRGB color) {
for (int8_t i = 0; i < LED_COUNT; i++) { for (int8_t i = 0; i < Kaleidoscope.device().led_count; i++) {
setCrgbAt(i, color); setCrgbAt(i, color);
} }
} }
void LEDControl::setCrgbAt(int8_t led_index, cRGB crgb) { void LEDControl::setCrgbAt(int8_t led_index, cRGB crgb) {
KeyboardHardware.setCrgbAt(led_index, crgb); Kaleidoscope.device().setCrgbAt(led_index, crgb);
} }
void LEDControl::setCrgbAt(KeyAddr key_addr, cRGB color) { void LEDControl::setCrgbAt(KeyAddr key_addr, cRGB color) {
KeyboardHardware.setCrgbAt(key_addr, color); Kaleidoscope.device().setCrgbAt(key_addr, color);
} }
cRGB LEDControl::getCrgbAt(int8_t led_index) { cRGB LEDControl::getCrgbAt(int8_t led_index) {
return KeyboardHardware.getCrgbAt(led_index); return Kaleidoscope.device().getCrgbAt(led_index);
} }
cRGB LEDControl::getCrgbAt(KeyAddr key_addr) { cRGB LEDControl::getCrgbAt(KeyAddr key_addr) {
return KeyboardHardware.getCrgbAt(KeyboardHardware.getLedIndex(key_addr)); return Kaleidoscope.device().getCrgbAt(Kaleidoscope.device().getLedIndex(key_addr));
} }
void LEDControl::syncLeds(void) { void LEDControl::syncLeds(void) {
if (paused) if (paused)
return; return;
KeyboardHardware.syncLeds(); Kaleidoscope.device().syncLeds();
} }
kaleidoscope::EventHandlerResult LEDControl::onSetup() { kaleidoscope::EventHandlerResult LEDControl::onSetup() {

@ -33,12 +33,12 @@ void LEDChaseEffect::TransientLEDMode::update(void) {
int8_t pos2 = pos_ - (direction_ * parent_->distance_); int8_t pos2 = pos_ - (direction_ * parent_->distance_);
// First, we turn off the LEDs that were turned on in the previous update. // First, we turn off the LEDs that were turned on in the previous update.
// `pos_` is always in the valid range (0 <= pos_ < LED_COUNT), but after it // `pos_` is always in the valid range (0 <= pos_ < Kaleidoscope.device().led_count), but after it
// changes direction, for the first few updates, `pos2` will be out of bounds. // changes direction, for the first few updates, `pos2` will be out of bounds.
// Since it's an unsigned integer, even when it would have a value below zero, // Since it's an unsigned integer, even when it would have a value below zero,
// it underflows and so one test is good for both ends of the range. // it underflows and so one test is good for both ends of the range.
::LEDControl.setCrgbAt(pos_, CRGB(0, 0, 0)); ::LEDControl.setCrgbAt(pos_, CRGB(0, 0, 0));
if (pos2 < LED_COUNT) if (pos2 < Kaleidoscope.device().led_count)
::LEDControl.setCrgbAt(pos2, CRGB(0, 0, 0)); ::LEDControl.setCrgbAt(pos2, CRGB(0, 0, 0));
// Next, we adjust the red light's position. If the direction hasn't changed (the red // Next, we adjust the red light's position. If the direction hasn't changed (the red
@ -46,20 +46,20 @@ void LEDChaseEffect::TransientLEDMode::update(void) {
// one. If the new position puts it out of bounds, we reverse the direction, and bring // one. If the new position puts it out of bounds, we reverse the direction, and bring
// it back in bounds. When this happens, the blue light "jumps" behind the red one, and // it back in bounds. When this happens, the blue light "jumps" behind the red one, and
// will be out of bounds. The simplest way to do this is to assign it a value that is // will be out of bounds. The simplest way to do this is to assign it a value that is
// known to be invalid (LED_COUNT). // known to be invalid (Kaleidoscope.device().led_count).
pos_ += direction_; pos_ += direction_;
if (pos_ < LED_COUNT && pos_ > 0) { if (pos_ < Kaleidoscope.device().led_count && pos_ > 0) {
pos2 += direction_; pos2 += direction_;
} else { } else {
direction_ = -direction_; direction_ = -direction_;
pos_ += direction_; pos_ += direction_;
pos2 = LED_COUNT; pos2 = Kaleidoscope.device().led_count;
} }
// Last, we turn on the LEDs at their new positions. As before, the blue light (pos2) is // Last, we turn on the LEDs at their new positions. As before, the blue light (pos2) is
// only set if it's in the valid LED range. // only set if it's in the valid LED range.
::LEDControl.setCrgbAt(pos_, CRGB(255, 0, 0)); ::LEDControl.setCrgbAt(pos_, CRGB(255, 0, 0));
if (pos2 < LED_COUNT) if (pos2 < Kaleidoscope.device().led_count)
::LEDControl.setCrgbAt(pos2, CRGB(0, 0, 255)); ::LEDControl.setCrgbAt(pos2, CRGB(0, 0, 255));
} }

@ -34,12 +34,12 @@ EventHandlerResult MagicCombo::beforeReportingState() {
if (comboKey == 0) if (comboKey == 0)
break; break;
match &= KeyboardHardware.isKeyswitchPressed(comboKey); match &= Kaleidoscope.device().isKeyswitchPressed(comboKey);
if (!match) if (!match)
break; break;
} }
if (j != KeyboardHardware.pressedKeyswitchCount()) if (j != Kaleidoscope.device().pressedKeyswitchCount())
match = false; match = false;
if (match && Kaleidoscope.hasTimeExpired(start_time_, min_interval)) { if (match && Kaleidoscope.hasTimeExpired(start_time_, min_interval)) {

@ -33,10 +33,10 @@ constexpr uint8_t HELD = 3;
constexpr uint8_t RELEASED = 0; constexpr uint8_t RELEASED = 0;
EventHandlerResult TestMode::beforeReportingState() { EventHandlerResult TestMode::beforeReportingState() {
if (KeyboardHardware.isKeyswitchPressed(R0C0) && if (Kaleidoscope.device().isKeyswitchPressed(R0C0) &&
KeyboardHardware.isKeyswitchPressed(R0C6) && Kaleidoscope.device().isKeyswitchPressed(R0C6) &&
KeyboardHardware.isKeyswitchPressed(R3C6) && Kaleidoscope.device().isKeyswitchPressed(R3C6) &&
KeyboardHardware.pressedKeyswitchCount() == 3) { Kaleidoscope.device().pressedKeyswitchCount() == 3) {
run_tests(); run_tests();
} }
return EventHandlerResult::OK; return EventHandlerResult::OK;
@ -44,13 +44,13 @@ EventHandlerResult TestMode::beforeReportingState() {
void TestMode::waitForKeypress() { void TestMode::waitForKeypress() {
for (uint8_t temp = 0; temp < 8; temp++) { for (uint8_t temp = 0; temp < 8; temp++) {
KeyboardHardware.readMatrix(); Kaleidoscope.device().readMatrix();
} }
while (1) { while (1) {
KeyboardHardware.readMatrix(); Kaleidoscope.device().readMatrix();
if (KeyboardHardware.isKeyswitchPressed(R3C6) if (Kaleidoscope.device().isKeyswitchPressed(R3C6)
&& KeyboardHardware.pressedKeyswitchCount() == 1 && Kaleidoscope.device().pressedKeyswitchCount() == 1
&& KeyboardHardware.previousLeftHandState.all == 0) { && Kaleidoscope.device().previousLeftHandState.all == 0) {
break; break;
} }
} }
@ -117,13 +117,13 @@ void TestMode::handleKeyEvent(side_data_t *side, keydata_t *oldState, keydata_t
// If the key is held down // If the key is held down
if (keyState == HELD) { if (keyState == HELD) {
KeyboardHardware.setCrgbAt(key_addr_col_shifted, green); Kaleidoscope.device().setCrgbAt(key_addr_col_shifted, green);
} else if (bitRead(side->badKeys, key_addr_col_shifted.toInt()) == 1) { } else if (bitRead(side->badKeys, key_addr_col_shifted.toInt()) == 1) {
// If we triggered chatter detection ever on this key // If we triggered chatter detection ever on this key
KeyboardHardware.setCrgbAt(key_addr_col_shifted, red); Kaleidoscope.device().setCrgbAt(key_addr_col_shifted, red);
} else if (keyState == TOGGLED_OFF) { } else if (keyState == TOGGLED_OFF) {
// If the key was just released // If the key was just released
KeyboardHardware.setCrgbAt(key_addr_col_shifted, blue); Kaleidoscope.device().setCrgbAt(key_addr_col_shifted, blue);
} }
} }
@ -138,16 +138,16 @@ void TestMode::testMatrix() {
// Clear out the key event buffer so we don't get messed up information from // Clear out the key event buffer so we don't get messed up information from
// taps during LED test mode. // taps during LED test mode.
while (1) { while (1) {
KeyboardHardware.readMatrix(); Kaleidoscope.device().readMatrix();
if (KeyboardHardware.isKeyswitchPressed(R0C0) && if (Kaleidoscope.device().isKeyswitchPressed(R0C0) &&
KeyboardHardware.isKeyswitchPressed(R0C6) && Kaleidoscope.device().isKeyswitchPressed(R0C6) &&
KeyboardHardware.isKeyswitchPressed(R3C6) && Kaleidoscope.device().isKeyswitchPressed(R3C6) &&
KeyboardHardware.pressedKeyswitchCount() == 3) { Kaleidoscope.device().pressedKeyswitchCount() == 3) {
break; break;
} }
for (auto key_addr : KeyAddr::all()) { for (auto key_addr : KeyAddr::all()) {
handleKeyEvent(&left, &(KeyboardHardware.previousLeftHandState), &(KeyboardHardware.leftHandState), key_addr, 7); handleKeyEvent(&left, &(Kaleidoscope.device().previousLeftHandState), &(Kaleidoscope.device().leftHandState), key_addr, 7);
handleKeyEvent(&right, &(KeyboardHardware.previousRightHandState), &(KeyboardHardware.rightHandState), key_addr, 15); handleKeyEvent(&right, &(Kaleidoscope.device().previousRightHandState), &(Kaleidoscope.device().rightHandState), key_addr, 15);
} }
::LEDControl.syncLeds(); ::LEDControl.syncLeds();
} }
@ -159,13 +159,13 @@ void TestMode::toggle_programming_leds_on() {
} }
void TestMode::run_tests() { void TestMode::run_tests() {
// KeyboardHardware.serialPort().println("Running tests"); // Kaleidoscope.device().serialPort().println("Running tests");
toggle_programming_leds_on(); toggle_programming_leds_on();
// Disable debouncing // Disable debouncing
KeyboardHardware.setKeyscanInterval(2); Kaleidoscope.device().setKeyscanInterval(2);
test_leds(); test_leds();
testMatrix(); testMatrix();
// KeyboardHardware.serialPort().println("Done running tests"); // Kaleidoscope.device().serialPort().println("Done running tests");
} }
} }

@ -38,7 +38,7 @@ void TapDance::interrupt(KeyAddr key_addr) {
last_tap_dance_key_ = Key_NoKey; last_tap_dance_key_ = Key_NoKey;
KeyboardHardware.maskKey(key_addr); Kaleidoscope.device().maskKey(key_addr);
kaleidoscope::hid::sendKeyboardReport(); kaleidoscope::hid::sendKeyboardReport();
kaleidoscope::hid::releaseAllKeys(); kaleidoscope::hid::releaseAllKeys();
@ -118,8 +118,8 @@ EventHandlerResult TapDance::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr,
if (keyToggledOn(keyState)) if (keyToggledOn(keyState))
interrupt(key_addr); interrupt(key_addr);
if (KeyboardHardware.isKeyMasked(key_addr)) { if (Kaleidoscope.device().isKeyMasked(key_addr)) {
KeyboardHardware.unMaskKey(key_addr); Kaleidoscope.device().unMaskKey(key_addr);
return EventHandlerResult::EVENT_CONSUMED; return EventHandlerResult::EVENT_CONSUMED;
} }
return EventHandlerResult::OK; return EventHandlerResult::OK;

@ -91,7 +91,7 @@ EventHandlerResult TypingBreaks::onKeyswitchEvent(Key &mapped_key, KeyAddr key_a
// counters if need be. // counters if need be.
if (keyToggledOn(key_state)) { if (keyToggledOn(key_state)) {
if (key_addr.col() <= COLS / 2) if (key_addr.col() <= Kaleidoscope.device().matrix_columns / 2)
left_hand_keys_++; left_hand_keys_++;
else else
right_hand_keys_++; right_hand_keys_++;
@ -107,12 +107,12 @@ EventHandlerResult TypingBreaks::onSetup() {
// If idleTime is max, assume that EEPROM is uninitialized, and store the // If idleTime is max, assume that EEPROM is uninitialized, and store the
// defaults. // defaults.
uint32_t idle_time; uint32_t idle_time;
KeyboardHardware.storage().get(settings_base_, idle_time); Kaleidoscope.storage().get(settings_base_, idle_time);
if (idle_time == 0xffffffff) { if (idle_time == 0xffffffff) {
KeyboardHardware.storage().put(settings_base_, settings); Kaleidoscope.storage().put(settings_base_, settings);
} }
KeyboardHardware.storage().get(settings_base_, settings); Kaleidoscope.storage().get(settings_base_, settings);
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
@ -192,7 +192,7 @@ EventHandlerResult TypingBreaks::onFocusEvent(const char *command) {
break; break;
} }
KeyboardHardware.storage().put(settings_base_, settings); Kaleidoscope.storage().put(settings_base_, settings);
return EventHandlerResult::EVENT_CONSUMED; return EventHandlerResult::EVENT_CONSUMED;
} }

@ -0,0 +1,21 @@
/* kaleidoscope_internal::device - Global device object for internal use
* Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
*/
#include <Kaleidoscope.h>
namespace kaleidoscope_internal {
kaleidoscope::Device device;
}

@ -0,0 +1,21 @@
/* kaleidoscope_internal::device - Global device object for internal use
* Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
namespace kaleidoscope_internal {
extern kaleidoscope::Device device;
}
Loading…
Cancel
Save