make astyle

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

@ -23,119 +23,119 @@
#include <Kaleidoscope-Macros.h> #include <Kaleidoscope-Macros.h>
const Key keymaps[][ROWS][COLS] PROGMEM = { const Key keymaps[][ROWS][COLS] PROGMEM = {
[0] = KEYMAP_STACKED [0] = KEYMAP_STACKED
( (
___, ___, ___, ___, ___, ___, M(0), ___, ___, ___, ___, ___, ___, M(0),
___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___,
___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___, ___,
___ ___,
),
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___,
___
),
}; };
static Key eventDropper (Key mappedKey, byte row, byte col, uint8_t keyState) { static Key eventDropper (Key mappedKey, byte row, byte col, uint8_t keyState) {
return Key_NoKey; return Key_NoKey;
} }
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
if (macroIndex == 0 && key_toggled_on (keyState)) if (macroIndex == 0 && key_toggled_on (keyState))
GhostInTheFirmware.activate (); GhostInTheFirmware.activate ();
return MACRO_NONE; return MACRO_NONE;
} }
static const KaleidoscopePlugins::GhostInTheFirmware::GhostKey ghostKeys[] PROGMEM = { static const KaleidoscopePlugins::GhostInTheFirmware::GhostKey ghostKeys[] PROGMEM = {
{0, 6, 200, 50}, {0, 6, 200, 50},
{0, 5, 200, 50}, {0, 5, 200, 50},
{0, 4, 200, 50}, {0, 4, 200, 50},
{0, 3, 200, 50}, {0, 3, 200, 50},
{0, 2, 200, 50}, {0, 2, 200, 50},
{0, 1, 200, 50}, {0, 1, 200, 50},
{0, 0, 200, 50}, {0, 0, 200, 50},
{1, 0, 200, 50}, {1, 0, 200, 50},
{1, 1, 200, 50}, {1, 1, 200, 50},
{1, 2, 200, 50}, {1, 2, 200, 50},
{1, 3, 200, 50}, {1, 3, 200, 50},
{1, 4, 200, 50}, {1, 4, 200, 50},
{1, 5, 200, 50}, {1, 5, 200, 50},
{1, 6, 200, 50}, {1, 6, 200, 50},
{2, 6, 200, 50}, {2, 6, 200, 50},
{2, 5, 200, 50}, {2, 5, 200, 50},
{2, 4, 200, 50}, {2, 4, 200, 50},
{2, 3, 200, 50}, {2, 3, 200, 50},
{2, 2, 200, 50}, {2, 2, 200, 50},
{2, 1, 200, 50}, {2, 1, 200, 50},
{2, 0, 200, 50}, {2, 0, 200, 50},
{3, 0, 200, 50}, {3, 0, 200, 50},
{3, 1, 200, 50}, {3, 1, 200, 50},
{3, 3, 200, 50}, {3, 3, 200, 50},
{3, 4, 200, 50}, {3, 4, 200, 50},
{3, 5, 200, 50}, {3, 5, 200, 50},
{0, 7, 200, 50}, {0, 7, 200, 50},
{1, 7, 200, 50}, {1, 7, 200, 50},
{2, 7, 200, 50}, {2, 7, 200, 50},
{3, 7, 200, 50}, {3, 7, 200, 50},
{3, 6, 200, 50}, {3, 6, 200, 50},
{3, 9, 200, 50}, {3, 9, 200, 50},
{3, 8, 200, 50}, {3, 8, 200, 50},
{2, 8, 200, 50}, {2, 8, 200, 50},
{1, 8, 200, 50}, {1, 8, 200, 50},
{0, 8, 200, 50}, {0, 8, 200, 50},
{3, 10, 200, 50}, {3, 10, 200, 50},
{3, 11, 200, 50}, {3, 11, 200, 50},
{3, 12, 200, 50}, {3, 12, 200, 50},
{3, 13, 200, 50}, {3, 13, 200, 50},
{3, 14, 200, 50}, {3, 14, 200, 50},
{3, 15, 200, 50}, {3, 15, 200, 50},
{2, 15, 200, 50}, {2, 15, 200, 50},
{2, 14, 200, 50}, {2, 14, 200, 50},
{2, 13, 200, 50}, {2, 13, 200, 50},
{2, 12, 200, 50}, {2, 12, 200, 50},
{2, 11, 200, 50}, {2, 11, 200, 50},
{2, 10, 200, 50}, {2, 10, 200, 50},
{2, 9, 200, 50}, {2, 9, 200, 50},
{1, 9, 200, 50}, {1, 9, 200, 50},
{1, 10, 200, 50}, {1, 10, 200, 50},
{1, 11, 200, 50}, {1, 11, 200, 50},
{1, 12, 200, 50}, {1, 12, 200, 50},
{1, 13, 200, 50}, {1, 13, 200, 50},
{1, 14, 200, 50}, {1, 14, 200, 50},
{1, 15, 200, 50}, {1, 15, 200, 50},
{0, 15, 200, 50}, {0, 15, 200, 50},
{0, 14, 200, 50}, {0, 14, 200, 50},
{0, 13, 200, 50}, {0, 13, 200, 50},
{0, 12, 200, 50}, {0, 12, 200, 50},
{0, 11, 200, 50}, {0, 11, 200, 50},
{0, 10, 200, 50}, {0, 10, 200, 50},
{0, 9, 200, 50}, {0, 9, 200, 50},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
void setup () { void setup () {
Serial.begin (9600); Serial.begin (9600);
Kaleidoscope.setup (KEYMAP_SIZE); Kaleidoscope.setup (KEYMAP_SIZE);
GhostInTheFirmware.configure (ghostKeys); GhostInTheFirmware.configure (ghostKeys);
StalkerEffect.configure (STALKER (BlazingTrail, NULL)); StalkerEffect.configure (STALKER (BlazingTrail, NULL));
Kaleidoscope.use (&LEDControl, &GhostInTheFirmware, &StalkerEffect, &Macros, Kaleidoscope.use (&LEDControl, &GhostInTheFirmware, &StalkerEffect, &Macros,
NULL); NULL);
event_handler_hook_use (eventDropper); event_handler_hook_use (eventDropper);
} }
void loop () { void loop () {
Kaleidoscope.loop (); Kaleidoscope.loop ();
} }

@ -20,68 +20,68 @@
#include <Kaleidoscope-GhostInTheFirmware.h> #include <Kaleidoscope-GhostInTheFirmware.h>
namespace KaleidoscopePlugins { namespace KaleidoscopePlugins {
GhostInTheFirmware::GhostKey *GhostInTheFirmware::ghostKeys; GhostInTheFirmware::GhostKey *GhostInTheFirmware::ghostKeys;
bool GhostInTheFirmware::isActive; bool GhostInTheFirmware::isActive;
bool GhostInTheFirmware::isPressed; bool GhostInTheFirmware::isPressed;
uint16_t GhostInTheFirmware::currentPos; uint16_t GhostInTheFirmware::currentPos;
uint32_t GhostInTheFirmware::startTime; uint32_t GhostInTheFirmware::startTime;
uint16_t GhostInTheFirmware::pressTimeOut; uint16_t GhostInTheFirmware::pressTimeOut;
uint16_t GhostInTheFirmware::delayTimeOut; uint16_t GhostInTheFirmware::delayTimeOut;
GhostInTheFirmware::GhostInTheFirmware (void) { GhostInTheFirmware::GhostInTheFirmware (void) {
} }
void void
GhostInTheFirmware::begin (void) { GhostInTheFirmware::begin (void) {
loop_hook_use (this->loopHook); loop_hook_use (this->loopHook);
} }
void void
GhostInTheFirmware::activate (void) { GhostInTheFirmware::activate (void) {
isActive = true; isActive = true;
} }
void void
GhostInTheFirmware::configure (const GhostKey ghostKeys_[]) { GhostInTheFirmware::configure (const GhostKey ghostKeys_[]) {
ghostKeys = (GhostKey *)ghostKeys_; ghostKeys = (GhostKey *)ghostKeys_;
} }
void void
GhostInTheFirmware::loopHook (bool postClear) { GhostInTheFirmware::loopHook (bool postClear) {
if (postClear || !isActive) if (postClear || !isActive)
return; return;
if (pressTimeOut == 0) { if (pressTimeOut == 0) {
pressTimeOut = pgm_read_word (&(ghostKeys[currentPos].pressTime)); pressTimeOut = pgm_read_word (&(ghostKeys[currentPos].pressTime));
delayTimeOut = pgm_read_word (&(ghostKeys[currentPos].delay)); delayTimeOut = pgm_read_word (&(ghostKeys[currentPos].delay));
if (pressTimeOut == 0) { if (pressTimeOut == 0) {
currentPos = 0; currentPos = 0;
isActive = false; isActive = false;
return; return;
} }
isPressed = true; isPressed = true;
startTime = millis ();
} else {
if (isPressed && ((millis () - startTime) > pressTimeOut)) {
isPressed = false;
startTime = millis (); startTime = millis ();
} else {
if (isPressed && ((millis () - startTime) > pressTimeOut)) {
isPressed = false;
startTime = millis ();
byte row = pgm_read_byte (&(ghostKeys[currentPos].row)); byte row = pgm_read_byte (&(ghostKeys[currentPos].row));
byte col = pgm_read_byte (&(ghostKeys[currentPos].col)); byte col = pgm_read_byte (&(ghostKeys[currentPos].col));
handle_keyswitch_event (Key_NoKey, row, col, WAS_PRESSED); handle_keyswitch_event (Key_NoKey, row, col, WAS_PRESSED);
} else if (isPressed) { } else if (isPressed) {
byte row = pgm_read_byte (&(ghostKeys[currentPos].row)); byte row = pgm_read_byte (&(ghostKeys[currentPos].row));
byte col = pgm_read_byte (&(ghostKeys[currentPos].col)); byte col = pgm_read_byte (&(ghostKeys[currentPos].col));
handle_keyswitch_event (Key_NoKey, row, col, IS_PRESSED); handle_keyswitch_event (Key_NoKey, row, col, IS_PRESSED);
} else if ((millis () - startTime) > delayTimeOut) { } else if ((millis () - startTime) > delayTimeOut) {
currentPos++; currentPos++;
pressTimeOut = 0; pressTimeOut = 0;
} }
} }
} }
}; };

@ -21,13 +21,13 @@
#include <Kaleidoscope.h> #include <Kaleidoscope.h>
namespace KaleidoscopePlugins { namespace KaleidoscopePlugins {
class GhostInTheFirmware : public KaleidoscopePlugin { class GhostInTheFirmware : public KaleidoscopePlugin {
public: public:
typedef struct { typedef struct {
byte row; byte row;
byte col; byte col;
uint16_t pressTime; uint16_t pressTime;
uint16_t delay; uint16_t delay;
} GhostKey; } GhostKey;
GhostInTheFirmware (void); GhostInTheFirmware (void);
@ -46,7 +46,7 @@ namespace KaleidoscopePlugins {
static uint16_t delayTimeOut; static uint16_t delayTimeOut;
static void loopHook (bool postClear); static void loopHook (bool postClear);
}; };
}; };

Loading…
Cancel
Save