make astyle

pull/389/head
Jesse Vincent 8 years ago
parent 903230ec14
commit 14d236ed39
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -20,45 +20,45 @@
#include <Kaleidoscope-Cycle.h> #include <Kaleidoscope-Cycle.h>
const Key keymaps[][ROWS][COLS] PROGMEM = { const Key keymaps[][ROWS][COLS] PROGMEM = {
[0] = KEYMAP_STACKED [0] = KEYMAP_STACKED
( (
Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey,
Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab, Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G, Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G,
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape, Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
Key_Cycle, Key_Cycle,
Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip, Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip,
Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals, Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals,
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote, Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
Key_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus, Key_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_Cycle Key_Cycle
), ),
}; };
void cycleAction (Key previousKey, uint8_t cycleCount) { void cycleAction (Key previousKey, uint8_t cycleCount) {
if (previousKey.raw == Key_E.raw) { if (previousKey.raw == Key_E.raw) {
if (cycleCount == 1) { if (cycleCount == 1) {
Cycle.replace (Key_F); Cycle.replace (Key_F);
} else if (cycleCount == 2) { } else if (cycleCount == 2) {
Cycle.replace (Key_G); Cycle.replace (Key_G);
}
}
if (previousKey.raw == Key_A.raw) {
cycleThrough (Key_A, Key_B, Key_C, Key_D);
} }
}
if (previousKey.raw == Key_A.raw) {
cycleThrough (Key_A, Key_B, Key_C, Key_D);
}
} }
void setup () { void setup () {
Kaleidoscope.setup (KEYMAP_SIZE); Kaleidoscope.setup (KEYMAP_SIZE);
Kaleidoscope.use (&Cycle, NULL); Kaleidoscope.use (&Cycle, NULL);
} }
void loop () { void loop () {
Kaleidoscope.loop (); Kaleidoscope.loop ();
} }

@ -22,26 +22,26 @@
using namespace KaleidoscopePlugins::Ranges; using namespace KaleidoscopePlugins::Ranges;
namespace KaleidoscopePlugins { namespace KaleidoscopePlugins {
// --- state --- // --- state ---
Key Cycle::lastNonCycleKey; Key Cycle::lastNonCycleKey;
uint8_t Cycle::cycleCount; uint8_t Cycle::cycleCount;
// --- helpers --- // --- helpers ---
#define isCycle(k) (k.raw == CYCLE) #define isCycle(k) (k.raw == CYCLE)
// --- api --- // --- api ---
Cycle::Cycle (void) { Cycle::Cycle (void) {
} }
void void
Cycle::begin (void) { Cycle::begin (void) {
event_handler_hook_use (this->eventHandlerHook); event_handler_hook_use (this->eventHandlerHook);
} }
void void
Cycle::replace (Key key) { Cycle::replace (Key key) {
handle_keyswitch_event (Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED | INJECTED); handle_keyswitch_event (Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED | INJECTED);
Keyboard.sendReport (); Keyboard.sendReport ();
handle_keyswitch_event (Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED); handle_keyswitch_event (Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED);
@ -51,45 +51,45 @@ namespace KaleidoscopePlugins {
Keyboard.sendReport (); Keyboard.sendReport ();
handle_keyswitch_event (key, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED); handle_keyswitch_event (key, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED);
Keyboard.sendReport (); Keyboard.sendReport ();
} }
void void
Cycle::replace (uint8_t cycleSize, const Key cycleSteps[]) { Cycle::replace (uint8_t cycleSize, const Key cycleSteps[]) {
uint8_t idx = cycleCount % cycleSize; uint8_t idx = cycleCount % cycleSize;
Key key; Key key;
key.raw = pgm_read_word (cycleSteps + idx); key.raw = pgm_read_word (cycleSteps + idx);
replace (key); replace (key);
} }
// --- hooks --- // --- hooks ---
Key Key
Cycle::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) { Cycle::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
if (keyState & INJECTED) if (keyState & INJECTED)
return mappedKey; return mappedKey;
if (!key_is_pressed (keyState) && !key_was_pressed (keyState)) { if (!key_is_pressed (keyState) && !key_was_pressed (keyState)) {
if (isCycle (mappedKey)) if (isCycle (mappedKey))
return Key_NoKey; return Key_NoKey;
return mappedKey; return mappedKey;
} }
if (!isCycle (mappedKey)) { if (!isCycle (mappedKey)) {
if (key_toggled_on (keyState)) { if (key_toggled_on (keyState)) {
lastNonCycleKey.raw = mappedKey.raw; lastNonCycleKey.raw = mappedKey.raw;
cycleCount = 0; cycleCount = 0;
} }
return mappedKey; return mappedKey;
} }
if (!key_toggled_off (keyState)) if (!key_toggled_off (keyState))
return Key_NoKey; return Key_NoKey;
cycleCount++; cycleCount++;
cycleAction (lastNonCycleKey, cycleCount); cycleAction (lastNonCycleKey, cycleCount);
return Key_NoKey; return Key_NoKey;
} }
}; };
__attribute__((weak)) __attribute__((weak))

@ -28,7 +28,7 @@
}) })
namespace KaleidoscopePlugins { namespace KaleidoscopePlugins {
class Cycle : public KaleidoscopePlugin { class Cycle : public KaleidoscopePlugin {
public: public:
Cycle (void); Cycle (void);
@ -42,7 +42,7 @@ namespace KaleidoscopePlugins {
static uint8_t cycleCount; static uint8_t cycleCount;
static Key eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState); static Key eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState);
}; };
}; };
void cycleAction (Key previousKey, uint8_t cycleCount); void cycleAction (Key previousKey, uint8_t cycleCount);

Loading…
Cancel
Save