make astyle

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

@ -43,32 +43,32 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
),
};
void systerAction (KaleidoscopePlugins::Syster::action_t action, const char *symbol) {
void systerAction(KaleidoscopePlugins::Syster::action_t action, const char *symbol) {
switch (action) {
case KaleidoscopePlugins::Syster::StartAction:
Unicode.type (0x2328);
Unicode.type(0x2328);
break;
case KaleidoscopePlugins::Syster::EndAction:
handle_keyswitch_event (Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED | INJECTED);
Keyboard.sendReport ();
handle_keyswitch_event (Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED);
Keyboard.sendReport ();
handle_keyswitch_event(Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED | INJECTED);
Keyboard.sendReport();
handle_keyswitch_event(Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED);
Keyboard.sendReport();
break;
case KaleidoscopePlugins::Syster::SymbolAction:
Serial.print ("systerAction: symbol=");
Serial.println (symbol);
if (strcmp (symbol, "coffee") == 0) {
Unicode.type (0x2615);
Serial.print("systerAction: symbol=");
Serial.println(symbol);
if (strcmp(symbol, "coffee") == 0) {
Unicode.type(0x2615);
}
break;
}
}
void setup () {
Kaleidoscope.setup (KEYMAP_SIZE);
Kaleidoscope.use (&Unicode, &Syster, NULL);
void setup() {
Kaleidoscope.setup(KEYMAP_SIZE);
Kaleidoscope.use(&Unicode, &Syster, NULL);
}
void loop () {
Kaleidoscope.loop ();
void loop() {
Kaleidoscope.loop();
}

@ -32,16 +32,16 @@ bool Syster::isActive;
// --- api ---
Syster::Syster (void) {
Syster::Syster(void) {
}
void
Syster::begin (void) {
event_handler_hook_use (this->eventHandlerHook);
Syster::begin(void) {
event_handler_hook_use(this->eventHandlerHook);
}
void
Syster::reset (void) {
Syster::reset(void) {
symbolPos = 0;
symbol[0] = 0;
isActive = false;
@ -49,14 +49,14 @@ Syster::reset (void) {
// --- hooks ---
Key
Syster::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
Syster::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState) {
if (!isActive) {
if (!isSyster (mappedKey))
if (!isSyster(mappedKey))
return mappedKey;
if (key_toggled_on (keyState)) {
if (key_toggled_on(keyState)) {
isActive = true;
systerAction (StartAction, NULL);
systerAction(StartAction, NULL);
}
return Key_NoKey;
}
@ -64,37 +64,37 @@ Syster::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
if (keyState & INJECTED)
return mappedKey;
if (isSyster (mappedKey))
if (isSyster(mappedKey))
return Key_NoKey;
if (mappedKey == Key_Backspace && symbolPos == 0)
return Key_NoKey;
if (key_toggled_off (keyState)) {
if (key_toggled_off(keyState)) {
if (mappedKey == Key_Spacebar) {
for (uint8_t i = 0; i <= symbolPos; i++) {
handle_keyswitch_event (Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED | INJECTED);
Keyboard.sendReport ();
handle_keyswitch_event (Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED);
Keyboard.sendReport ();
handle_keyswitch_event(Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED | INJECTED);
Keyboard.sendReport();
handle_keyswitch_event(Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED);
Keyboard.sendReport();
}
systerAction (EndAction, NULL);
systerAction(EndAction, NULL);
symbol[symbolPos] = 0;
systerAction (SymbolAction, symbol);
reset ();
systerAction(SymbolAction, symbol);
reset();
return Key_NoKey;
}
}
if (key_toggled_on (keyState)) {
if (key_toggled_on(keyState)) {
if (mappedKey == Key_Backspace) {
if (symbolPos > 0)
symbolPos--;
} else {
const char c = keyToChar (mappedKey);
const char c = keyToChar(mappedKey);
if (c)
symbol[symbolPos++] = c;
}
@ -106,7 +106,7 @@ Syster::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
__attribute__((weak))
const char
keyToChar (Key key) {
keyToChar(Key key) {
if (key.flags != 0)
return 0;
@ -122,7 +122,7 @@ keyToChar (Key key) {
__attribute__((weak))
void
systerAction (KaleidoscopePlugins::Syster::action_t action, const char *symbol) {
systerAction(KaleidoscopePlugins::Syster::action_t action, const char *symbol) {
}
KaleidoscopePlugins::Syster Syster;

@ -34,21 +34,21 @@ class Syster : public KaleidoscopePlugin {
SymbolAction
} action_t;
Syster (void);
Syster(void);
void begin (void) final;
static void reset (void);
void begin(void) final;
static void reset(void);
private:
static char symbol[SYSTER_MAX_SYMBOL_LENGTH + 1];
static uint8_t symbolPos;
static bool isActive;
static Key eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState);
static Key eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState);
};
};
const char keyToChar (Key key);
void systerAction (KaleidoscopePlugins::Syster::action_t action, const char *symbol);
const char keyToChar(Key key);
void systerAction(KaleidoscopePlugins::Syster::action_t action, const char *symbol);
extern KaleidoscopePlugins::Syster Syster;

Loading…
Cancel
Save