summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGergely Nagy <algernon@keyboard.io>2018-06-09 13:13:46 +0200
committerGergely Nagy <algernon@keyboard.io>2018-06-09 13:13:46 +0200
commit583d5429cd1ed65956a96af8630d733bfd88b072 (patch)
treeaafd6d0e09947ad359c497887298c14d736ce19f
parent33bcc999b9b1beeb9418a9ff3907dc15b44ea47f (diff)
downloadmodel01-firmware-583d5429cd1ed65956a96af8630d733bfd88b072.tar.gz
model01-firmware-583d5429cd1ed65956a96af8630d733bfd88b072.tar.bz2
model01-firmware-583d5429cd1ed65956a96af8630d733bfd88b072.zip
Updated to use the new MagicCombo APIs
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
-rw-r--r--Model01-Firmware.ino50
1 files changed, 12 insertions, 38 deletions
diff --git a/Model01-Firmware.ino b/Model01-Firmware.ino
index 12c3b0a..f04ade8 100644
--- a/Model01-Firmware.ino
+++ b/Model01-Firmware.ino
@@ -288,45 +288,23 @@ void hostPowerManagementEventHandler(kaleidoscope::HostPowerManagement::Event ev
* firmware The names aren't particularly important. What is important is that
* each is unique.
*
- * These are the names of your magic combos. They'll be used in two places.
- *
- * The first is in the magic combo list, that pairs a name (or index, really)
- * with keys.
- *
- * The second is in the 'switch' statement in the 'magicComboActions' function.
- * That switch statement actually runs the code associated with the combo, when
- * the combo is recognised.
+ * These are the names of your magic combos. They will be used by the
+ * `USE_MAGIC_COMBOS` call below.
*/
enum { COMBO_PROTOCOL_TOGGLE };
-// Key combinations we want special actions for, to be used with the MagicCombo
-// plugin.
-static const kaleidoscope::MagicCombo::combo_t magic_combos[] PROGMEM = {
- [COMBO_PROTOCOL_TOGGLE] = {
- R3C6 | R2C6 | R3C7, // Left Fn + Esc + Shift
- 0
- },
- {0, 0} // End-of-list marker.
-};
-
-/** magicComboActions dispatches combo events the MagicCombo plugin recognises.
-
- The first argument is the index of the combination, the next two are the
- left- and right-hand states, as bit maps. For most cases, the index is
- enough to decide how to handle the combination.
-
- The 'switch' statement should have a 'case' for each entry of the combo
- enum. Each 'case' statement should call out to a function to handle the
- combination in question.
-*/
-void magicComboActions(uint8_t combo_index, uint32_t left_hand, uint32_t right_hand) {
- switch (combo_index) {
- case COMBO_PROTOCOL_TOGGLE:
- USBQuirks.toggleKeyboardProtocol();
- break;
- }
+static void toggleKeyboardProtocol(uint8_t combo_index) {
+ USBQuirks.toggleKeyboardProtocol();
}
+/** Magic combo list, a list of key combo and action pairs the firmware should
+ * recognise.
+ */
+USE_MAGIC_COMBOS([COMBO_PROTOCOL_TOGGLE] = {.action = toggleKeyboardProtocol,
+ // Left Fn + Esc + Shift
+ .keys = { R3C6, R2C6, R3C7 }
+ });
+
// First, tell Kaleidoscope which plugins you want to use.
// The order can be important. For example, LED effects are
// added in the order they're listed here.
@@ -417,10 +395,6 @@ void setup() {
// see https://github.com/keyboardio/Kaleidoscope-LED-Stalker
StalkerEffect.variant = STALKER(BlazingTrail);
- // For the MagicCombo plugin to work, we need to tell it what combos we care
- // about.
- MagicCombo.magic_combos = magic_combos;
-
// We want to make sure that the firmware starts with LED effects off
// This avoids over-taxing devices that don't have a lot of power to share
// with USB devices