Ran astyle on code

pull/389/head
Ben Gemperline 7 years ago
parent 4ca7664442
commit 51f0acbb94

@ -47,15 +47,15 @@ void setup() {
//Setting is {KeyThatWasPressed, AlternativeKeyToSend, TimeoutInMS} //Setting is {KeyThatWasPressed, AlternativeKeyToSend, TimeoutInMS}
static kaleidoscope::ModifierKeyMap spacecadetmap[] = { static kaleidoscope::ModifierKeyMap spacecadetmap[] = {
{Key_LeftShift, Key_LeftParen, 250} {Key_LeftShift, Key_LeftParen, 250}
,{Key_RightShift, Key_RightParen, 250} , {Key_RightShift, Key_RightParen, 250}
,{Key_LeftGui, Key_LeftCurlyBracket, 250} , {Key_LeftGui, Key_LeftCurlyBracket, 250}
,{Key_RightAlt, Key_RightCurlyBracket, 250} , {Key_RightAlt, Key_RightCurlyBracket, 250}
,{Key_LeftAlt, Key_RightCurlyBracket, 250} , {Key_LeftAlt, Key_RightCurlyBracket, 250}
,{Key_LeftControl, Key_LeftBracket, 250} , {Key_LeftControl, Key_LeftBracket, 250}
,{Key_RightControl, Key_RightBracket, 250} , {Key_RightControl, Key_RightBracket, 250}
}; };
//Set the map and the number of entries //Set the map and the number of entries
SpaceCadet.setMap(spacecadetmap, sizeof(spacecadetmap)/sizeof(spacecadetmap[0])); SpaceCadet.setMap(spacecadetmap, sizeof(spacecadetmap) / sizeof(spacecadetmap[0]));
Kaleidoscope.setup(); Kaleidoscope.setup();
} }

