|
|
@ -123,22 +123,17 @@ void Heatmap::resetMap(void) {
|
|
|
|
highest_ = 1;
|
|
|
|
highest_ = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Heatmap::setup(void) {
|
|
|
|
EventHandlerResult Heatmap::onKeyswitchEvent(Key &mapped_key, byte row, byte col, uint8_t key_state) {
|
|
|
|
Kaleidoscope.useEventHandlerHook(eventHook);
|
|
|
|
|
|
|
|
Kaleidoscope.useLoopHook(loopHook);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Key Heatmap::eventHook(Key mapped_key, byte row, byte col, uint8_t key_state) {
|
|
|
|
|
|
|
|
// this methode is called frequently by Kaleidoscope
|
|
|
|
// this methode is called frequently by Kaleidoscope
|
|
|
|
// even if the module isn't activated
|
|
|
|
// even if the module isn't activated
|
|
|
|
|
|
|
|
|
|
|
|
// if it is a synthetic key, skip it
|
|
|
|
// if it is a synthetic key, skip it
|
|
|
|
if (key_state & INJECTED)
|
|
|
|
if (key_state & INJECTED)
|
|
|
|
return mapped_key;
|
|
|
|
return EventHandlerResult::OK;
|
|
|
|
|
|
|
|
|
|
|
|
// if the key is not toggled on, skip it
|
|
|
|
// if the key is not toggled on, skip it
|
|
|
|
if (!keyToggledOn(key_state))
|
|
|
|
if (!keyToggledOn(key_state))
|
|
|
|
return mapped_key;
|
|
|
|
return EventHandlerResult::OK;
|
|
|
|
|
|
|
|
|
|
|
|
// increment the heatmap_ value related to the key
|
|
|
|
// increment the heatmap_ value related to the key
|
|
|
|
heatmap_[row][col]++;
|
|
|
|
heatmap_[row][col]++;
|
|
|
@ -155,10 +150,10 @@ Key Heatmap::eventHook(Key mapped_key, byte row, byte col, uint8_t key_state) {
|
|
|
|
shiftStats();
|
|
|
|
shiftStats();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return mapped_key;
|
|
|
|
return EventHandlerResult::OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Heatmap::loopHook(bool is_post_clear) {
|
|
|
|
EventHandlerResult Heatmap::beforeEachCycle() {
|
|
|
|
// this methode is called frequently by Kaleidoscope
|
|
|
|
// this methode is called frequently by Kaleidoscope
|
|
|
|
// even if the module isn't activated
|
|
|
|
// even if the module isn't activated
|
|
|
|
|
|
|
|
|
|
|
@ -170,6 +165,8 @@ void Heatmap::loopHook(bool is_post_clear) {
|
|
|
|
// between heat_colors[x] and heat_colors[x+1].
|
|
|
|
// between heat_colors[x] and heat_colors[x+1].
|
|
|
|
if (highest_ > (static_cast<uint16_t>(heat_colors_length) << 9))
|
|
|
|
if (highest_ > (static_cast<uint16_t>(heat_colors_length) << 9))
|
|
|
|
shiftStats();
|
|
|
|
shiftStats();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EventHandlerResult::OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Heatmap::update(void) {
|
|
|
|
void Heatmap::update(void) {
|
|
|
@ -201,8 +198,27 @@ void Heatmap::update(void) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Heatmap::Heatmap(void) {
|
|
|
|
// Legacy V1 API
|
|
|
|
|
|
|
|
#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API
|
|
|
|
|
|
|
|
void Heatmap::begin() {
|
|
|
|
|
|
|
|
Kaleidoscope.useEventHandlerHook(legacyEventHandler);
|
|
|
|
|
|
|
|
Kaleidoscope.useLoopHook(legacyLoopHook);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Key Heatmap::legacyEventHandler(Key mapped_key, byte row, byte col, uint8_t key_state) {
|
|
|
|
|
|
|
|
EventHandlerResult r = ::HeatmapEffect.onKeyswitchEvent(mapped_key, row, col, key_state);
|
|
|
|
|
|
|
|
if (r == EventHandlerResult::OK)
|
|
|
|
|
|
|
|
return mapped_key;
|
|
|
|
|
|
|
|
return Key_NoKey;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Heatmap::legacyLoopHook(bool is_post_clear) {
|
|
|
|
|
|
|
|
if (is_post_clear)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
::HeatmapEffect.beforeEachCycle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|