Skip to content

Instantly share code, notes, and snippets.

@algernon algernon/Sketch.ino
Created Feb 24, 2019

Embed
What would you like to do?
Kaleidoscope Sticky key plugin
#include "StickyKey.h"
kaleidoscope::plugin::StickyKey StickyW(Key_W), StickyX(Key_X);
KALEIDOSCOPE_INIT_PLUGINS(StickyW, StickyX);
#include "StickyKey.h"
namespace kaleidoscope {
namespace plugin {
EventHandlerResult beforeReportingState() {
if (tap_count_ >= 2) {
handleKeyswitchEvent(key_, UNKNOWN_KEYSWITCH_POSITION, IS_PRESSED);
}
return EventHandlerResult::OK;
}
EventHandlerResult onKeyswitchEvent(Key &mapped_key, byte row, byte col, uint8_t keyState) {
if (tap_count_ > 0 && mapped_key != key_) {
tap_count_ = 0;
return EventHandlerResult::OK;
}
if (mapped_key == key_) {
if (tap_count_ < 2)
tap_count_++;
}
return EventHandlerResult::OK;
}
}
}
#include <Kaleidoscope.h>
namespace kaleidoscope {
namespace plugin {
class StickyKey : public kaleidoscope::Plugin {
public:
StickyKey(const Key k) : key_(k) {}
EventHandlerResult beforeReportingState();
EventHandlerResult onKeyswitchEvent(Key &mapped_key, byte row, byte col, uint8_t keyState);
private:
Key key_;
uint8_t tap_count_ = 0;
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.