Fixed lots of compilation errors

pull/389/head
Michael Richters 7 years ago
parent 5bfe5c07eb
commit 721baeca78

@ -23,19 +23,26 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
___), ___),
}; };
// Define the Qukeys map // Define the Qukeys map
QUKEYS( // QUKEYS(
Qukey(QWERTY, 2, 1, Key_LeftShift), // Qukey(0, 2, 1, Key_LeftShift),
Qukey(QWERTY, 2, 2, Key_LeftControl), // Qukey(0, 2, 2, Key_LeftControl),
Qukey(QWERTY, 2, 3, Key_LeftAlt), // Qukey(0, 2, 3, Key_LeftAlt),
Qukey(QWERTY, 2, 4, Key_LeftGui) // Qukey(0, 2, 4, Key_LeftGui)
) // )
void setup() { void setup() {
// Use Qukeys // Use Qukeys
Kaleidoscope.use(&Qukeys); Kaleidoscope.use(&Qukeys);
Qukeys.init(qukey_list, qukey_count); //kaleidoscope::Qukeys.init(qukeys, count);
kaleidoscope::Qukey qukeys[] = {
kaleidoscope::Qukey(0, 2, 1, Key_LeftShift),
kaleidoscope::Qukey(0, 2, 2, Key_LeftControl)
};
uint8_t count = sizeof(qukeys) / sizeof(kaleidoscope::Qukey);
Qukeys.qukeys_ = qukeys;
Qukeys.qukeys_count_ = count;
Kaleidoscope.setup(); Kaleidoscope.setup();
} }

