make astyle

pull/389/head
Jesse Vincent 8 years ago
parent 126b14d6c6
commit f148a4c7e7
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -50,8 +50,8 @@ static void leaderTestAA (uint8_t seqIndex) {
static const KaleidoscopePlugins::Leader::dictionary_t leaderDictionary[] PROGMEM = LEADER_DICT static const KaleidoscopePlugins::Leader::dictionary_t leaderDictionary[] PROGMEM = LEADER_DICT
( (
{LEADER_SEQ(LEAD(0), Key_A), leaderTestA}, {LEADER_SEQ(LEAD(0), Key_A), leaderTestA},
{LEADER_SEQ(LEAD(0), Key_A, Key_A), leaderTestAA} {LEADER_SEQ(LEAD(0), Key_A, Key_A), leaderTestAA}
); );
void setup () { void setup () {

@ -21,14 +21,14 @@
using namespace KaleidoscopePlugins::Ranges; using namespace KaleidoscopePlugins::Ranges;
namespace KaleidoscopePlugins { namespace KaleidoscopePlugins {
// --- state --- // --- state ---
Key Leader::sequence[LEADER_MAX_SEQUENCE_LENGTH + 1]; Key Leader::sequence[LEADER_MAX_SEQUENCE_LENGTH + 1];
uint8_t Leader::sequencePos; uint8_t Leader::sequencePos;
uint32_t Leader::endTime; uint32_t Leader::endTime;
uint16_t Leader::timeOut = 1000; uint16_t Leader::timeOut = 1000;
const Leader::dictionary_t *Leader::dictionary; const Leader::dictionary_t *Leader::dictionary;
// --- helpers --- // --- helpers ---
#define PARTIAL_MATCH -1 #define PARTIAL_MATCH -1
#define NO_MATCH -2 #define NO_MATCH -2
@ -36,9 +36,9 @@ namespace KaleidoscopePlugins {
#define isLeader(k) (k.raw >= LEAD_FIRST && k.raw <= LEAD_LAST) #define isLeader(k) (k.raw >= LEAD_FIRST && k.raw <= LEAD_LAST)
#define isActive() (sequence[0].raw != Key_NoKey.raw) #define isActive() (sequence[0].raw != Key_NoKey.raw)
// --- actions --- // --- actions ---
int8_t int8_t
Leader::lookup (void) { Leader::lookup (void) {
bool match; bool match;
for (uint8_t seqIndex = 0; ; seqIndex++) { for (uint8_t seqIndex = 0; ; seqIndex++) {
@ -69,38 +69,38 @@ namespace KaleidoscopePlugins {
} }
return NO_MATCH; return NO_MATCH;
} }
// --- api --- // --- api ---
Leader::Leader (void) { Leader::Leader (void) {
} }
void void
Leader::begin (void) { Leader::begin (void) {
event_handler_hook_use (this->eventHandlerHook); event_handler_hook_use (this->eventHandlerHook);
loop_hook_use (this->loopHook); loop_hook_use (this->loopHook);
} }
void void
Leader::configure (const Leader::dictionary_t dictionary_[]) { Leader::configure (const Leader::dictionary_t dictionary_[]) {
dictionary = dictionary_; dictionary = dictionary_;
} }
void void
Leader::reset (void) { Leader::reset (void) {
sequencePos = 0; sequencePos = 0;
sequence[0].raw = Key_NoKey.raw; sequence[0].raw = Key_NoKey.raw;
} }
void void
Leader::inject (Key key, uint8_t keyState) { Leader::inject (Key key, uint8_t keyState) {
eventHandlerHook (key, 255, 255, keyState); eventHandlerHook (key, 255, 255, keyState);
} }
// --- hooks --- // --- hooks ---
Key Key
Leader::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) { Leader::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
if (keyState & INJECTED) if (keyState & INJECTED)
return mappedKey; return mappedKey;
@ -159,10 +159,10 @@ namespace KaleidoscopePlugins {
action_t leaderAction = (action_t) pgm_read_ptr (&(dictionary[actionIndex].action)); action_t leaderAction = (action_t) pgm_read_ptr (&(dictionary[actionIndex].action));
(*leaderAction) (actionIndex); (*leaderAction) (actionIndex);
return Key_NoKey; return Key_NoKey;
} }
void void
Leader::loopHook (bool postClear) { Leader::loopHook (bool postClear) {
if (!postClear) if (!postClear)
return; return;
@ -171,7 +171,7 @@ namespace KaleidoscopePlugins {
if (millis () >= endTime) if (millis () >= endTime)
reset (); reset ();
} }
}; };
KaleidoscopePlugins::Leader Leader; KaleidoscopePlugins::Leader Leader;

@ -29,7 +29,7 @@
#define LEADER_DICT(...) { __VA_ARGS__, {{Key_NoKey}, NULL} } #define LEADER_DICT(...) { __VA_ARGS__, {{Key_NoKey}, NULL} }
namespace KaleidoscopePlugins { namespace KaleidoscopePlugins {
class Leader : public KaleidoscopePlugin { class Leader : public KaleidoscopePlugin {
public: public:
typedef void (*action_t) (uint8_t seqIndex); typedef void (*action_t) (uint8_t seqIndex);
typedef struct { typedef struct {
@ -56,7 +56,7 @@ namespace KaleidoscopePlugins {
static Key eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState); static Key eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState);
static void loopHook (bool postClear); static void loopHook (bool postClear);
static int8_t lookup (void); static int8_t lookup (void);
}; };
}; };
extern KaleidoscopePlugins::Leader Leader; extern KaleidoscopePlugins::Leader Leader;

Loading…
Cancel
Save