diff options
author | dakkar <dakkar@thenautilus.net> | 2019-02-15 14:59:32 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2019-02-15 14:59:32 +0000 |
commit | 3cc3c8831326cc50619d6f4e99de11c54b7376c9 (patch) | |
tree | b02b51827c50a388b8abebb9d076774ee9da8ac2 | |
parent | some cleanup (diff) | |
download | keyboardio-model01-3cc3c8831326cc50619d6f4e99de11c54b7376c9.tar.gz keyboardio-model01-3cc3c8831326cc50619d6f4e99de11c54b7376c9.tar.bz2 keyboardio-model01-3cc3c8831326cc50619d6f4e99de11c54b7376c9.zip |
start of the "color picker" toy
-rw-r--r-- | Model01-Firmware.ino | 2 | ||||
-rw-r--r-- | color-picker.h | 26 | ||||
-rw-r--r-- | combos.h | 17 |
3 files changed, 43 insertions, 2 deletions
diff --git a/Model01-Firmware.ino b/Model01-Firmware.ino index a3d6d95..5cda263 100644 --- a/Model01-Firmware.ino +++ b/Model01-Firmware.ino @@ -10,6 +10,7 @@ #include "keymap-wrapper.h" #include "color-themes.h" +#include "color-picker.h" /* plugins */ #include "kaleidoscope/plugin/EEPROM-Settings.h" @@ -31,6 +32,7 @@ KALEIDOSCOPE_INIT_PLUGINS( LEDControl, DakkarColorDark, DakkarColorBright, + theColorPicker, Macros, MouseKeys, diff --git a/color-picker.h b/color-picker.h new file mode 100644 index 0000000..9782ef7 --- /dev/null +++ b/color-picker.h @@ -0,0 +1,26 @@ +// -*- mode: c++ -*- +#pragma once + +#include <Kaleidoscope.h> + +class ColorPicker : public kaleidoscope::Plugin { +public: + ColorPicker(void) : is_active(false), current_index(0), colors{}, map{} { } + + void toggle(void) { is_active = !is_active; } + + kaleidoscope::EventHandlerResult onKeyswitchEvent(Key &mapped_key, byte row, byte col, uint8_t key_state) { + 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]; +}; + +ColorPicker theColorPicker; @@ -3,18 +3,31 @@ #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_NKRO_MODE, + COMBO_TOGGLE_COLOR_PICKER }; static void toggleKeyboardProtocol(uint8_t combo_index) { USBQuirks.toggleKeyboardProtocol(); } -USE_MAGIC_COMBOS({.action = toggleKeyboardProtocol, +static void toggleColorPicker(uint8_t combo_index) { + theColorPicker.toggle(); +} + +USE_MAGIC_COMBOS( + { + .action = toggleKeyboardProtocol, // Left Fn + Esc + Shift .keys = { R3C6, R2C6, R3C7 } + }, + { + .action = toggleColorPicker, + // Left Fn + Right Fn + .keys = { R3C6, R3C9 } }); |