Update example sketches' `macroAction()` functions to KeyEvent

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/1024/head
Michael Richters 3 years ago
parent c81fd4a584
commit 0a5fff5005
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -75,10 +75,11 @@ KEYMAPS(
KALEIDOSCOPE_INIT_PLUGINS(Macros); KALEIDOSCOPE_INIT_PLUGINS(Macros);
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
switch (macroIndex) { switch (macro_id) {
case RESET: case RESET:
Kaleidoscope.rebootBootloader(); if (keyToggledOn(event.state))
Kaleidoscope.rebootBootloader();
break; break;
default: default:
break; break;

@ -113,25 +113,24 @@ KALEIDOSCOPE_INIT_PLUGINS(
MouseKeys MouseKeys
); );
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
switch (macroIndex) { if (keyToggledOn(event.state)) {
case MACRO_QWERTY: switch (macro_id) {
// This macro is currently unused, but is kept around for compatibility case MACRO_QWERTY:
// reasons. We used to use it in place of `MoveToLayer(QWERTY)`, but no // This macro is currently unused, but is kept around for compatibility
// longer do. We keep it so that if someone still has the old layout with // reasons. We used to use it in place of `MoveToLayer(QWERTY)`, but no
// the macro in EEPROM, it will keep working after a firmware update. // longer do. We keep it so that if someone still has the old layout with
Layer.move(QWERTY); // the macro in EEPROM, it will keep working after a firmware update.
break; Layer.move(QWERTY);
case MACRO_VERSION_INFO: break;
if (keyToggledOn(keyState)) { case MACRO_VERSION_INFO:
Macros.type(PSTR("Keyboardio Atreus - Kaleidoscope ")); Macros.type(PSTR("Keyboardio Atreus - Kaleidoscope "));
Macros.type(PSTR(BUILD_INFORMATION)); Macros.type(PSTR(BUILD_INFORMATION));
break;
default:
break;
} }
break;
default:
break;
} }
return MACRO_NONE; return MACRO_NONE;
} }

@ -85,8 +85,8 @@ static kaleidoscope::plugin::LEDSolidColor solidBlue(0, 15, 100);
static kaleidoscope::plugin::LEDSolidColor solidIndigo(0, 0, 100); static kaleidoscope::plugin::LEDSolidColor solidIndigo(0, 0, 100);
static kaleidoscope::plugin::LEDSolidColor solidViolet(70, 0, 60); static kaleidoscope::plugin::LEDSolidColor solidViolet(70, 0, 60);
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
if (macroIndex == 1 && keyToggledOn(keyState)) { if (macro_id == 1 && keyToggledOn(event.state)) {
Kaleidoscope.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),

@ -82,10 +82,11 @@ KEYMAPS(
KALEIDOSCOPE_INIT_PLUGINS(Macros); KALEIDOSCOPE_INIT_PLUGINS(Macros);
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
switch (macroIndex) { switch (macro_id) {
case QWERTY: case QWERTY:
Layer.move(QWERTY); if (keyToggledOn(event.state))
Layer.move(QWERTY);
break; break;
default: default:
break; break;

@ -42,8 +42,8 @@ KEYMAPS(
) )
// *INDENT-ON* // *INDENT-ON*
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
if (macroIndex == 0 && keyToggledOff(keyState)) { if (macro_id == 0 && keyToggledOff(event.state)) {
EEPROMKeymapProgrammer.activate(); EEPROMKeymapProgrammer.activate();
} }

@ -68,8 +68,8 @@ void macroToggleOneShot() {
OneShot.toggleAutoOneShot(); OneShot.toggleAutoOneShot();
} }
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
if (macroIndex == TOGGLE_ONESHOT) { if (macro_id == TOGGLE_ONESHOT) {
macroToggleOneShot(); macroToggleOneShot();
} }

@ -49,10 +49,10 @@ KEYMAPS(
// *INDENT-ON* // *INDENT-ON*
// Defining a macro (on the "any" key: see above) to toggle Qukeys on and off // Defining a macro (on the "any" key: see above) to toggle Qukeys on and off
const macro_t *macroAction(uint8_t macro_index, uint8_t key_state) { const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
switch (macro_index) { switch (macro_id) {
case MACRO_TOGGLE_QUKEYS: case MACRO_TOGGLE_QUKEYS:
if (keyToggledOn(key_state)) if (keyToggledOn(event.state))
Qukeys.toggle(); Qukeys.toggle();
break; break;
} }

@ -52,10 +52,10 @@ static void unicode(uint32_t character, uint8_t keyState) {
} }
} }
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
switch (macroIndex) { switch (macro_id) {
case MACRO_KEYBOARD_EMOJI: case MACRO_KEYBOARD_EMOJI:
unicode(0x2328, keyState); unicode(0x2328, event.state);
break; break;
} }
return MACRO_NONE; return MACRO_NONE;

@ -42,11 +42,11 @@ KEYMAPS(
) )
// *INDENT-ON* // *INDENT-ON*
const macro_t *macroAction(uint8_t macro_index, uint8_t key_state) { const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
if (!keyToggledOn(key_state)) if (!keyToggledOn(event.state))
return MACRO_NONE; return MACRO_NONE;
if (macro_index == 0) { if (macro_id == 0) {
for (uint8_t i = Key_A.getKeyCode(); i <= Key_0.getKeyCode(); i++) { for (uint8_t i = Key_A.getKeyCode(); i <= Key_0.getKeyCode(); i++) {
LEDControl.set_all_leds_to(0, 0, 0); LEDControl.set_all_leds_to(0, 0, 0);
LEDControl.syncLeds(); LEDControl.syncLeds();

@ -45,16 +45,16 @@ KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
Macros, Macros,
LEDRainbowWaveEffect); LEDRainbowWaveEffect);
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
if (keyToggledOn(keyState)) { if (keyToggledOn(event.state)) {
uint8_t brightness = LEDControl.getBrightness(); uint8_t brightness = LEDControl.getBrightness();
if (macroIndex == 0) { if (macro_id == 0) {
if (brightness > 10) if (brightness > 10)
brightness -= 10; brightness -= 10;
else else
brightness = 0; brightness = 0;
} else if (macroIndex == 1) { } else if (macro_id == 1) {
if (brightness < 245) if (brightness < 245)
brightness += 10; brightness += 10;
else else

Loading…
Cancel
Save