|
|
|
@ -21,35 +21,35 @@
|
|
|
|
|
|
|
|
|
|
namespace kaleidoscope {
|
|
|
|
|
|
|
|
|
|
//Default, empty constructor
|
|
|
|
|
ModifierKeyMap::ModifierKeyMap(){
|
|
|
|
|
}
|
|
|
|
|
//Default, empty constructor
|
|
|
|
|
ModifierKeyMap::ModifierKeyMap() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Constructor with input and output, and assume default timeout
|
|
|
|
|
ModifierKeyMap::ModifierKeyMap(Key input_, Key output_){
|
|
|
|
|
//Constructor with input and output, and assume default timeout
|
|
|
|
|
ModifierKeyMap::ModifierKeyMap(Key input_, Key output_) {
|
|
|
|
|
input = input_;
|
|
|
|
|
output = output_;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Constructor with all three set
|
|
|
|
|
ModifierKeyMap::ModifierKeyMap(Key input_, Key output_, uint16_t timeout_) {
|
|
|
|
|
//Constructor with all three set
|
|
|
|
|
ModifierKeyMap::ModifierKeyMap(Key input_, Key output_, uint16_t timeout_) {
|
|
|
|
|
input = input_;
|
|
|
|
|
output = output_;
|
|
|
|
|
timeout = timeout_;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Space Cadet
|
|
|
|
|
uint8_t SpaceCadet::map_size_ = 0;
|
|
|
|
|
ModifierKeyMap * SpaceCadet::map_;
|
|
|
|
|
uint16_t SpaceCadet::time_out = 1000;
|
|
|
|
|
//Space Cadet
|
|
|
|
|
uint8_t SpaceCadet::map_size_ = 0;
|
|
|
|
|
ModifierKeyMap * SpaceCadet::map_;
|
|
|
|
|
uint16_t SpaceCadet::time_out = 1000;
|
|
|
|
|
|
|
|
|
|
//Empty constructor
|
|
|
|
|
SpaceCadet::SpaceCadet() {
|
|
|
|
|
//Empty constructor
|
|
|
|
|
SpaceCadet::SpaceCadet() {
|
|
|
|
|
//By default, we make one with left shift sending left paren, and right shift sending right paren
|
|
|
|
|
static ModifierKeyMap internalMap[] = {
|
|
|
|
|
//By default, respect the default timeout
|
|
|
|
|
{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
|
|
|
|
|
/*,{Key_LeftGui,Key_LeftCurlyBracket,250}
|
|
|
|
|
,{Key_RightAlt,Key_RightCurlyBracket,250}
|
|
|
|
@ -59,22 +59,22 @@ namespace kaleidoscope {
|
|
|
|
|
|
|
|
|
|
//Set the variables to our internal map
|
|
|
|
|
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 SpaceCadet::setMap(ModifierKeyMap * map, uint8_t map_size){
|
|
|
|
|
//Void function to reset the modifier map if desired.
|
|
|
|
|
void SpaceCadet::setMap(ModifierKeyMap * map, uint8_t map_size) {
|
|
|
|
|
//Set the map
|
|
|
|
|
map_ = map;
|
|
|
|
|
//set the map size to be the length of the array
|
|
|
|
|
map_size_ = map_size;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpaceCadet::begin() {
|
|
|
|
|
void SpaceCadet::begin() {
|
|
|
|
|
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 (!keyIsPressed(key_state) && !keyWasPressed(key_state)) {
|
|
|
|
@ -84,11 +84,11 @@ namespace kaleidoscope {
|
|
|
|
|
// If a key has been just toggled on...
|
|
|
|
|
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
|
|
|
|
|
//for the non-pressed key
|
|
|
|
|
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.
|
|
|
|
|
map_[i].flagged = true;
|
|
|
|
|
map_[i].start_time = millis();
|
|
|
|
@ -110,7 +110,7 @@ namespace kaleidoscope {
|
|
|
|
|
bool pressed_key_was_valid = false;
|
|
|
|
|
uint8_t index = 0;
|
|
|
|
|
|
|
|
|
|
if(map_size_ > 0) {
|
|
|
|
|
if (map_size_ > 0) {
|
|
|
|
|
//Look to see if any keys in our map are flagged
|
|
|
|
|
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
|
|
|
|
|
uint16_t current_timeout = map_[index].timeout;
|
|
|
|
|
//If that isn't set, use the global timeout setting.
|
|
|
|
|
if(current_timeout == 0){
|
|
|
|
|
if (current_timeout == 0) {
|
|
|
|
|
current_timeout = time_out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -172,7 +172,7 @@ namespace kaleidoscope {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return mapped_key;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|