diff options
author | dakkar <dakkar@thenautilus.net> | 2019-02-15 15:13:07 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2019-02-15 15:13:07 +0000 |
commit | 332b5ceec3963a5ecbf123865698d824d1eedc43 (patch) | |
tree | c9bc6b31291079e1654ee78d70c9b4f4d9552317 | |
parent | start of the "color picker" toy (diff) | |
download | keyboardio-model01-332b5ceec3963a5ecbf123865698d824d1eedc43.tar.gz keyboardio-model01-332b5ceec3963a5ecbf123865698d824d1eedc43.tar.bz2 keyboardio-model01-332b5ceec3963a5ecbf123865698d824d1eedc43.zip |
probably simpler: use LEDMode
-rw-r--r-- | color-picker.h | 15 | ||||
-rw-r--r-- | 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 <Kaleidoscope.h> +#include <Kaleidoscope-LEDControl.h> -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; @@ -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 } }); |