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>
const Key keymaps[][ROWS][COLS] PROGMEM = {
[0] = KEYMAP_STACKED
(
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_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,
[0] = KEYMAP_STACKED
(
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_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_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
Key_Cycle,
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
Key_Cycle,
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_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_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_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_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_Cycle
),
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_Cycle
),
};
void cycleAction (Key previousKey, uint8_t cycleCount) {
if (previousKey.raw == Key_E.raw) {
if (cycleCount == 1) {
Cycle.replace (Key_F);
} else if (cycleCount == 2) {
Cycle.replace (Key_G);
if (previousKey.raw == Key_E.raw) {
if (cycleCount == 1) {
Cycle.replace (Key_F);
} else if (cycleCount == 2) {
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 () {
Kaleidoscope.setup (KEYMAP_SIZE);
Kaleidoscope.setup (KEYMAP_SIZE);
Kaleidoscope.use (&Cycle, NULL);
Kaleidoscope.use (&Cycle, NULL);
}
void loop () {
Kaleidoscope.loop ();
Kaleidoscope.loop ();
}

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

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

Loading…
Cancel
Save