Updated sources to use newer method and remove map_size variable requirement

pull/389/head
Ben Gemperline 7 years ago
parent 90c1f7cc13
commit 1a73d22da7

@ -21,7 +21,6 @@
namespace kaleidoscope { namespace kaleidoscope {
//Constructor with input and output, and assume default timeout //Constructor with input and output, and assume default timeout
SpaceCadet::KeyBinding::KeyBinding(Key input_, Key output_) { SpaceCadet::KeyBinding::KeyBinding(Key input_, Key output_) {
input = input_; input = input_;
@ -36,19 +35,26 @@ SpaceCadet::KeyBinding::KeyBinding(Key input_, Key output_, uint16_t timeout_) {
} }
//Space Cadet //Space Cadet
KeyBinding * SpaceCadet::map = { SpaceCadet::KeyBinding * SpaceCadet::map;
//By default, respect the default timeout
{Key_LeftShift, Key_LeftParen, 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}
,{Key_LeftControl,Key_LeftBracket, 250}
,{Key_RightControl,Key_RightBracket, 250}*/
, SPACECADET_MAP_END
};
uint16_t SpaceCadet::time_out = 1000; uint16_t SpaceCadet::time_out = 1000;
//Empty Constructor
SpaceCadet::SpaceCadet() {
SpaceCadet::KeyBinding initialmap[] = {
//By default, respect the default timeout
{Key_LeftShift, Key_LeftParen, 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}
,{Key_LeftControl,Key_LeftBracket, 250}
,{Key_RightControl,Key_RightBracket, 250}*/
, SPACECADET_MAP_END
};
map = initialmap;
}
void SpaceCadet::begin() { void SpaceCadet::begin() {
Kaleidoscope.useEventHandlerHook(eventHandlerHook); Kaleidoscope.useEventHandlerHook(eventHandlerHook);
} }

@ -21,24 +21,15 @@
#include <Kaleidoscope.h> #include <Kaleidoscope.h>
#ifndef SPACECADET_MAP_END #ifndef SPACECADET_MAP_END
#define SPACECADET_MAP_END {Key_NoKey, Key_NoKey, 0} #define SPACECADET_MAP_END (kaleidoscope::SpaceCadet::KeyBinding) { Key_NoKey, Key_NoKey, 0 }
#endif #endif
namespace kaleidoscope { namespace kaleidoscope {
//Declaration for the method (implementing KaleidoscopePlugin) //Declaration for the method (implementing KaleidoscopePlugin)
class SpaceCadet : public KaleidoscopePlugin { class SpaceCadet : public KaleidoscopePlugin {
public: public:
//Empty constructor //Internal Class
SpaceCadet(void) {} //Declarations for the modifier key mapping
//Methods
void begin(void) final;
//Publically accessible variables
static uint16_t time_out; // The global timeout in milliseconds
static KeyBinding * map; // The map of key bindings
//Declarations for the modifier key mapping
class KeyBinding { class KeyBinding {
public: public:
//Empty constructor; set the vars separately //Empty constructor; set the vars separately
@ -58,6 +49,17 @@ class SpaceCadet : public KaleidoscopePlugin {
//the start time for this key press //the start time for this key press
uint32_t start_time = 0; uint32_t start_time = 0;
}; };
//Empty constructor
SpaceCadet(void);
//Methods
void begin(void) final;
//Publically accessible variables
static uint16_t time_out; // The global timeout in milliseconds
static SpaceCadet::KeyBinding * map; // The map of key bindings
private: private:
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);
}; };

Loading…
Cancel
Save