@ -21,35 +21,35 @@
namespace kaleidoscope { namespace kaleidoscope {
//Default, empty constructor //Default, empty constructor
ModifierKeyMap::ModifierKeyMap(){ ModifierKeyMap::ModifierKeyMap() {
} }
//Constructor with input and output, and assume default timeout //Constructor with input and output, and assume default timeout
ModifierKeyMap::ModifierKeyMap(Key input_, Key output_){ ModifierKeyMap::ModifierKeyMap(Key input_, Key output_) {
input = input_; input = input_;
output = output_; output = output_;
} }
//Constructor with all three set //Constructor with all three set
ModifierKeyMap::ModifierKeyMap(Key input_, Key output_, uint16_t timeout_) { ModifierKeyMap::ModifierKeyMap(Key input_, Key output_, uint16_t timeout_) {
input = input_; input = input_;
output = output_; output = output_;
timeout = timeout_; timeout = timeout_;
} }
//Space Cadet //Space Cadet
uint8_t SpaceCadet::map_size_ = 0; uint8_t SpaceCadet::map_size_ = 0;
ModifierKeyMap * SpaceCadet::map_; ModifierKeyMap * SpaceCadet::map_;
uint16_t SpaceCadet::time_out = 1000; uint16_t SpaceCadet::time_out = 1000;
//Empty constructor //Empty constructor
SpaceCadet::SpaceCadet() { SpaceCadet::SpaceCadet() {
//By default, we make one with left shift sending left paren, and right shift sending right paren //By default, we make one with left shift sending left paren, and right shift sending right paren
static ModifierKeyMap internalMap[] = { static ModifierKeyMap internalMap[] = {
//By default, respect the default timeout //By default, respect the default timeout
{Key_LeftShift, Key_LeftParen, 0} {Key_LeftShift, Key_LeftParen, 0}
,{Key_RightShift, Key_RightParen, 0} , {Key_RightShift, Key_RightParen, 0}
//These may be uncommented, added, or set in the main sketch //These may be uncommented, added, or set in the main sketch
/*,{Key_LeftGui,Key_LeftCurlyBracket,250} /*,{Key_LeftGui,Key_LeftCurlyBracket,250}
,{Key_RightAlt,Key_RightCurlyBracket,250} ,{Key_RightAlt,Key_RightCurlyBracket,250}
@ -59,22 +59,22 @@ namespace kaleidoscope {
//Set the variables to our internal map //Set the variables to our internal map
map_ = internalMap; map_ = internalMap;
map_size_ = sizeof(internalMap)/sizeof(internalMap[0]); map_size_ = sizeof(internalMap) / sizeof(internalMap[0]);
} }
//Void function to reset the modifier map if desired. //Void function to reset the modifier map if desired.
void SpaceCadet::setMap(ModifierKeyMap * map, uint8_t map_size){ void SpaceCadet::setMap(ModifierKeyMap * map, uint8_t map_size) {
//Set the map //Set the map
map_ = map; map_ = map;
//set the map size to be the length of the array //set the map size to be the length of the array
map_size_ = map_size; map_size_ = map_size;
} }
void SpaceCadet::begin() { void SpaceCadet::begin() {
Kaleidoscope.useEventHandlerHook(eventHandlerHook); Kaleidoscope.useEventHandlerHook(eventHandlerHook);
} }
Key SpaceCadet::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state) { Key SpaceCadet::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state) {
// If nothing happened, bail out fast. // If nothing happened, bail out fast.
if (!keyIsPressed(key_state) && !keyWasPressed(key_state)) { if (!keyIsPressed(key_state) && !keyWasPressed(key_state)) {
@ -84,11 +84,11 @@ namespace kaleidoscope {
// If a key has been just toggled on... // If a key has been just toggled on...
if (keyToggledOn(key_state)) { if (keyToggledOn(key_state)) {
if(map_size_ > 0) { if (map_size_ > 0) {
//This will only set one key, and if it isn't in our map it clears everything //This will only set one key, and if it isn't in our map it clears everything
//for the non-pressed key //for the non-pressed key
for (uint8_t i = 0; i < map_size_; ++i) { for (uint8_t i = 0; i < map_size_; ++i) {
if(mapped_key.raw == map_[i].input.raw) { if (mapped_key.raw == map_[i].input.raw) {
//The keypress was valid and a match. //The keypress was valid and a match.
map_[i].flagged = true; map_[i].flagged = true;
map_[i].start_time = millis(); map_[i].start_time = millis();
@ -110,7 +110,7 @@ namespace kaleidoscope {
bool pressed_key_was_valid = false; bool pressed_key_was_valid = false;
uint8_t index = 0; uint8_t index = 0;
if(map_size_ > 0) { if (map_size_ > 0) {
//Look to see if any keys in our map are flagged //Look to see if any keys in our map are flagged
for (uint8_t i = 0; i < map_size_; ++i) { for (uint8_t i = 0; i < map_size_; ++i) {
@ -132,7 +132,7 @@ namespace kaleidoscope {
//use the map index to find the local timeout for this key //use the map index to find the local timeout for this key
uint16_t current_timeout = map_[index].timeout; uint16_t current_timeout = map_[index].timeout;
//If that isn't set, use the global timeout setting. //If that isn't set, use the global timeout setting.
if(current_timeout == 0){ if (current_timeout == 0) {
current_timeout = time_out; current_timeout = time_out;
} }
@ -172,7 +172,7 @@ namespace kaleidoscope {
} }
return mapped_key; return mapped_key;
} }
} }

@ -21,8 +21,8 @@
#include <Kaleidoscope.h> #include <Kaleidoscope.h>
namespace kaleidoscope { namespace kaleidoscope {
//Declarations for the modifier key mapping //Declarations for the modifier key mapping
class ModifierKeyMap { class ModifierKeyMap {
public: public:
//Empty constructor; set the vars separately //Empty constructor; set the vars separately
ModifierKeyMap(void); ModifierKeyMap(void);
@ -40,10 +40,10 @@ namespace kaleidoscope {
bool flagged = false; bool flagged = false;
//the start time for this key press //the start time for this key press
uint32_t start_time = 0; uint32_t start_time = 0;
}; };
//Declaration for the method (implementing KaleidoscopePlugin) //Declaration for the method (implementing KaleidoscopePlugin)
class SpaceCadet : public KaleidoscopePlugin { class SpaceCadet : public KaleidoscopePlugin {
public: public:
//Empty constructor //Empty constructor
SpaceCadet(void); SpaceCadet(void);
@ -58,7 +58,7 @@ namespace kaleidoscope {
static uint8_t map_size_; static uint8_t map_size_;
static ModifierKeyMap * map_; static ModifierKeyMap * map_;
static Key eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state); static Key eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state);
}; };
}; };
extern kaleidoscope::SpaceCadet SpaceCadet; extern kaleidoscope::SpaceCadet SpaceCadet;

Loading…
Cancel
Save