astyle pass

pull/135/head
Jesse Vincent 8 years ago
parent 57ebb17d8f
commit 8c6b8433cc
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -50,18 +50,18 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
switch (macroIndex) { switch (macroIndex) {
case M_APPSWITCH: case M_APPSWITCH:
return macroAppSwitch (keyState); return macroAppSwitch(keyState);
case M_APPCANCEL: case M_APPCANCEL:
return macroAppCancel (keyState); return macroAppCancel(keyState);
} }
return MACRO_NONE; return MACRO_NONE;
} }
void setup () { void setup() {
Kaleidoscope.setup (KEYMAP_SIZE); Kaleidoscope.setup(KEYMAP_SIZE);
Kaleidoscope.use (&HostOS, &Macros, NULL); Kaleidoscope.use(&HostOS, &Macros, NULL);
} }
void loop () { void loop() {
Kaleidoscope.loop (); Kaleidoscope.loop();
} }

@ -27,10 +27,10 @@ using namespace KaleidoscopePlugins::HostOS;
static bool appSwitchActive = false; static bool appSwitchActive = false;
const macro_t *macroAppSwitch (uint8_t keyState) { const macro_t *macroAppSwitch(uint8_t keyState) {
Key mod = Key_LeftAlt; Key mod = Key_LeftAlt;
if (HostOS.os () == OSX) if (HostOS.os() == OSX)
mod = Key_LeftGui; mod = Key_LeftGui;
// Key was just pressed, or is being held // Key was just pressed, or is being held
@ -50,8 +50,8 @@ const macro_t *macroAppSwitch (uint8_t keyState) {
return MACRO_NONE; return MACRO_NONE;
} }
const macro_t *macroAppCancel (uint8_t keyState) { const macro_t *macroAppCancel(uint8_t keyState) {
if (key_toggled_on (keyState)) if (key_toggled_on(keyState))
appSwitchActive = false; appSwitchActive = false;
return MACRO_NONE; return MACRO_NONE;
} }

@ -26,5 +26,5 @@ enum {
M_APPCANCEL, M_APPCANCEL,
}; };
const macro_t *macroAppSwitch (uint8_t keyState); const macro_t *macroAppSwitch(uint8_t keyState);
const macro_t *macroAppCancel (uint8_t keyState); const macro_t *macroAppCancel(uint8_t keyState);

