astyle with current project style guidelines

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

@ -40,24 +40,24 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
),
};
static void tapDanceEsc (uint8_t tapDanceIndex, uint8_t tapCount, KaleidoscopePlugins::TapDance::ActionType tapDanceAction) {
tapDanceActionKeys (tapCount, tapDanceAction, Key_Escape, Key_Tab);
static void tapDanceEsc(uint8_t tapDanceIndex, uint8_t tapCount, KaleidoscopePlugins::TapDance::ActionType tapDanceAction) {
tapDanceActionKeys(tapCount, tapDanceAction, Key_Escape, Key_Tab);
}
void tapDanceAction (uint8_t tapDanceIndex, byte row, byte col, uint8_t tapCount, KaleidoscopePlugins::TapDance::ActionType tapDanceAction) {
void tapDanceAction(uint8_t tapDanceIndex, byte row, byte col, uint8_t tapCount, KaleidoscopePlugins::TapDance::ActionType tapDanceAction) {
switch (tapDanceIndex) {
case 0:
return tapDanceActionKeys (tapCount, tapDanceAction, Key_Tab, Key_Escape);
return tapDanceActionKeys(tapCount, tapDanceAction, Key_Tab, Key_Escape);
case 1:
return tapDanceEsc (tapDanceIndex, tapCount, tapDanceAction);
return tapDanceEsc(tapDanceIndex, tapCount, tapDanceAction);
}
}
void setup () {
Kaleidoscope.setup (KEYMAP_SIZE);
Kaleidoscope.use (&TapDance, NULL);
void setup() {
Kaleidoscope.setup(KEYMAP_SIZE);
Kaleidoscope.use(&TapDance, NULL);
}
void loop () {
Kaleidoscope.loop ();
void loop() {
Kaleidoscope.loop();
}

@ -40,91 +40,91 @@ byte TapDance::lastTapDanceCol;
// --- actions ---
void
TapDance::interrupt (void) {
TapDance::interrupt(void) {
uint8_t idx = lastTapDanceKey.raw - Ranges::TD_FIRST;
tapDanceAction (idx, lastTapDanceRow, lastTapDanceCol, tapCount[idx], Interrupt);
bitWrite (triggeredState, idx, 1);
tapDanceAction(idx, lastTapDanceRow, lastTapDanceCol, tapCount[idx], Interrupt);
bitWrite(triggeredState, idx, 1);
endTime = 0;
if (bitRead (pressedState, idx))
if (bitRead(pressedState, idx))
return;
release (idx);
release(idx);
}
void
TapDance::timeout (void) {
TapDance::timeout(void) {
uint8_t idx = lastTapDanceKey.raw - Ranges::TD_FIRST;
tapDanceAction (idx, lastTapDanceRow, lastTapDanceCol, tapCount[idx], Timeout);
bitWrite (triggeredState, idx, 1);
tapDanceAction(idx, lastTapDanceRow, lastTapDanceCol, tapCount[idx], Timeout);
bitWrite(triggeredState, idx, 1);
if (bitRead (pressedState, idx))
if (bitRead(pressedState, idx))
return;
lastTapDanceKey.raw = Key_NoKey.raw;
release (idx);
release(idx);
}
Key
TapDance::release (uint8_t tapDanceIndex) {
TapDance::release(uint8_t tapDanceIndex) {
endTime = 0;
lastTapDanceKey.raw = Key_NoKey.raw;
bitClear (pressedState, tapDanceIndex);
bitClear (triggeredState, tapDanceIndex);
bitWrite (releaseNextState, tapDanceIndex, 1);
bitClear(pressedState, tapDanceIndex);
bitClear(triggeredState, tapDanceIndex);
bitWrite(releaseNextState, tapDanceIndex, 1);
return Key_NoKey;
}
Key
TapDance::tap (void) {
TapDance::tap(void) {
uint8_t idx = lastTapDanceKey.raw - Ranges::TD_FIRST;
tapCount[idx]++;
endTime = millis () + timeOut;
endTime = millis() + timeOut;
tapDanceAction (idx, lastTapDanceRow, lastTapDanceCol, tapCount[idx], Tap);
tapDanceAction(idx, lastTapDanceRow, lastTapDanceCol, tapCount[idx], Tap);
return Key_NoKey;
}
// --- api ---
TapDance::TapDance (void) {
TapDance::TapDance(void) {
lastTapDanceKey.raw = Key_NoKey.raw;
}
void
TapDance::begin (void) {
event_handler_hook_use (this->eventHandlerHook);
loop_hook_use (this->loopHook);
TapDance::begin(void) {
event_handler_hook_use(this->eventHandlerHook);
loop_hook_use(this->loopHook);
}
void
TapDance::actionKeys (uint8_t tapCount, ActionType tapDanceAction, uint8_t maxKeys, const Key tapKeys[]) {
TapDance::actionKeys(uint8_t tapCount, ActionType tapDanceAction, uint8_t maxKeys, const Key tapKeys[]) {
if (tapCount > maxKeys)
tapCount = maxKeys;
Key key;
key.raw = pgm_read_word (&(tapKeys[tapCount - 1].raw));
key.raw = pgm_read_word(&(tapKeys[tapCount - 1].raw));
switch (tapDanceAction) {
case Tap:
break;
case Interrupt:
case Timeout:
handle_keyswitch_event (key, lastTapDanceRow, lastTapDanceCol, IS_PRESSED | INJECTED);
handle_keyswitch_event(key, lastTapDanceRow, lastTapDanceCol, IS_PRESSED | INJECTED);
break;
case Hold:
handle_keyswitch_event (key, lastTapDanceRow, lastTapDanceCol, IS_PRESSED | WAS_PRESSED | INJECTED);
handle_keyswitch_event(key, lastTapDanceRow, lastTapDanceCol, IS_PRESSED | WAS_PRESSED | INJECTED);
break;
case Release:
Keyboard.sendReport ();
handle_keyswitch_event (key, lastTapDanceRow, lastTapDanceCol, WAS_PRESSED | INJECTED);
Keyboard.sendReport();
handle_keyswitch_event(key, lastTapDanceRow, lastTapDanceCol, WAS_PRESSED | INJECTED);
break;
}
}
@ -132,99 +132,99 @@ TapDance::actionKeys (uint8_t tapCount, ActionType tapDanceAction, uint8_t maxKe
// --- hooks ---
Key
TapDance::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
TapDance::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState) {
if (keyState & INJECTED)
return mappedKey;
if (!key_is_pressed (keyState) && !key_was_pressed (keyState)) {
if (isTapDance (mappedKey))
if (!key_is_pressed(keyState) && !key_was_pressed(keyState)) {
if (isTapDance(mappedKey))
return Key_NoKey;
return mappedKey;
}
if (!isTapDance (mappedKey)) {
if (!isActive ())
if (!isTapDance(mappedKey)) {
if (!isActive())
return mappedKey;
if (key_toggled_on (keyState))
interrupt ();
if (key_toggled_on(keyState))
interrupt();
return mappedKey;
}
uint8_t tapDanceIndex = mappedKey.raw - Ranges::TD_FIRST;
if (key_toggled_off (keyState))
bitClear (pressedState, tapDanceIndex);
if (key_toggled_off(keyState))
bitClear(pressedState, tapDanceIndex);
if (!isInSeq (mappedKey)) {
if (!isActive ()) {
if (bitRead (triggeredState, tapDanceIndex)) {
if (key_toggled_off (keyState))
return release (tapDanceIndex);
if (!isInSeq(mappedKey)) {
if (!isActive()) {
if (bitRead(triggeredState, tapDanceIndex)) {
if (key_toggled_off(keyState))
return release(tapDanceIndex);
return Key_NoKey;
}
lastTapDanceKey.raw = mappedKey.raw;
lastTapDanceRow = row;
lastTapDanceCol = col;
return tap ();
return tap();
} else {
if (key_toggled_off (keyState) && stillHeld (tapDanceIndex)) {
return release (tapDanceIndex);
if (key_toggled_off(keyState) && stillHeld(tapDanceIndex)) {
return release(tapDanceIndex);
}
if (!key_toggled_on (keyState))
if (!key_toggled_on(keyState))
return Key_NoKey;
interrupt ();
interrupt();
}
}
// in sequence
if (key_toggled_off (keyState))
if (key_toggled_off(keyState))
return Key_NoKey;
lastTapDanceKey.raw = mappedKey.raw;
lastTapDanceRow = row;
lastTapDanceCol = col;
bitSet (pressedState, tapDanceIndex);
bitSet(pressedState, tapDanceIndex);
if (key_toggled_on (keyState))
return tap ();
if (key_toggled_on(keyState))
return tap();
if (bitRead (triggeredState, tapDanceIndex))
tapDanceAction (tapDanceIndex, row, col, tapCount[tapDanceIndex], Hold);
if (bitRead(triggeredState, tapDanceIndex))
tapDanceAction(tapDanceIndex, row, col, tapCount[tapDanceIndex], Hold);
return Key_NoKey;
}
void
TapDance::loopHook (bool postClear) {
TapDance::loopHook(bool postClear) {
if (!postClear)
return;
for (uint8_t i = 0; i < 16; i++) {
if (!bitRead (releaseNextState, i))
if (!bitRead(releaseNextState, i))
continue;
tapDanceAction (i, lastTapDanceRow, lastTapDanceCol, tapCount[i], Release);
tapDanceAction(i, lastTapDanceRow, lastTapDanceCol, tapCount[i], Release);
tapCount[i] = 0;
bitClear (releaseNextState, i);
bitClear(releaseNextState, i);
}
if (!isActive ())
if (!isActive())
return;
if (endTime && millis () > endTime)
if (endTime && millis() > endTime)
timeout();
}
} // namespace KaleidoscopePlugins
__attribute__((weak))
void
tapDanceAction (uint8_t tapDanceIndex, byte row, byte col, uint8_t tapCount, KaleidoscopePlugins::TapDance::ActionType tapDanceAction) {
tapDanceAction(uint8_t tapDanceIndex, byte row, byte col, uint8_t tapCount, KaleidoscopePlugins::TapDance::ActionType tapDanceAction) {
}
KaleidoscopePlugins::TapDance TapDance;

@ -40,12 +40,12 @@ class TapDance : public KaleidoscopePlugin {
Release,
} ActionType;
TapDance (void);
TapDance(void);
void begin (void) final;
void begin(void) final;
static uint16_t timeOut;
void actionKeys (uint8_t tapCount, ActionType tapDanceAction, uint8_t maxKeys, const Key tapKeys[]);
void actionKeys(uint8_t tapCount, ActionType tapDanceAction, uint8_t maxKeys, const Key tapKeys[]);
private:
static uint32_t endTime;
@ -57,16 +57,16 @@ class TapDance : public KaleidoscopePlugin {
static byte lastTapDanceRow;
static byte lastTapDanceCol;
static Key eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState);
static void loopHook (bool postClear);
static Key eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState);
static void loopHook(bool postClear);
static Key tap (void);
static void interrupt (void);
static void timeout (void);
static Key release (uint8_t tapDanceIndex);
static Key tap(void);
static void interrupt(void);
static void timeout(void);
static Key release(uint8_t tapDanceIndex);
};
} // namespace KaleidoscopePlugins
void tapDanceAction (uint8_t tapDanceIndex, byte row, byte col, uint8_t tapCount, KaleidoscopePlugins::TapDance::ActionType tapDanceAction);
void tapDanceAction(uint8_t tapDanceIndex, byte row, byte col, uint8_t tapCount, KaleidoscopePlugins::TapDance::ActionType tapDanceAction);
extern KaleidoscopePlugins::TapDance TapDance;

Loading…
Cancel
Save