From 980a41e9049aad53c49b667066a3c5e5cabda113 Mon Sep 17 00:00:00 2001 From: Jeremy Bernhardt Date: Thu, 14 Mar 2019 14:59:34 -0600 Subject: [Keyboard] Georgi Support (#5384) * Working on chording * Working on chording * Got layouts in order * Initial Georgi support * forgot to add keymaps * Updated readme * Update keyboards/georgi/keymaps/template/readme.md Co-Authored-By: germ * Update keyboards/georgi/georgi.h Co-Authored-By: germ * Update keyboards/georgi/keymaps/default/keymap.c Co-Authored-By: germ * Update keyboards/georgi/keymaps/default/keymap.c Co-Authored-By: germ * Update keyboards/georgi/rules.mk Co-Authored-By: germ * Update keyboards/georgi/rules.mk Co-Authored-By: germ * Update keyboards/georgi/matrix.c Co-Authored-By: germ * Update keyboards/georgi/georgi.c Co-Authored-By: germ * Update keyboards/georgi/georgi.c Co-Authored-By: germ * Update keyboards/georgi/rules.mk Co-Authored-By: germ * Update keyboards/georgi/keymaps/default/keymap.c Co-Authored-By: germ * Update keyboards/georgi/keymaps/template/keymap.c Co-Authored-By: germ * Update keyboards/georgi/matrix.c Co-Authored-By: germ * Disabled features, updated info * Update keyboards/georgi/config.h Co-Authored-By: germ * Update keyboards/georgi/config.h Co-Authored-By: germ * Fixed info.json --- keyboards/georgi/sten.h | 290 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 290 insertions(+) create mode 100644 keyboards/georgi/sten.h (limited to 'keyboards/georgi/sten.h') diff --git a/keyboards/georgi/sten.h b/keyboards/georgi/sten.h new file mode 100644 index 0000000000..fee05deca3 --- /dev/null +++ b/keyboards/georgi/sten.h @@ -0,0 +1,290 @@ +// 2019, g Heavy Industries + +#include QMK_KEYBOARD_H +#include "mousekey.h" +#include "keymap.h" +#include "keymap_steno.h" + +// Bitfield representing the current chord +uint32_t cChord = 0; + +// See if a given chord is pressed. +// P will return +// PJ will continue processing, removing the found chord +#define P(chord, act) if (cChord == (chord)) { act; return true; } +#define PJ(chord, act) if ((cChord & (chord)) == (chord)) { cChord ^= chord; act; } + +// All Steno Codes +// Shift to internal representation +#define STN(n) (1L< 1) { + uprintf("Switching to QMK\n"); + layer_on(1); + goto out; + } + + // Lone FN press, toggle QWERTY + if (cChord == FN) { + (cMode == STENO) ? (cMode = QWERTY) : (cMode = STENO); + goto out; + } + + // Check for Plover momentary + if (cMode == QWERTY && (cChord & FN)) { + cChord ^= FN; + goto steno; + } + + // Do QWERTY and Momentary QWERTY + if (cMode == QWERTY || (cMode == COMMAND) || (cChord & (FN | PWR))) { + if (cChord & FN) cChord ^= FN; + processQwerty(); + goto out; + } + + // Fallback NKRO Steno + if (cMode == STENO && QWERSTENO) { + processFakeSteno(); + goto out; + } + +steno: + // Hey that's a steno chord! + inChord = false; + cChord = 0; + return true; + +out: + inChord = false; + clear_keyboard(); + cChord = 0; + return false; +} + +// Update Chord State +bool process_steno_user(uint16_t keycode, keyrecord_t *record) { + // Everything happens in here when steno keys come in. + // Bail on keyup + if (!record->event.pressed) return true; + + // Update key repeat timers + repTimer = timer_read(); + inChord = true; + + // Switch on the press adding to chord + bool pr = record->event.pressed; + switch (keycode) { + // Mods and stuff + case STN_ST1: pr ? (cChord |= (ST1)): (cChord &= ~(ST1)); break; + case STN_ST2: pr ? (cChord |= (ST2)): (cChord &= ~(ST2)); break; + case STN_ST3: pr ? (cChord |= (ST3)): (cChord &= ~(ST3)); break; + case STN_ST4: pr ? (cChord |= (ST4)): (cChord &= ~(ST4)); break; + case STN_FN: pr ? (cChord |= (FN)) : (cChord &= ~(FN)); break; + case STN_PWR: pr ? (cChord |= (PWR)): (cChord &= ~(PWR)); break; + case STN_N1...STN_N6: + case STN_N7...STN_NC: pr ? (cChord |= (NUM)): (cChord &= ~(NUM)); break; + + // All the letter keys + case STN_S1: pr ? (cChord |= (LSU)) : (cChord &= ~(LSU)); break; + case STN_S2: pr ? (cChord |= (LSD)) : (cChord &= ~(LSD)); break; + case STN_TL: pr ? (cChord |= (LFT)) : (cChord &= ~(LFT)); break; + case STN_KL: pr ? (cChord |= (LK)) : (cChord &= ~(LK)); break; + case STN_PL: pr ? (cChord |= (LP)) : (cChord &= ~(LP)); break; + case STN_WL: pr ? (cChord |= (LW)) : (cChord &= ~(LW)); break; + case STN_HL: pr ? (cChord |= (LH)) : (cChord &= ~(LH)); break; + case STN_RL: pr ? (cChord |= (LR)) : (cChord &= ~(LR)); break; + case STN_A: pr ? (cChord |= (LA)) : (cChord &= ~(LA)); break; + case STN_O: pr ? (cChord |= (LO)) : (cChord &= ~(LO)); break; + case STN_E: pr ? (cChord |= (RE)) : (cChord &= ~(RE)); break; + case STN_U: pr ? (cChord |= (RU)) : (cChord &= ~(RU)); break; + case STN_FR: pr ? (cChord |= (RF)) : (cChord &= ~(RF)); break; + case STN_RR: pr ? (cChord |= (RR)) : (cChord &= ~(RR)); break; + case STN_PR: pr ? (cChord |= (RP)) : (cChord &= ~(RP)); break; + case STN_BR: pr ? (cChord |= (RB)) : (cChord &= ~(RB)); break; + case STN_LR: pr ? (cChord |= (RL)) : (cChord &= ~(RL)); break; + case STN_GR: pr ? (cChord |= (RG)) : (cChord &= ~(RG)); break; + case STN_TR: pr ? (cChord |= (RT)) : (cChord &= ~(RT)); break; + case STN_SR: pr ? (cChord |= (RS)) : (cChord &= ~(RS)); break; + case STN_DR: pr ? (cChord |= (RD)) : (cChord &= ~(RD)); break; + case STN_ZR: pr ? (cChord |= (RZ)) : (cChord &= ~(RZ)); break; + } + + // Check for key repeat in QWERTY mode + return true; +} +void matrix_scan_user(void) { + // We abuse this for early sending of key + // Key repeat only on QWER/SYMB layers + if (cMode != QWERTY) return; + + // Check timers + if (timer_elapsed(repTimer) > REP_DELAY) { + // Process Key for report + processQwerty(); + + // Send report to host + send_keyboard_report(); + repTimer = timer_read(); + } +}; + +// Helpers +bool processFakeSteno(void) { + PJ( LSU, SEND(KC_Q);); + PJ( LSD, SEND(KC_A);); + PJ( LFT, SEND(KC_W);); + PJ( LP, SEND(KC_E);); + PJ( LH, SEND(KC_R);); + PJ( LK, SEND(KC_S);); + PJ( LW, SEND(KC_D);); + PJ( LR, SEND(KC_F);); + PJ( ST1, SEND(KC_T);); + PJ( ST2, SEND(KC_G);); + PJ( LA, SEND(KC_C);); + PJ( LO, SEND(KC_V);); + PJ( RE, SEND(KC_N);); + PJ( RU, SEND(KC_M);); + PJ( ST3, SEND(KC_Y);); + PJ( ST4, SEND(KC_H);); + PJ( RF, SEND(KC_U);); + PJ( RP, SEND(KC_I);); + PJ( RL, SEND(KC_O);); + PJ( RT, SEND(KC_P);); + PJ( RD, SEND(KC_LBRC);); + PJ( RR, SEND(KC_J);); + PJ( RB, SEND(KC_K);); + PJ( RG, SEND(KC_L);); + PJ( RS, SEND(KC_SCLN);); + PJ( RZ, SEND(KC_COMM);); + PJ( NUM, SEND(KC_1);); + + return false; +} +void clickMouse(uint8_t kc) { +#ifdef MOUSEKEY_ENABLE + mousekey_on(kc); + mousekey_send(); + + // Store state for later use + inMouse = true; + mousePress = kc; +#endif +} +void SEND(uint8_t kc) { + // Send Keycode, Does not work for Quantum Codes + if (cMode == COMMAND && CMDLEN < MAX_CMD_BUF) { + uprintf("CMD LEN: %d BUF: %d\n", CMDLEN, MAX_CMD_BUF); + CMDBUF[CMDLEN] = kc; + CMDLEN++; + } + + if (cMode != COMMAND) register_code(kc); + return; +} -- cgit v1.2.3