@ -26,13 +26,13 @@
Key_Home, Key_mouseL, Key_mouseDn, Key_mouseR, Key_mouseWarpSW, Key_mouseWarpSE, \ Key_Home, Key_mouseL, Key_mouseDn, Key_mouseR, Key_mouseWarpSW, Key_mouseWarpSE, \
Key_End, Key_Z, Key_X, Key_C, Key_V, Key_mouseWarpEnd, ___, \ Key_End, Key_Z, Key_X, Key_C, Key_V, Key_mouseWarpEnd, ___, \
Key_LeftControl, Key_mouseBtnL, Key_LeftGui, Key_LeftShift, \ Key_LeftControl, Key_mouseBtnL, Key_LeftGui, Key_LeftShift, \
___,\ ___, \
\ \
XXX, Key_F6, Key_F7, Key_F8, Key_F9, ___, ___,\ XXX, Key_F6, Key_F7, Key_F8, Key_F9, ___, ___, \
Key_Delete, Consumer_PlaySlashPause, Key_LeftCurlyBracket, Key_RightCurlyBracket, Key_LeftBracket, Key_RightBracket, System_Sleep,\ Key_Delete, Consumer_PlaySlashPause, Key_LeftCurlyBracket, Key_RightCurlyBracket, Key_LeftBracket, Key_RightBracket, System_Sleep, \
Key_LeftArrow, Key_DownArrow, Key_UpArrow, Key_RightArrow, Key_F11, Key_F12,\ Key_LeftArrow, Key_DownArrow, Key_UpArrow, Key_RightArrow, Key_F11, Key_F12, \
___, Consumer_VolumeDecrement, Consumer_VolumeIncrement, Key_BacklightDown, Key_BacklightUp, Key_Backslash, Key_Pipe,\ ___, Consumer_VolumeDecrement, Consumer_VolumeIncrement, Key_BacklightDown, Key_BacklightUp, Key_Backslash, Key_Pipe, \
Key_RightShift, Key_RightAlt, Key_mouseBtnR, Key_RightControl,\ Key_RightShift, Key_RightAlt, Key_mouseBtnR, Key_RightControl, \
___\ ___\
) )
@ -44,7 +44,7 @@
___, ___, ___, ___, ___, ___, ___, ___, ___, Key_Keypad4, Key_Keypad5, Key_Keypad6, Key_KeypadAdd, ___, \ ___, ___, ___, ___, ___, ___, ___, ___, ___, Key_Keypad4, Key_Keypad5, Key_Keypad6, Key_KeypadAdd, ___, \
___, ___, ___, ___, ___, ___, ___, Key_Keypad1, Key_Keypad2, Key_Keypad3, Key_Equals, Key_Quote, \ ___, ___, ___, ___, ___, ___, ___, Key_Keypad1, Key_Keypad2, Key_Keypad3, Key_Equals, Key_Quote, \
___, ___, ___, ___, ___, ___, ___, ___, ___, Key_Keypad0, Key_KeypadDot, Key_KeypadMultiply, Key_KeypadDivide, Key_Enter, \ ___, ___, ___, ___, ___, ___, ___, ___, ___, Key_Keypad0, Key_KeypadDot, Key_KeypadMultiply, Key_KeypadDivide, Key_Enter, \
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,\ Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, \
Key_Keymap1_Momentary, Key_Keymap1_Momentary \ Key_Keymap1_Momentary, Key_Keymap1_Momentary \
) )
@ -53,7 +53,7 @@
Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab, Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals, \ Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab, Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals, \
Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G, Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote, \ Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G, Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote, \
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape, ___, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus, \ Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape, ___, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus, \
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,\ Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, \
Key_KeymapNext_Momentary, Key_KeymapNext_Momentary \ Key_KeymapNext_Momentary, Key_KeymapNext_Momentary \
) )
@ -65,17 +65,17 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
}; };
static LEDSolidColor solidRed (60, 0, 0); static LEDSolidColor solidRed(60, 0, 0);
static LEDSolidColor solidOrange (60, 20, 0); static LEDSolidColor solidOrange(60, 20, 0);
static LEDSolidColor solidYellow (40, 35, 0); static LEDSolidColor solidYellow(40, 35, 0);
static LEDSolidColor solidGreen (0, 100, 0); static LEDSolidColor solidGreen(0, 100, 0);
static LEDSolidColor solidBlue (0, 15, 100); static LEDSolidColor solidBlue(0, 15, 100);
static LEDSolidColor solidIndigo (0, 0, 100); static LEDSolidColor solidIndigo(0, 0, 100);
static LEDSolidColor solidViolet (70, 0, 60); static LEDSolidColor solidViolet(70, 0, 60);
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
if (macroIndex == TOGGLENUMLOCK && key_toggled_on(keyState)) { if (macroIndex == TOGGLENUMLOCK && key_toggled_on(keyState)) {
return NumLock.toggle (Macros.row, Macros.col, NUMPAD_KEYMAP); return NumLock.toggle(Macros.row, Macros.col, NUMPAD_KEYMAP);
} }
if (macroIndex == 1 && key_toggled_on(keyState)) { if (macroIndex == 1 && key_toggled_on(keyState)) {

@ -13,7 +13,7 @@ Kaleidoscope_::setup(void) {
Keyboard.begin(); Keyboard.begin();
// A workaround, so that the compiler does not optimize this out... // A workaround, so that the compiler does not optimize this out...
handle_keyswitch_event (Key_NoKey, 255, 255, 0); handle_keyswitch_event(Key_NoKey, 255, 255, 0);
} }
void void
@ -58,12 +58,12 @@ Kaleidoscope_::replaceEventHandlerHook(eventHandlerHook oldHook, eventHandlerHoo
} }
void void
Kaleidoscope_::appendEventHandlerHook (eventHandlerHook hook) { Kaleidoscope_::appendEventHandlerHook(eventHandlerHook hook) {
replaceEventHandlerHook((eventHandlerHook)NULL, hook); replaceEventHandlerHook((eventHandlerHook)NULL, hook);
} }
void void
Kaleidoscope_::useEventHandlerHook (eventHandlerHook hook) { Kaleidoscope_::useEventHandlerHook(eventHandlerHook hook) {
for (byte i = 0; i < HOOK_MAX; i++) { for (byte i = 0; i < HOOK_MAX; i++) {
if (eventHandlers[i] == hook) if (eventHandlers[i] == hook)
return; return;
@ -92,7 +92,7 @@ Kaleidoscope_::useLoopHook(loopHook hook) {
if (loopHooks[i] == hook) if (loopHooks[i] == hook)
return; return;
} }
appendLoopHook (hook); appendLoopHook(hook);
} }
bool bool
@ -106,7 +106,7 @@ Kaleidoscope_::focusHook(const char *command) {
if (strncmp_P(command, PSTR("layer."), 6) != 0) if (strncmp_P(command, PSTR("layer."), 6) != 0)
return false; return false;
if (strcmp_P (command + 6, PSTR("on")) == 0) if (strcmp_P(command + 6, PSTR("on")) == 0)
subCommand = ON; subCommand = ON;
else if (strcmp_P(command + 6, PSTR("off")) == 0) else if (strcmp_P(command + 6, PSTR("off")) == 0)
subCommand = OFF; subCommand = OFF;

@ -82,7 +82,7 @@ class Kaleidoscope_ {
* functions will, on the other hand, just append the hooks, and not care about * functions will, on the other hand, just append the hooks, and not care about
* protection. * protection.
*/ */
typedef Key (*eventHandlerHook)(Key mappedKey, byte row, byte col, uint8_t keyState); typedef Key(*eventHandlerHook)(Key mappedKey, byte row, byte col, uint8_t keyState);
static eventHandlerHook eventHandlers[HOOK_MAX]; static eventHandlerHook eventHandlers[HOOK_MAX];
static void replaceEventHandlerHook(eventHandlerHook oldHook, eventHandlerHook newHook); static void replaceEventHandlerHook(eventHandlerHook oldHook, eventHandlerHook newHook);

@ -31,7 +31,7 @@ static bool handle_keyswitch_event_default(Key mappedKey, byte row, byte col, ui
// for every newly released button, figure out what logical key it is and send a key up event // for every newly released button, figure out what logical key it is and send a key up event
if (mappedKey.flags & SYNTHETIC) { if (mappedKey.flags & SYNTHETIC) {
handle_synthetic_keyswitch_event( mappedKey, keyState); handle_synthetic_keyswitch_event(mappedKey, keyState);
} else if (key_is_pressed(keyState)) { } else if (key_is_pressed(keyState)) {
press_key(mappedKey); press_key(mappedKey);
} else if (key_toggled_off(keyState) && (keyState & INJECTED)) { } else if (key_toggled_off(keyState) && (keyState & INJECTED)) {

@ -5,25 +5,25 @@ static uint32_t LayerState;
uint8_t Layer_::highestLayer; uint8_t Layer_::highestLayer;
uint8_t Layer_::keyMap[ROWS][COLS]; uint8_t Layer_::keyMap[ROWS][COLS];
Key (*Layer_::getKey)(uint8_t layer, byte row, byte col) = Layer.getKeyFromPROGMEM; Key(*Layer_::getKey)(uint8_t layer, byte row, byte col) = Layer.getKeyFromPROGMEM;
static void handle_keymap_keyswitch_event(Key keymapEntry, uint8_t keyState) { static void handle_keymap_keyswitch_event(Key keymapEntry, uint8_t keyState) {
if (keymapEntry.keyCode >= MOMENTARY_OFFSET) { if (keymapEntry.keyCode >= MOMENTARY_OFFSET) {
uint8_t target = keymapEntry.keyCode - MOMENTARY_OFFSET; uint8_t target = keymapEntry.keyCode - MOMENTARY_OFFSET;
if (key_toggled_on(keyState)) { if (key_toggled_on(keyState)) {
if ( target == KEYMAP_NEXT) { if (target == KEYMAP_NEXT) {
Layer.next(); Layer.next();
} else if ( target == KEYMAP_PREVIOUS) { } else if (target == KEYMAP_PREVIOUS) {
Layer.previous(); Layer.previous();
} else { } else {
Layer.on(target); Layer.on(target);
} }
} }
if (key_toggled_off(keyState)) { if (key_toggled_off(keyState)) {
if ( target == KEYMAP_NEXT) { if (target == KEYMAP_NEXT) {
Layer.previous(); Layer.previous();
} else if ( target == KEYMAP_PREVIOUS) { } else if (target == KEYMAP_PREVIOUS) {
Layer.next(); Layer.next();
} else { } else {
Layer.off(target); Layer.off(target);
@ -32,7 +32,7 @@ static void handle_keymap_keyswitch_event(Key keymapEntry, uint8_t keyState) {
// switch keymap and stay there // switch keymap and stay there
} else if (key_toggled_on(keyState)) { } else if (key_toggled_on(keyState)) {
if (Layer.isOn (keymapEntry.keyCode) && keymapEntry.keyCode) if (Layer.isOn(keymapEntry.keyCode) && keymapEntry.keyCode)
Layer.off(keymapEntry.keyCode); Layer.off(keymapEntry.keyCode);
else else
Layer.on(keymapEntry.keyCode); Layer.on(keymapEntry.keyCode);
@ -48,12 +48,12 @@ Layer_::eventHandler(Key mappedKey, byte row, byte col, uint8_t keyState) {
return Key_NoKey; return Key_NoKey;
} }
Layer_::Layer_ (void) { Layer_::Layer_(void) {
defaultLayer (0); defaultLayer(0);
} }
Key Key
Layer_::getKeyFromPROGMEM (uint8_t layer, byte row, byte col) { Layer_::getKeyFromPROGMEM(uint8_t layer, byte row, byte col) {
Key key; Key key;
key.raw = pgm_read_word(&(keymaps[layer][row][col])); key.raw = pgm_read_word(&(keymaps[layer][row][col]));
@ -64,7 +64,7 @@ Layer_::getKeyFromPROGMEM (uint8_t layer, byte row, byte col) {
void void
Layer_::mergeLayers(void) { Layer_::mergeLayers(void) {
memset (keyMap, DefaultLayer, ROWS * COLS); memset(keyMap, DefaultLayer, ROWS * COLS);
if (LayerState == (uint32_t)(1 << DefaultLayer)) if (LayerState == (uint32_t)(1 << DefaultLayer))
return; return;
@ -74,7 +74,7 @@ Layer_::mergeLayers(void) {
int8_t layer = highestLayer; int8_t layer = highestLayer;
while (layer > DefaultLayer) { while (layer > DefaultLayer) {
if (Layer.isOn (layer)) { if (Layer.isOn(layer)) {
Key mappedKey = (*getKey)(layer, r, c); Key mappedKey = (*getKey)(layer, r, c);
if (mappedKey != Key_Transparent) { if (mappedKey != Key_Transparent) {
@ -94,55 +94,55 @@ Key Layer_::lookup(byte row, byte col) {
return (*getKey)(layer, row, col); return (*getKey)(layer, row, col);
} }
uint8_t Layer_::top (void) { uint8_t Layer_::top(void) {
for (int8_t i = 31; i >= 0; i--) { for (int8_t i = 31; i >= 0; i--) {
if (bitRead (LayerState, i)) if (bitRead(LayerState, i))
return i; return i;
} }
return 0; return 0;
} }
void Layer_::move (uint8_t layer) { void Layer_::move(uint8_t layer) {
LayerState = 0; LayerState = 0;
on (layer); on(layer);
} }
void Layer_::on (uint8_t layer) { void Layer_::on(uint8_t layer) {
bitSet (LayerState, layer); bitSet(LayerState, layer);
if (layer > highestLayer) if (layer > highestLayer)
highestLayer = layer; highestLayer = layer;
mergeLayers(); mergeLayers();
} }
void Layer_::off (uint8_t layer) { void Layer_::off(uint8_t layer) {
bitClear (LayerState, layer); bitClear(LayerState, layer);
if (layer == highestLayer) if (layer == highestLayer)
highestLayer = top(); highestLayer = top();
mergeLayers(); mergeLayers();
} }
boolean Layer_::isOn (uint8_t layer) { boolean Layer_::isOn(uint8_t layer) {
return bitRead(LayerState, layer); return bitRead(LayerState, layer);
} }
void Layer_::next (void) { void Layer_::next(void) {
on (top () + 1); on(top() + 1);
} }
void Layer_::previous (void) { void Layer_::previous(void) {
off (top ()); off(top());
} }
void Layer_::defaultLayer (uint8_t layer) { void Layer_::defaultLayer(uint8_t layer) {
move (layer); move(layer);
DefaultLayer = layer; DefaultLayer = layer;
} }
uint8_t Layer_::defaultLayer (void) { uint8_t Layer_::defaultLayer(void) {
return DefaultLayer; return DefaultLayer;
} }
uint32_t Layer_::getLayerState (void) { uint32_t Layer_::getLayerState(void) {
return LayerState; return LayerState;
} }

@ -26,7 +26,7 @@ class Layer_ {
static Key eventHandler(Key mappedKey, byte row, byte col, uint8_t keyState); static Key eventHandler(Key mappedKey, byte row, byte col, uint8_t keyState);
static Key (*getKey)(uint8_t layer, byte row, byte col); static Key(*getKey)(uint8_t layer, byte row, byte col);
static Key getKeyFromPROGMEM(uint8_t layer, byte row, byte col); static Key getKeyFromPROGMEM(uint8_t layer, byte row, byte col);
@ -37,6 +37,6 @@ class Layer_ {
static void mergeLayers(void); static void mergeLayers(void);
}; };
Key layer_getKey (uint8_t layer, uint8_t r, uint8_t c); Key layer_getKey(uint8_t layer, uint8_t r, uint8_t c);
extern Layer_ Layer; extern Layer_ Layer;

Loading…
Cancel
Save