@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <Kaleidoscope.h>
#include <Kaleidoscope-Qukeys.h> #include <Kaleidoscope-Qukeys.h>
#include <kaleidoscope/hid.h> #include <kaleidoscope/hid.h>
@ -35,17 +36,25 @@ Qukey::Qukey(int8_t layer, byte row, byte col, Key alt_keycode) {
this->state = QUKEY_STATE_UNDETERMINED; this->state = QUKEY_STATE_UNDETERMINED;
} }
Qukeys::Qukeys() {} Qukey * Qukeys::qukeys_;
uint8_t Qukeys::qukeys_count_ = 0;
bool Qukeys::active_ = true;
uint16_t Qukeys::time_limit_ = 200;
QueueItem Qukeys::key_queue_[QUKEYS_QUEUE_MAX] = {};
uint8_t Qukeys::key_queue_length_ = 0;
Qukeys::init(Qukey *qukeys, uint8_t qukeys_count) { // Empty constructor; nothing is stored at the instance level
qukeys_ = qukeys; Qukeys::Qukeys(void) {}
qukeys_count_ = qukeys_count;
} // Qukeys::init(Qukey *qukeys, uint8_t qukeys_count) {
// qukeys_ = qukeys;
// qukeys_count_ = qukeys_count;
// }
int8_t Qukeys::lookupQukey(uint8_t key_addr) { int8_t Qukeys::lookupQukey(uint8_t key_addr) {
if (key_addr == QUKEY_UNKNOWN_ADDR) if (key_addr == QUKEY_UNKNOWN_ADDR)
return QUKEY_NOT_FOUND; return QUKEY_NOT_FOUND;
for (int8_t i; i < qukeys_count_; i++) { for (int8_t i = 0; i < qukeys_count_; i++) {
Qukey qukey = qukeys_[i]; Qukey qukey = qukeys_[i];
if (qukey.addr == key_addr) { if (qukey.addr == key_addr) {
byte row = addr::row(key_addr); byte row = addr::row(key_addr);
@ -78,12 +87,12 @@ int8_t Qukeys::searchQueue(uint8_t key_addr) {
// flush a single entry from the head of the queue // flush a single entry from the head of the queue
void Qukeys::flushKey(int8_t state) { void Qukeys::flushKey(int8_t state) {
int8_t qukey_index = Qukeys.lookupQukey(key_addr); int8_t qukey_index = lookupQukey(key_queue_[0].addr);
if (qukey_index != QUKEY_NOT_FOUND) { if (qukey_index != QUKEY_NOT_FOUND) {
qukeys_[qukey_index].state = state; qukeys_[qukey_index].state = state;
} }
byte row = addr::row(key_queue[0].addr); byte row = addr::row(key_queue_[0].addr);
byte col = addr::col(key_queue[0].addr); byte col = addr::col(key_queue_[0].addr);
Key keycode = Key_NoKey; Key keycode = Key_NoKey;
if (state == QUKEY_STATE_ALTERNATE && qukey_index != QUKEY_NOT_FOUND) { if (state == QUKEY_STATE_ALTERNATE && qukey_index != QUKEY_NOT_FOUND) {
keycode = qukeys_[qukey_index].alt_keycode; keycode = qukeys_[qukey_index].alt_keycode;
@ -100,7 +109,7 @@ void Qukeys::flushKey(int8_t state) {
// we can ignore it and don't start an infinite loop. It would be // we can ignore it and don't start an infinite loop. It would be
// nice if we could use key_state to also indicate which plugin // nice if we could use key_state to also indicate which plugin
// injected the key. // injected the key.
handleKeySwitchEvent(keycode, row, col, IS_PRESSED | INJECTED); handleKeyswitchEvent(keycode, row, col, IS_PRESSED | INJECTED);
// Now we send the report (if there were any changes) // Now we send the report (if there were any changes)
hid::sendKeyboardReport(); hid::sendKeyboardReport();
@ -122,7 +131,7 @@ void Qukeys::flushQueue(int8_t state, int8_t index) {
Key Qukeys::keyScanHook(Key mapped_key, byte row, byte col, uint8_t key_state) { Key Qukeys::keyScanHook(Key mapped_key, byte row, byte col, uint8_t key_state) {
// If Qukeys is turned off, continue to next plugin // If Qukeys is turned off, continue to next plugin
if (!active) if (!active_)
return mapped_key; return mapped_key;
// If the key was injected (from the queue being flushed), continue to next plugin // If the key was injected (from the queue being flushed), continue to next plugin
@ -135,12 +144,12 @@ Key Qukeys::keyScanHook(Key mapped_key, byte row, byte col, uint8_t key_state) {
// get key addr & qukey (if any) // get key addr & qukey (if any)
uint8_t key_addr = addr::addr(row, col); uint8_t key_addr = addr::addr(row, col);
int8_t qukey_index = Qukeys.lookupQukey(key_addr); int8_t qukey_index = lookupQukey(key_addr);
// If the key was just pressed: // If the key was just pressed:
if (keyToggledOn(key_state)) { if (keyToggledOn(key_state)) {
// I think I may need to call maskKey() somewhere here, but I'm not sure // I think I may need to call maskKey() somewhere here, but I'm not sure
if (key_queue_length) { if (key_queue_length_) {
enqueue(key_addr); enqueue(key_addr);
} else { } else {
if (qukey_index == QUKEY_NOT_FOUND) if (qukey_index == QUKEY_NOT_FOUND)
@ -183,7 +192,7 @@ Key Qukeys::keyScanHook(Key mapped_key, byte row, byte col, uint8_t key_state) {
return Key_NoKey; return Key_NoKey;
} }
void preReportHook(void) { void Qukeys::preReportHook(void) {
// If the qukey has been held longer than the time limit, set its // If the qukey has been held longer than the time limit, set its
// state to the alternate keycode and add it to the report // state to the alternate keycode and add it to the report
uint32_t current_time = millis(); uint32_t current_time = millis();
@ -196,7 +205,7 @@ void preReportHook(void) {
} }
} }
void loopHook(bool post_clear) { void Qukeys::loopHook(bool post_clear) {
if (!post_clear) if (!post_clear)
return preReportHook(); return preReportHook();
} }

@ -72,22 +72,27 @@ class Qukeys : public KaleidoscopePlugin {
public: public:
Qukeys(void); Qukeys(void);
static void begin(void) final; //static void init(Qukey *qukeys, uint8_t qukeys_count);
void begin(void) final;
static void activate(void) { static void activate(void) {
active = true; active_ = true;
} }
static void deactivate(void) { static void deactivate(void) {
active = false; active_ = false;
} }
static int8_t lookupQukey(uint8_t key_addr); static int8_t lookupQukey(uint8_t key_addr);
static void enqueue(uint8_t key_addr);
static int8_t searchQueue(uint8_t key_addr);
static void flushKey(int8_t state);
static void flushQueue(int8_t state, int8_t index);
private:
static Qukey * qukeys_; static Qukey * qukeys_;
static uint8_t qukeys_count_; static uint8_t qukeys_count_;
private:
static bool active_; static bool active_;
static uint16_t time_limit_; static uint16_t time_limit_;
static queue_item_t key_queue_[QUKEYS_QUEUE_MAX]; static QueueItem key_queue_[QUKEYS_QUEUE_MAX];
static uint8_t key_queue_length_; static uint8_t key_queue_length_;
static Key keyScanHook(Key mapped_key, byte row, byte col, uint8_t key_state); static Key keyScanHook(Key mapped_key, byte row, byte col, uint8_t key_state);
@ -102,6 +107,8 @@ extern kaleidoscope::Qukeys Qukeys;
// macro for use in sketch file to simplify definition of qukeys // macro for use in sketch file to simplify definition of qukeys
#define QUKEYS(qukey_defs...) \ #define QUKEYS(qukey_defs...) \
static kaleidoscope::Qukey qukeys[] = { qukey_defs... }; \ namespace kaleidoscope { \
uint8_t qukeys_count = sizeof(qukeys) / sizeof(kaleidoscope::Qukey); \ Qukey qukeys[] = { qukey_defs... }; \
Qukeys.init(qukeys, qukeys_count); uint8_t qukeys_count = sizeof(qukeys) / sizeof(Qukey); \
Qukeys.init(qukeys, qukeys_count); \
}

Loading…
Cancel
Save