From 332b5ceec3963a5ecbf123865698d824d1eedc43 Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 15 Feb 2019 15:13:07 +0000 Subject: probably simpler: use LEDMode --- color-picker.h | 15 ++++++++------- combos.h | 17 ++--------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/color-picker.h b/color-picker.h index 9782ef7..9aa9f1f 100644 --- a/color-picker.h +++ b/color-picker.h @@ -1,26 +1,27 @@ // -*- mode: c++ -*- #pragma once -#include +#include -class ColorPicker : public kaleidoscope::Plugin { +class ColorPicker : public kaleidoscope::plugin::LEDMode { public: - ColorPicker(void) : is_active(false), current_index(0), colors{}, map{} { } - - void toggle(void) { is_active = !is_active; } + ColorPicker(void) : current_index(0), colors{}, map{} { } kaleidoscope::EventHandlerResult onKeyswitchEvent(Key &mapped_key, byte row, byte col, uint8_t key_state) { - if (!Kaleidoscope.has_leds || !is_active) + if (!Kaleidoscope.has_leds || !is_active()) return kaleidoscope::EventHandlerResult::OK; return kaleidoscope::EventHandlerResult::EVENT_CONSUMED; } private: - bool is_active; uint8_t current_index; cRGB colors[16]; uint8_t map[ROWS][COLS]; + + bool is_active() { + return LEDControl.get_mode() == this; + } }; ColorPicker theColorPicker; diff --git a/combos.h b/combos.h index 242e274..38d455c 100644 --- a/combos.h +++ b/combos.h @@ -3,31 +3,18 @@ #include "kaleidoscope/plugin/MagicCombo.h" #include "kaleidoscope/plugin/USB-Quirks.h" -#include "color-picker.h" enum { // Toggle between Boot (6-key rollover; for BIOSes and early boot) and NKRO // mode. - COMBO_TOGGLE_NKRO_MODE, - COMBO_TOGGLE_COLOR_PICKER + COMBO_TOGGLE_NKRO_MODE }; static void toggleKeyboardProtocol(uint8_t combo_index) { USBQuirks.toggleKeyboardProtocol(); } -static void toggleColorPicker(uint8_t combo_index) { - theColorPicker.toggle(); -} - -USE_MAGIC_COMBOS( - { - .action = toggleKeyboardProtocol, +USE_MAGIC_COMBOS({.action = toggleKeyboardProtocol, // Left Fn + Esc + Shift .keys = { R3C6, R2C6, R3C7 } - }, - { - .action = toggleColorPicker, - // Left Fn + Right Fn - .keys = { R3C6, R3C9 } }); -- cgit v1.2.3