Updated to use the new plugin APIs

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/365/head
Gergely Nagy 6 years ago
parent ac4aab534f
commit 0f32840a3a

@ -41,11 +41,10 @@ void magicComboActions(uint8_t combo_index, uint32_t left_hand, uint32_t right_h
}
}
KALEIDOSCOPE_INIT_PLUGINS(MagicCombo);
void setup() {
Serial.begin(9600);
Kaleidoscope.use(&MagicCombo);
Kaleidoscope.setup();
MagicCombo.magic_combos = magic_combos;

@ -1,6 +1,6 @@
/* -*- mode: c++ -*-
* Kaleidoscope-MagicCombo -- Magic combo framework
* Copyright (C) 2016, 2017 Gergely Nagy
* Copyright (C) 2016, 2017, 2018 Gergely Nagy
*
* 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
@ -35,7 +35,7 @@ static const kaleidoscope::MagicCombo::combo_t magic_combos[] PROGMEM = {
{0, 0}
};
// *INDENT-OFF*
const Key keymaps[][ROWS][COLS] PROGMEM = {
[0] = KEYMAP_STACKED
(
@ -49,18 +49,18 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip,
Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals,
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
Key_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_NoKey),
};
// *INDENT-ON*
KALEIDOSCOPE_INIT_PLUGINS(MagicCombo);
void setup() {
Serial.begin(9600);
Kaleidoscope.use(&MagicCombo);
Kaleidoscope.setup();
MagicCombo.magic_combos = magic_combos;

@ -1,6 +1,6 @@
/* -*- mode: c++ -*-
* Kaleidoscope-MagicCombo -- Magic combo framework
* Copyright (C) 2016, 2017 Gergely Nagy
* Copyright (C) 2016, 2017, 2018 Gergely Nagy
*
* 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
@ -34,16 +34,9 @@ const MagicCombo::combo_t *MagicCombo::magic_combos;
uint16_t MagicCombo::min_interval = 500;
uint32_t MagicCombo::end_time_;
MagicCombo::MagicCombo(void) {
}
void MagicCombo::begin(void) {
Kaleidoscope.useLoopHook(loopHook);
}
void MagicCombo::loopHook(bool is_post_clear) {
if (!magic_combos || is_post_clear)
return;
EventHandlerResult MagicCombo::beforeReportingState() {
if (!magic_combos)
return EventHandlerResult::OK;
for (byte i = 0;; i++) {
combo_t combo;
@ -63,8 +56,23 @@ void MagicCombo::loopHook(bool is_post_clear) {
break;
}
}
return EventHandlerResult::OK;
}
// Legacy V1 API
#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API
void MagicCombo::begin() {
Kaleidoscope.useLoopHook(legacyLoopHook);
}
void MagicCombo::legacyLoopHook(bool is_post_clear) {
if (is_post_clear)
return;
::MagicCombo.beforeReportingState();
}
#endif
};
__attribute__((weak)) void magicComboActions(uint8_t comboIndex, uint32_t left_hand, uint32_t right_hand) {

@ -1,6 +1,6 @@
/* -*- mode: c++ -*-
* Kaleidoscope-MagicCombo -- Magic combo framework
* Copyright (C) 2016, 2017 Gergely Nagy
* Copyright (C) 2016, 2017, 2018 Gergely Nagy
*
* 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
@ -22,23 +22,27 @@
namespace kaleidoscope {
class MagicCombo : public KaleidoscopePlugin {
class MagicCombo : public kaleidoscope::Plugin {
public:
typedef struct {
uint32_t left_hand, right_hand;
} combo_t;
MagicCombo(void);
void begin(void) final;
MagicCombo(void) {}
static const combo_t *magic_combos;
static uint16_t min_interval;
EventHandlerResult beforeReportingState();
#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API
protected:
void begin();
static void legacyLoopHook(bool is_post_clear);
#endif
private:
static uint32_t end_time_;
static void loopHook(bool is_post_clear);
};
}

Loading…
Cancel
Save