You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.1 KiB
68 lines
2.1 KiB
8 years ago
|
/* -*- mode: c++ -*-
|
||
8 years ago
|
* Kaleidoscope-LED-ActiveModColor -- Light up the LEDs under the active modifiers
|
||
6 years ago
|
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc
|
||
8 years ago
|
*
|
||
6 years ago
|
* 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 the Free Software
|
||
|
* Foundation, version 3.
|
||
8 years ago
|
*
|
||
6 years ago
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||
|
* details.
|
||
8 years ago
|
*
|
||
6 years ago
|
* You should have received a copy of the GNU General Public License along with
|
||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||
8 years ago
|
*/
|
||
|
|
||
8 years ago
|
#include <Kaleidoscope-LED-ActiveModColor.h>
|
||
7 years ago
|
#include <Kaleidoscope-OneShot.h>
|
||
8 years ago
|
#include <kaleidoscope/hid.h>
|
||
8 years ago
|
|
||
8 years ago
|
namespace kaleidoscope {
|
||
6 years ago
|
namespace plugin {
|
||
8 years ago
|
|
||
|
cRGB ActiveModColorEffect::highlight_color = (cRGB) {
|
||
8 years ago
|
0xff, 0xff, 0xff
|
||
8 years ago
|
};
|
||
8 years ago
|
|
||
7 years ago
|
cRGB ActiveModColorEffect::sticky_color = CRGB(0xff, 0x00, 0x00);
|
||
|
|
||
7 years ago
|
EventHandlerResult ActiveModColorEffect::beforeReportingState() {
|
||
8 years ago
|
for (byte r = 0; r < ROWS; r++) {
|
||
|
for (byte c = 0; c < COLS; c++) {
|
||
7 years ago
|
Key k = Layer.lookupOnActiveLayer(r, c);
|
||
8 years ago
|
|
||
7 years ago
|
if (::OneShot.isOneShotKey(k)) {
|
||
7 years ago
|
if (::OneShot.isSticky(k))
|
||
|
::LEDControl.setCrgbAt(r, c, sticky_color);
|
||
|
else if (::OneShot.isActive(k))
|
||
7 years ago
|
::LEDControl.setCrgbAt(r, c, highlight_color);
|
||
|
else
|
||
|
::LEDControl.refreshAt(r, c);
|
||
|
} else if (k.raw >= Key_LeftControl.raw && k.raw <= Key_RightGui.raw) {
|
||
|
if (hid::isModifierKeyActive(k))
|
||
|
::LEDControl.setCrgbAt(r, c, highlight_color);
|
||
|
else
|
||
|
::LEDControl.refreshAt(r, c);
|
||
|
} else if (k.flags == (SYNTHETIC | SWITCH_TO_KEYMAP)) {
|
||
|
uint8_t layer = k.keyCode;
|
||
7 years ago
|
if (layer >= LAYER_SHIFT_OFFSET)
|
||
|
layer -= LAYER_SHIFT_OFFSET;
|
||
7 years ago
|
|
||
|
if (Layer.isOn(layer))
|
||
|
::LEDControl.setCrgbAt(r, c, highlight_color);
|
||
|
else
|
||
|
::LEDControl.refreshAt(r, c);
|
||
|
}
|
||
8 years ago
|
}
|
||
8 years ago
|
}
|
||
7 years ago
|
|
||
|
return EventHandlerResult::OK;
|
||
|
}
|
||
|
|
||
6 years ago
|
}
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
6 years ago
|
kaleidoscope::plugin::ActiveModColorEffect ActiveModColorEffect;
|