From 383a3c1e08d0f4e00b1c6f07e8468c5eac544eb4 Mon Sep 17 00:00:00 2001 From: Daniel Gordon Date: Mon, 18 Dec 2017 16:01:59 -0600 Subject: [PATCH] Add Daniel Gordon's Ergodox Infinity and Chimera * gordon.c defines many aliases for KC codes. * gordon.c defines many advanced tap dance functions. * This is a squashed commit of about 6 months of work on chimera and ergodox infinity changes. * Ignore the change-id below. Change-Id: I83927139e8a80fe08992ae91ec7d62571498f7f7 --- .../chimera_ortho/keymaps/gordon/keymap.c | 389 ++++++++++++++++++ .../ergodox_infinity/keymaps/gordon/keymap.c | 315 ++++++++++++++ users/gordon/gordon.c | 275 +++++++++++++ users/gordon/gordon.h | 157 +++++++ users/gordon/readme.md | 14 + users/gordon/rules.mk | 1 + 6 files changed, 1151 insertions(+) create mode 100644 keyboards/chimera_ortho/keymaps/gordon/keymap.c create mode 100644 keyboards/ergodox_infinity/keymaps/gordon/keymap.c create mode 100644 users/gordon/gordon.c create mode 100644 users/gordon/gordon.h create mode 100644 users/gordon/readme.md create mode 100644 users/gordon/rules.mk diff --git a/keyboards/chimera_ortho/keymaps/gordon/keymap.c b/keyboards/chimera_ortho/keymaps/gordon/keymap.c new file mode 100644 index 00000000..721f8207 --- /dev/null +++ b/keyboards/chimera_ortho/keymaps/gordon/keymap.c @@ -0,0 +1,389 @@ +// this is the style you want to emulate. +// This is the canonical layout file for the Quantum project. If you want to add another keyboard, + +#include "chimera_ortho.h" +#include "action_layer.h" +#include "version.h" +#include "process_keycode/process_tap_dance.h" +#include "gordon.h" + +// Each layer gets a name for readability, which is then used in the keymap matrix below. +// The underscores don't mean anything - you can have a layer called STUFF or any other name. +// Layer names don't all need to be of the same length, obviously, and you can also skip them +// entirely and just use numbers. + +#define CALTDEL LCTL(LALT(KC_DEL)) +#define TSKMGR LCTL(LSFT(KC_ESC)) + +#define KC_SNAPLEFT LGUI(KC_LEFT) +#define KC_SNAPRIGHT LGUI(KC_RIGHT) +#define KC_SNAPUP LGUI(KC_UP) +#define KC_SNAPDOWN LGUI(KC_DOWN) +#define KC_PREVTAB LCTL(LSFT(KC_TAB)) +#define KC_NEXTTAB LCTL(KC_TAB) +#define KC_WORKRIGHT LCTL(LGUI(KC_RIGHT)) +#define KC_WORKLEFT LCTL(LGUI(KC_LEFT)) + +#define KC_NMPD TG(_NUMPAD) +#define KC_SYMB TG(_SYMBOLS) + +#define KC_SCTL MT(MOD_LCTL, KC_LBRC) +#define KC_SCTR MT(MOD_LCTL, KC_RBRC) +#define KC_SPLT MT(MOD_LALT, KC_MINS) +#define KC_SPRT MT(MOD_LALT, KC_1) +#define KC_GBRC MT(MOD_RGUI, KC_8) +#define KC_GQOT MT(MOD_LGUI, KC_QUOT) +#define KC_CSHW MT(MOD_LCTL|MOD_LSFT,KC_W) + +#define KC_CDEL LCTL(KC_DEL) +#define KC_AUDUP KC_AUDIO_VOL_UP +#define KC_AUDOWN KC_AUDIO_VOL_DOWN + + +#define KC_MEHS MEH_T(KC_S) +#define KC_MEHL MEH_T(KC_L) +#define KC_GWIN GUI_T(KC_G) +#define KC_FCTL CTL_T(KC_F) +#define KC_JCTL CTL_T(KC_J) +#define KC_ZCTL CTL_T(KC_Z) +#define KC_ALTV ALT_T(KC_V) +#define KC_ALTN ALT_T(KC_N) +#define KC_MEHX ALL_T(KC_X) +#define KC_RESET RESET + +//LTs +#define KC_MESC LT(_MACROS, KC_ESC) +#define KC_DNUM LT(_NUMPAD, KC_D) +#define KC_SPFN LT(_NAV,KC_EQL) +#define KC_EMAUS LT(_MOUSE,KC_E) +#define KC_ENAV LT(_NAV,KC_E) +#define KC_INAV LT(_TEXTNAV,KC_I) +#define KC_BSPSYM LT(_SYMBOLS,KC_BSPACE) +#define KC_ENTSYM LT(_SYMBOLS,KC_ENTER) +#define KC_CLNMAUS LT(_MOUSE,KC_SCOLON) + +#define KC_FUNC TT(_FUNCTION) + +//TAP DANCE +#define KC_F6F7 TD(F6F7) +#define KC_ALF4 TD(ALTF4) +#define KC_TTT TD(TTT) +#define KC_ENHM TD(HOME_END) +#define KC_CLPS TD(CALC_PRINTSCREEN) + + +#define KC_INCL M(0) +#define KC_PULL M(1) +#define KC_PUSH M(2) +#define KC_SCAP M(3) +#define KC_SCOF M(4) +#define KC_CAD LALT(LCTL(KC_DEL)) + +#define LONGPRESS_DELAY 150 +//#define LAYER_TOGGLE_DELAY 300 + +// Fillers to make layering more clear +#define _______ KC_TRNS +#define XXXXXXX KC_NO +#define KC_ KC_TRNS + +/* TODO: + * + * DONE: RESET and CAD into macro layer. + * DONE: WINUP AND WINDOWN in NAV layer + * DONE: Get rid of caps layer. not sure what it is even for. + * DONE: LMEH + * DONE: plus, divide, multiply on left hand for num layer + * DONE: F1 - F12 on a layer toggle (not a temp toggle but a one shot or something) + * DONE: Volume, page up and down for mouse layer. + * DONE: Add full user files - without using anything. + * DONE: Insert, ctrl delete + * DONE: Home and End + * DONE: Printscreen + + * Easier way to open new terminal (instead of alt + F2) + * Intellij/text navigation layer (ctrl delete could be here). + * Macro for "System.exit(0)" probably macro layer and "c" + * Some sort of tap dance for comma, H, right pinky, and possibly other corners. + * Something more with the right hand. not sure what. + * Mouse: Left scroll, right scroll + * Passwords and any other macros. + * LED for control + * All modifiers reset + * Russain layer + * Hebrew layer + * Get rid of stupid git pull and push macros. + * +*/ + +//Tap dance enums +enum { + F12ETAPS = 0, + CALCCOMP, + ALTF4, + F6F7, + TTT, + HOME_END, + CALC_PRINTSCREEN +}; + +static xtap ttt_state = { + .is_press_action = true, + .state = 0 +}; + + +//Already exists in gordon.c, shouldn't need this anymore +/*// To activate SINGLE_HOLD, you will need to hold for 200ms first. +// This tap dance favors keys that are used frequently in typing like 'f' +int cur_dance (qk_tap_dance_state_t *state) { + if (state->count == 1) { + if (state->interrupted) { + return SINGLE_TAP; + } + else { + if (!state->pressed) return SINGLE_TAP; + else return SINGLE_HOLD; + } + } + //If count = 2, and it has been interrupted - assume that user is trying to type the letter associated + //with single tap. + else if (state->count == 2) { + if (state->interrupted) return DOUBLE_SINGLE_TAP; + else if (state->pressed) return DOUBLE_HOLD; + else return DOUBLE_TAP; + } + else if ((state->count == 3) && ((state->interrupted) || (!state->pressed))) return TRIPLE_TAP; + else if (state->count == 3) return TRIPLE_HOLD; + else return 8; //magic number. At some point this method will expand to work for more presses +}*/ + +/* "Super tap toggle" + * Basically, TT but for two or more layers for a single key. + * This particular dance: + * Single tap/hold - TT for Function layer + * Double tap/hold - TT for Numpad layer + * Triple tap/hold - TT for Mouse layer + * +*/ +void TTT_finished (qk_tap_dance_state_t *state, void *user_data) { + ttt_state.state = cur_dance(state); + switch (ttt_state.state) { + case SINGLE_TAP: layer_invert(_FUNCTION); break; + case SINGLE_HOLD: layer_on(_FUNCTION); break; + case DOUBLE_TAP: layer_invert(_NUMPAD); break; + case DOUBLE_HOLD: layer_on(_NUMPAD); break; + case DOUBLE_SINGLE_TAP: layer_invert(_NUMPAD); break; + case TRIPLE_TAP: layer_invert(_MOUSE); break; + case TRIPLE_HOLD: layer_on(_MOUSE); break; + } +} + +void TTT_reset (qk_tap_dance_state_t *state, void *user_data) { + switch (ttt_state.state) { + case SINGLE_TAP: break; + case SINGLE_HOLD: layer_off(_FUNCTION); break; + case DOUBLE_TAP: break; + case DOUBLE_HOLD: layer_off(_NUMPAD); break; + case DOUBLE_SINGLE_TAP: break; + case TRIPLE_TAP: break; + case TRIPLE_HOLD: layer_off(_MOUSE); break; + } + ttt_state.state = 0; +} + +qk_tap_dance_action_t tap_dance_actions[] = { + // simple tap dance + [F12ETAPS] = ACTION_TAP_DANCE_DOUBLE(KC_F12,LSFT(LCTL(KC_F10))), + [CALCCOMP] = ACTION_TAP_DANCE_DOUBLE(KC_CALCULATOR, KC_MY_COMPUTER), + [CALC_PRINTSCREEN] = ACTION_TAP_DANCE_DOUBLE(KC_CALCULATOR, KC_PSCR), + [ALTF4] = ACTION_TAP_DANCE_DOUBLE(KC_F4,LALT(KC_F4)), + [F6F7] = ACTION_TAP_DANCE_DOUBLE(LSFT(KC_F6), LALT(KC_F7)), + [HOME_END] = ACTION_TAP_DANCE_DOUBLE(KC_END, KC_HOME), + [TTT] = ACTION_TAP_DANCE_FN_ADVANCED(NULL,TTT_finished, TTT_reset), +}; + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + [_QWERTY] = KEYMAP( + //,----+----+----+----+----+----+----. ,----+----+----+----+----+----+----. + MESC, Q ,CSHW,ENAV, R , T ,SPC , CLPS, Y , U ,INAV, O , P ,TTT, + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + TAB , A , MEHS,DNUM,FCTL,GWIN,GRAVE, TILD, H ,JCTL, K ,MEHL,CLNMAUS,ENHM, + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + MINUS,ZCTL,MEHX, C ,ALTV, B ,DELETE, INS ,ALTN, M ,COMM,DOT ,SLSH,UNDS, + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + LSHIFT,BSPSYM, SPC ,ENTSYM + // \------------------+----+----+---/ \---+----+----+-------------------/ + ), + + [_NUMPAD] = KEYMAP( + //,----+----+----+----+----+----+----. ,----+----+----+----+----+----+----. + , , , ,ASTR, , , , , 7 , 8 , 9 ,ASTR,/**/, + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + ,MINS,PLUS,/**/,EQUAL, , , , , 4 , 5 , 6 ,PLUS, , + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + , , , ,SLSH, , , , , 1 , 2 , 3 ,SLSH, , + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + , , , 0 + // \------------------+----+----+---/ \---+----+----+-------------------/ + ), + + [_SYMBOLS] = KEYMAP( + //,----+----+-----+----+----+----+----. ,----+----+----+----+----+----+----. + ,EXLM, AT ,LCBR,RCBR,HASH, , ,CIRC,AMPR,ASTR,LPRN,RPRN,/**/, + //|----+----+-----+----+----+----+----| |----+----+----+----+----+----+----| + ,EXLM,EXLM,LPRN,RPRN , , , , ,DQUO,EQUAL,QUOTE,RCBR, , + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + ,DOLLAR, PERC,LBRACKET,RBRACKET, , , ,PIPE,BSLASH,PLUS, , , , + //|----+----+-----+----+----+----+----| |----+----+----+----+----+----+----| + UNDS,/**/, ,/**/ + // \-------------------+----+----+---/ \---+----+----+-------------------/ + ), + + [_FUNCTION] = KEYMAP( + //,----+----+----+----+----+----+----. ,----+----+----+----+----+----+----. + F6F7 ,F1 ,F2 ,F3 ,ALF4,F5 ,F6 , F7 ,F8 ,F9 ,F10 ,F11 ,F12 ,/**/, + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + , , , , , , , , , , , , , , + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + , , , , , , , , , , , , , , + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + , , , + // \------------------+----+----+---/ \---+----+----+-------------------/ + ), + + [_NAV] = KEYMAP( + //,----+----+----+----+----+----+----. ,----+----+----+----+----+----+----. + , ,SNAPLEFT,/**/,SNAPRIGHT,, , , , , UP , , , , + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + ,SNAPUP,PREVTAB, ,NEXTTAB,SNAPDOWN,, , ,LEFT,DOWN,RGHT, , , + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + , ,WORKLEFT, ,WORKRIGHT,, , , ,PGUP,PGDN, , , , + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + CDEL ,DEL, , + // \------------------+----+----+---/ \---+----+----+-------------------/ + ), + + [_TEXTNAV] = KEYMAP( + //,----+----+----+----+----+----+----. ,----+----+----+----+----+----+----. + , , , , , , , , , ,/**/, , , , + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + , , , , , , , , , , , , , , + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + , , , , , , , , , , , , , , + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + , , , + // \------------------+----+----+---/ \---+----+----+-------------------/ + ), + + [_MOUSE] = KEYMAP( + //,----+----+----+----+----+----+----. ,----+----+----+----+----+----+----. + , , ,MS_UP, , , , , , , UP , , , ,/**/ + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + , ,MS_LEFT,MS_DOWN,MS_RIGHT, , , , ,LEFT,DOWN,RGHT,/**/, , + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + , , , , , , , , , , , , , , + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + ,MS_BTN1 ,MS_BTN2 , + // \------------------+----+----+---/ \---+----+----+-------------------/ + ), + + + [_MACROS] = KEYMAP( + //,----+----+----+----+----+----+----. ,----+----+----+----+----+----+----. + /**/,RESET,SECRET_2,SECRET_3, , , ,SYSTEM_SLEEP, , ,INCL, , , , + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + CAD ,SECRET_1, , , , , , , , , , , , , + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + SCAP, , , , , , , , , , , , ,SCAP, + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| + , , , + // \------------------+----+----+---/ \---+----+----+-------------------/ + ) + +}; + + +const uint16_t PROGMEM fn_actions[] = { + +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch(id) { + /* include some kind of library or header */ + case 0: + if (record->event.pressed) { + SEND_STRING("#include <>"); + return MACRO( T(LEFT), END); + } + break; + case 1: + if (record->event.pressed) { + SEND_STRING("git pull"); + return MACRO( T(ENT), END ); + } + break; + case 2: + if (record->event.pressed){ + SEND_STRING("git push"); + return MACRO( T(ENT), END ); + } + break; + case 3: + if (record->event.pressed){ + // layer_on(_CAPS); + // register_code(KC_CAPSLOCK); + // unregister_code(KC_CAPSLOCK); + } + break; + case 4: + if (record->event.pressed){ + // layer_off(_CAPS); + // register_code(KC_CAPSLOCK); + // unregister_code(KC_CAPSLOCK); + } + break; + } + return MACRO_NONE; +}; + + +void matrix_scan_user(void) { + uint8_t layer = biton32(layer_state); + + switch (layer) { + case _QWERTY: + set_led_green; + break; + case _MOUSE: + set_led_yellow; + break; + case _NUMPAD: + set_led_blue; + break; + case _SYMBOLS: + set_led_red; + break; + case _NAV: + set_led_magenta; + break; + case _MACROS: + set_led_green; + _delay_ms(45); + set_led_red; + _delay_ms(45); + break; + case _FUNCTION: + set_led_green; + _delay_ms(45); + set_led_blue; + _delay_ms(45); + break; + default: + set_led_green; + break; + } +}; diff --git a/keyboards/ergodox_infinity/keymaps/gordon/keymap.c b/keyboards/ergodox_infinity/keymaps/gordon/keymap.c new file mode 100644 index 00000000..7e3e51cd --- /dev/null +++ b/keyboards/ergodox_infinity/keymaps/gordon/keymap.c @@ -0,0 +1,315 @@ +#include QMK_KEYBOARD_H +#include "debug.h" +#include "action_layer.h" +#include "version.h" +#include "process_keycode/process_tap_dance.h" +#include "gordon.h" + +#include "keymap_german.h" + +#include "keymap_nordic.h" + + +#define TLSLSH M(TIL_SLASH) +#define F1_F13 TD(F1F13) +#define F2_F14 TD(F2F14) +#define F5_F15 TD(F5F15) +#define F4_ALTF4 TD(ALTF4) +#define END_ESC TD(ENDESC) +#define SHF6_AF7 TD(F6F7) +#define F12_RUN TD(F12ETAPS) +#define COMMA_TD TD(COMMA) + +enum custom_keycodes { + PLACEHOLDER = SAFE_RANGE, // can always be here + EPRM, + VRSN, + RGB_SLD, +}; + +//Tap dance enums +enum { + F12TAP = 0, + F12ETAPS, + CALCCOMP, + REFRESH, //send R, or Control+R if double tapped. + ENDESC, + XESC, //'quad function'. x, control, escape, alt + ALY2, //'quad function': a, Hyper, ctrl+a, layer 2 + PRLOCK, + F6F7, // Shift F6 or Alt F7 + TABCOMBO, + FCTRL, + F3D, + ALTF4, + COMMA, + AT, + HTAB, + F1F13, + F2F14, + F5F15 +}; + + + +// Custom tapping terms for each key. +// Requires changes to action_taping.c +/* uint16_t get_tapping_term(keyevent_t* event) { + uint16_t keycode = keymap_key_to_keycode(layer_switch_get_layer(event->key), event->key); + if (keycode == LT(3,KC_E) ) { + return TAPPING_TERM + 50; + } + return TAPPING_TERM; +} */ + + +// Tap Dance Definitions +qk_tap_dance_action_t tap_dance_actions[] = { + // simple tap dance + [F12ETAPS] = ACTION_TAP_DANCE_DOUBLE(KC_F12,LSFT(LCTL(KC_F10))), + [REFRESH] = ACTION_TAP_DANCE_DOUBLE(KC_R,LCTL(KC_R)), + [ENDESC] = ACTION_TAP_DANCE_DOUBLE(KC_END, KC_ESC), + [CALCCOMP] = ACTION_TAP_DANCE_DOUBLE(KC_CALCULATOR, KC_MY_COMPUTER), + [ALTF4] = ACTION_TAP_DANCE_DOUBLE(KC_F4,LALT(KC_F4)), + [F6F7] = ACTION_TAP_DANCE_DOUBLE(LSFT(KC_F6), LALT(KC_F7)), + [F1F13] = ACTION_TAP_DANCE_DOUBLE(KC_F1, KC_F13), + [F2F14] = ACTION_TAP_DANCE_DOUBLE(KC_F2, KC_F14), + [F5F15] = ACTION_TAP_DANCE_DOUBLE(KC_F5, KC_F15), + [TABCOMBO] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, tab_finished, tab_reset), + [F3D] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, bt_finished, bt_reset), + [COMMA] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, comma_finished, comma_reset), + [HTAB] = ACTION_TAP_DANCE_FN_ADVANCED(NULL,h_finished, h_reset) +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + +//**************************FIRST LAYER - LAYER ZERO ************************************** + [_QWERTY] = KEYMAP( + + SHF6_AF7, F1_F13, F2_F14, TD(F3D), F4_ALTF4, F5_F15, KC_F11, + ________, KC_Q, CTR_SH_W, NAV_E, CTR_AL_R, KC_T, PRINTSCR, + KC_TAB, KC_A, MEH_S, NUMPAD_D, CTRL_F, WIN_G, + ALT_SHFT, CTRL_Z, HYPER_X, MOUSE_C, ALT_V, KC_B, TT(_MOUSE), + KC_MINUS, KC_GRAVE, KC_DELETE, KC_LEFT, KC_RIGHT, + + KC_INSERT, KC_DELETE, + ALT_HOME, + KC_LSHIFT, SYMB_BSP, END_ESC, + + F12_RUN, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, TD(CALCCOMP), + ________, KC_Y, KC_U, KC_I, KC_O, KC_P, ________, + WIN_H, CTRL_J, KC_K, MEH_L, COL_MOUS, ________, + KC_LEAD, KC_N, ALT_M, COMMA_TD, HYPE_DOT, KC_SLASH, TD(TABCOMBO), + KC_UP, KC_DOWN, KC_ESC, KC_TILD, KC_UNDS, + + KC_ESCAPE, KC_DELETE, + ALT_T(KC_PGUP), + RCTL_T(KC_PGDOWN), LT(_NAV,KC_ENTER), SPAC_SYM), + + + //**************************SYMBOLS LAYER************************** + [_SYMBOLS] = KEYMAP( + ________, ________, ________, ________, ________, ________, ________, + ________, TLSLSH, KC_AT, KC_LCBR, KC_RCBR, KC_CIRC, ________, + ________, KC_EXLM, KC_PIPE, KC_LPRN, KC_RPRN, M(DEREF), + ________,KC_DOLLAR, KC_PERC, LSQUIGLY, RSQUIGLY, ________, ________, + ________, M(TICK3), ________, ________, ________, + + ________,________, + ________, + ________,________,________, + + + ________, ________, ________, ________, ________, ________, NUMLOCK, + ________, TLSLSH, KC_PIPE, KC_PLUS, KC_AMPR, ________, CAPLOCK, + M(EQRIGHT), KC_DQUO, KC_EQUAL, KC_QUOTE,KC_SCOLON, ________, + ________, KC_PIPE, BK_SLASH, ASTERSK, KC_DOT, KC_SLASH, ________, + ________,________,________,M(TILD3),________, + ________,________, + ________, + ________,________,________), + + //**************************MOUSE MOVEMENT LAYER************************** + [_MOUSE] = KEYMAP(RESET,________,________,________,________,________,________, + RESET,________,________,KC_MS_UP,________,KC_MS_WH_UP,CALTDEL, + ________,________,KC_MS_LEFT,KC_MS_DOWN,KC_MS_RIGHT,KC_MS_WH_DOWN, + KC_SECRET_1,________,HYPR(KC_F13),________,HYPR(KC_F14),KC_SECRET_2,________, + ________,________,HYPR(KC_F15),KC_MS_WH_LEFT,KC_MS_WH_RIGHT, + + ________,________, + ________, + KC_MS_BTN1,KC_MS_BTN2,________, + + + ________,________,________,________,________,________,________, + KC_MS_WH_UP,________,________,KC_UP,________,________,________, + ________,KC_LEFT,KC_DOWN,KC_RIGHT,________,________, + KC_MS_WH_DOWN,________,KC_PGUP,KC_PGDOWN,KC_MEDIA_NEXT_TRACK,________,________, + KC_AUDIO_VOL_UP,KC_AUDIO_VOL_DOWN,KC_AUDIO_MUTE,KC_MEDIA_PLAY_PAUSE,________, + ________,________, + ________, + ________,________,KC_WWW_BACK), + + + + + //**************************WINDOWS NAVIGATION LAYER************************** + + [_NAV] = KEYMAP(________,________,________,________,________,________,________, + ________,________,SNAPLEFT,________,SNAPRGHT,LALT(KC_LEFT),________, + ________,LCTL(KC_W),PREVTAB,LGUI(KC_D),NEXTTAB,________, + ________,________,WORKLEFT,________,WORKRIGHT,________,________, + ________,________,________,________,________, + + ________,________, + ________, + ________,________,________, + + + ________,________,________,________,________,________,________, + ________,________,SNAPUP ,KC_UP ,SNAPDOWN,________,________, + ________,KC_LEFT ,KC_DOWN ,KC_RIGHT,________,________, + ________,________,________,________,________,________,________, + ________,________,________,________,________, + + + ________,________, + ________, + ________,________,________), + + //****************************NUMPAD LAYER**************************** + [_NUMPAD] = KEYMAP(________,________,________,________,________,________,________, + ________,________,________,________,________,________,________, + ________,________,________,________,________,________, + ________,________,________,________,________,________,________, + ________,________,________,________,________, + + ________,________, + ________, + ________,________,________, + + BL_TOGG ,BL_STEP ,________,________,________,________,________, + ________,________,KC_7 ,KC_8 ,KC_9 ,________,________, + ________,KC_4 ,KC_5 ,KC_6 ,________,________, + ________,________,KC_1 ,KC_2 ,KC_3 ,________,________, + KC_0 ,KC_0 , KC_DOT ,________,________, + + ________,________, + ________, + ________,________,KC_0), + //****************************TEXT/INTELLIJ NAVIGATION LAYER**************************** + [_TEXTNAV] = KEYMAP(________,________,________,________,________,________,________, + ________,MEH(KC_Q),LSFT(KC_ESCAPE),MEH(KC_D),MEH(KC_2),LALT(LSFT(KC_UP)),________, + ________,LALT(KC_F7),LCTL(KC_LEFT),LCTL(KC_B),LCTL(KC_RIGHT),LALT(LSFT(KC_DOWN)), + ________,________,________,LCTL(LSFT(KC_COMMA)),MEH(KC_DOT),LALT(KC_MS_WH_UP),________,________,________,________,________,________,________,________,________,________,LCTL(KC_DELETE),________,LALT(LSFT(KC_F9)),________,________,________,________,________,________,________,MEH(KC_5),LALT(LSFT(KC_Z)),________,LALT(KC_Z),________,________,________,LCTL(LSFT(KC_LEFT)),LALT(LCTL(KC_S)),LCTL(LSFT(KC_RIGHT)),LCTL(LSFT(KC_COMMA)),________,________,________,________,________,________,________,________,________,________,________,________,________,________,________,________,________,________,________) +}; + +const uint16_t PROGMEM fn_actions[] = { + [1] = ACTION_LAYER_TAP_TOGGLE(1) +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch(id) { + case INFOQM: { + if (record->event.pressed) { + SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); + } + break; + } + + case TIL_SLASH: { + if (record->event.pressed) { + SEND_STRING ("~/."); + } + break; + } + + case DEREF: { + if (record->event.pressed) { + SEND_STRING ("->"); + } + break; + } + + case EQRIGHT: { + if (record->event.pressed) { + SEND_STRING ("=>"); + } + break; + } + + case TICK3: { + if (record->event.pressed) { + SEND_STRING ("```"); + } + break; + } + + case TILD3: { + if (record->event.pressed) { + SEND_STRING ("~~~"); + } + break; + } + + case ALTTAB_START: { + register_code(KC_LALT); + layer_on(8); + } + + case ALTTAB_END: { + unregister_code(KC_LALT); + layer_off(8); + } + + + + } + return MACRO_NONE; +}; + +void matrix_scan_user(void) { + + uint8_t layer = biton32(layer_state); + + ergodox_board_led_on(); + ergodox_led_all_on(); + + ergodox_board_led_off(); + ergodox_right_led_1_off(); + ergodox_right_led_2_off(); + ergodox_right_led_3_off(); + switch (layer) { + case _SYMBOLS: + ergodox_right_led_1_on(); + break; + case _MOUSE: + ergodox_right_led_2_on(); + break; + case _NUMPAD: + ergodox_right_led_3_on(); + break; + case _NAV: + ergodox_right_led_1_on(); + ergodox_right_led_2_on(); + break; + case 5: + ergodox_right_led_1_on(); + ergodox_right_led_3_on(); + break; + case 6: + ergodox_right_led_2_on(); + ergodox_right_led_3_on(); + break; + case 7: + ergodox_right_led_1_on(); + ergodox_right_led_2_on(); + ergodox_right_led_3_on(); + break; + default: + break; + } + +}; diff --git a/users/gordon/gordon.c b/users/gordon/gordon.c new file mode 100644 index 00000000..056012a2 --- /dev/null +++ b/users/gordon/gordon.c @@ -0,0 +1,275 @@ +#include "gordon.h" +#include "quantum.h" +#include "action.h" +#include "process_keycode/process_tap_dance.h" + +#if (__has_include("secret.h")) +#include "secret.h" +#else +const char secret[][64] = { + "test1", + "test2", + "test3", + "test4", + "test5" +}; +#endif + + + + +void register_hyper (void) { //Helper function to invoke Hyper + register_code (KC_LSFT); + register_code (KC_LCTL); + register_code (KC_LALT); + register_code (KC_LGUI); +} +void unregister_hyper (void) { //Helper function to invoke Hyper + unregister_code (KC_LSFT); + unregister_code (KC_LCTL); + unregister_code (KC_LALT); + unregister_code (KC_LGUI); +} + +void register_ctrl_a (void) { + register_code(KC_LCTL); + register_code(KC_A); +} + +void unregister_ctrl_a (void) { + unregister_code(KC_LCTL); + unregister_code(KC_A); +} + +void register_alt_f7 (void) { + register_code (KC_LALT); + register_code (KC_F7); +} + +void unregister_alt_f7 (void) { + unregister_code (KC_LALT); + unregister_code (KC_F7); +} + +void register_shift_f6 (void) { + register_code (KC_LSFT); + register_code (KC_F6); +} + +void unregister_shift_f6 (void) { + unregister_code (KC_LSFT); + unregister_code (KC_F6); +} + +void register_ctrl_shift (void) { + register_code (KC_LSFT); + register_code (KC_LCTRL); +} + +void unregister_ctrl_shift (void) { + unregister_code (KC_LSFT); + unregister_code (KC_LCTRL); +} + +void register_alt_shift (void) { + register_code (KC_LSFT); + register_code (KC_LALT); +} + +void unregister_alt_shift (void) { + unregister_code (KC_LSFT); + unregister_code (KC_LALT); +} + +// To activate SINGLE_HOLD, you will need to hold for 200ms first. +// This tap dance favors keys that are used frequently in typing like 'f' +int cur_dance (qk_tap_dance_state_t *state) { + if (state->count == 1) { + //If count = 1, and it has been interrupted - it doesn't matter if it is pressed or not: Send SINGLE_TAP + if (state->interrupted) { + // if (!state->pressed) return SINGLE_TAP; + //need "permissive hold" here. + // else return SINsGLE_HOLD; + //If the interrupting key is released before the tap-dance key, then it is a single HOLD + //However, if the tap-dance key is released first, then it is a single TAP + //But how to get access to the state of the interrupting key???? + return SINGLE_TAP; + } + else { + if (!state->pressed) return SINGLE_TAP; + else return SINGLE_HOLD; + } + } + //If count = 2, and it has been interrupted - assume that user is trying to type the letter associated + //with single tap. + else if (state->count == 2) { + if (state->interrupted) return DOUBLE_SINGLE_TAP; + else if (state->pressed) return DOUBLE_HOLD; + else return DOUBLE_TAP; + } + else if ((state->count == 3) && ((state->interrupted) || (!state->pressed))) return TRIPLE_TAP; + else if (state->count == 3) return TRIPLE_HOLD; + else return 8; //magic number. At some point this method will expand to work for more presses +} + +//This works well if you want this key to work as a "fast modifier". It favors being held over being tapped. +int hold_cur_dance (qk_tap_dance_state_t *state) { + if (state->count == 1) { + if (state->interrupted) { + if (!state->pressed) return SINGLE_TAP; + else return SINGLE_HOLD; + } + else { + if (!state->pressed) return SINGLE_TAP; + else return SINGLE_HOLD; + } + } + //If count = 2, and it has been interrupted - assume that user is trying to type the letter associated + //with single tap. + else if (state->count == 2) { + if (state->pressed) return DOUBLE_HOLD; + else return DOUBLE_TAP; + } + else if (state->count == 3) { + if (!state->pressed) return TRIPLE_TAP; + else return TRIPLE_HOLD; + } + else return 8; //magic number. At some point this method will expand to work for more presses +} + + +static xtap htap_state = { + .is_press_action = true, + .state = 0 +}; + +void h_finished (qk_tap_dance_state_t *state, void *user_data) { + htap_state.state = cur_dance(state); + switch (htap_state.state) { + case SINGLE_TAP: register_code(KC_H); break; + case SINGLE_HOLD: layer_on(8); register_code(KC_LALT); break; + case DOUBLE_TAP: layer_invert(8); register_code(KC_LALT); break; + // case DOUBLE_HOLD: register_code(KC_LALT); + case DOUBLE_SINGLE_TAP: register_code(KC_H);unregister_code(KC_H);register_code(KC_H); + } +} + +void h_reset (qk_tap_dance_state_t *state, void *user_data) { + switch (htap_state.state) { + case SINGLE_TAP: unregister_code(KC_H); break; + case SINGLE_HOLD: layer_off(8); unregister_code(KC_LALT); break; + case DOUBLE_TAP: unregister_code(KC_LALT);break; + // case DOUBLE_HOLD: unregister_code(KC_LALT); + case DOUBLE_SINGLE_TAP: unregister_code(KC_H); + } + htap_state.state = 0; +} + + +/**************** QUAD FUNCTION FOR TAB ****************/ +// TAB, ALT + SHIFT, TAB TAB, CTRL + SHIFT +static xtap tab_state = { + .is_press_action = true, + .state = 0 +}; + +void tab_finished (qk_tap_dance_state_t *state, void *user_data) { + tab_state.state = cur_dance(state); + switch (tab_state.state) { + case SINGLE_TAP: register_code(KC_TAB); break; //send tab on single press + case SINGLE_HOLD: register_ctrl_shift(); break; + case DOUBLE_HOLD: register_alt_shift(); break; //alt shift on single hold + case DOUBLE_TAP: register_code(KC_TAB); unregister_code(KC_TAB); register_code(KC_TAB); break; //tab tab + case TRIPLE_TAP: register_code(KC_LSHIFT) ;register_code(KC_ESC); break; + case TRIPLE_HOLD: register_code(KC_LSHIFT); register_code(KC_LGUI); break; + } +} + +void tab_reset (qk_tap_dance_state_t *state, void *user_data) { + switch (tab_state.state) { + case SINGLE_TAP: unregister_code(KC_TAB); break; //unregister tab + case DOUBLE_HOLD: unregister_alt_shift(); break; //let go of alt shift + case DOUBLE_TAP: unregister_code(KC_TAB); break; + case SINGLE_HOLD: unregister_ctrl_shift(); break; + case TRIPLE_TAP: unregister_code(KC_LSHIFT); unregister_code(KC_ESC); break; + case TRIPLE_HOLD: unregister_code(KC_LSHIFT); unregister_code(KC_LGUI); break; + } + tab_state.state = 0; +} +/**************** QUAD FUNCTION FOR TAB ****************/ + +//*************** SUPER COMMA *******************// +// Assumption: we don't care about trying to hit ,, quickly +//*************** SUPER COMMA *******************// +static xtap comma_state = { + .is_press_action = true, + .state = 0 +}; + +void comma_finished (qk_tap_dance_state_t *state, void *user_data) { + comma_state.state = hold_cur_dance(state); //Use the dance that favors being held + switch (comma_state.state) { + case SINGLE_TAP: register_code(KC_COMMA); break; + case SINGLE_HOLD: layer_on(1); break; //turn on symbols layer + case DOUBLE_TAP: layer_invert(4); break; //toggle numbers layer + case DOUBLE_HOLD: layer_on(2); break; + case TRIPLE_TAP: register_code(KC_CALCULATOR); break; + case TRIPLE_HOLD: layer_on(3); + } +} + +void comma_reset (qk_tap_dance_state_t *state, void *user_data) { + switch (comma_state.state) { + case SINGLE_TAP: unregister_code(KC_COMMA); break; //unregister comma + case SINGLE_HOLD: layer_off(1); break; + case DOUBLE_TAP: ;break; + case DOUBLE_HOLD: layer_off(2); break; + case TRIPLE_TAP: unregister_code(KC_CALCULATOR); break; + case TRIPLE_HOLD: layer_off(3); + } + comma_state.state = 0; +} +//*************** SUPER COMMA *******************// +//*************** SUPER COMMA *******************// + + +//*************** F3 TAP DANCE *******************// +//Good example for accessing multiple layers from the same key. +static xtap S1_state = { + .is_press_action = true, + .state = 0 +}; + +void bt_finished (qk_tap_dance_state_t *state, void *user_data) { + S1_state.state = cur_dance(state); + switch (S1_state.state) { + case SINGLE_TAP: register_code(KC_F3); break; + case SINGLE_HOLD: layer_on(4); break; + case DOUBLE_TAP: layer_invert(4); break; + case DOUBLE_HOLD: layer_on(5); break; + case DOUBLE_SINGLE_TAP: layer_invert(4); break; + } +} + +void bt_reset (qk_tap_dance_state_t *state, void *user_data) { + switch (S1_state.state) { + case SINGLE_TAP: unregister_code(KC_F3); break; + case SINGLE_HOLD: layer_off(4); break; + case DOUBLE_TAP: break; //already inverted. Don't do anything. + case DOUBLE_HOLD: layer_off(5); break; + case DOUBLE_SINGLE_TAP: break; + } + S1_state.state = 0; +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case KC_SECRET_1 ... KC_SECRET_5: + if (!record->event.pressed) { + send_string(secret[keycode - KC_SECRET_1]); + } + return false; + break; + } + return true; +} \ No newline at end of file diff --git a/users/gordon/gordon.h b/users/gordon/gordon.h new file mode 100644 index 00000000..548c6304 --- /dev/null +++ b/users/gordon/gordon.h @@ -0,0 +1,157 @@ +#ifndef GORDON +#define GORDON + +#include "quantum.h" +#include "process_keycode/process_tap_dance.h" + + +// Fillers to make layering more clear +#define _______ KC_TRNS +#define ________ KC_TRNS +#define _________ KC_TRNS +#define XXXXXXX KC_NO + +// KC codes that are too long +#define DOLLAR KC_DOLLAR +#define LSQUIGLY KC_LBRACKET +#define RSQUIGLY KC_RBRACKET +#define NUMLOCK KC_NUMLOCK +#define CAPLOCK KC_CAPSLOCK +#define BK_SLASH KC_BSLASH +#define ASTERSK KC_KP_ASTERISK + +// Navigation +#define SNAPLEFT LGUI(KC_LEFT) +#define SNAPRGHT LGUI(KC_RIGHT) +#define SNAPUP LGUI(KC_UP) +#define SNAPDOWN LGUI(KC_DOWN) +#define PREVTAB LCTL(LSFT(KC_TAB)) +#define NEXTTAB LCTL(KC_TAB) +#define WORKRIGHT LCTL(LGUI(KC_RIGHT)) +#define WORKLEFT LCTL(LGUI(KC_LEFT)) + +// KC/modifier hold +#define CTRL_F CTL_T(KC_F) +#define CTRL_J CTL_T(KC_J) +#define CTRL_Z CTL_T(KC_Z) +#define ALT_V ALT_T(KC_V) +#define ALT_M ALT_T(KC_M) +#define WIN_G GUI_T(KC_G) +#define WIN_H GUI_T(KC_H) +#define HYPER_X ALL_T(KC_X) +#define HYPE_DOT ALL_T(KC_DOT) +#define MEH_S MEH_T(KC_S) +#define MEH_L MEH_T(KC_L) +#define ALT_HOME ALT_T(KC_HOME) + + +// KC/Layer Hold +#define NAV_E LT(_NAV,KC_E) +#define NUMPAD_D LT(_NUMPAD,KC_D) +#define MOUSE_C LT(_MOUSE,KC_C) +#define SYMB_BSP LT(_SYMBOLS,KC_BSPACE) +#define COL_MOUS LT(_MOUSE,KC_SCOLON) +#define SPAC_SYM LT(_SYMBOLS,KC_SPACE) + +// Double Modifier ONLY hold +#define ALT_SHFT LSFT(KC_LALT) +#define CTR_SHFT LSFT(KC_LCTL) + +// KC/Double modifier Hold +#define CTR_SH_W MT(MOD_LCTL|MOD_LSFT,KC_W) +#define CTR_AL_R MT(MOD_LCTL|MOD_LALT,KC_R) + +//MISC +#define PRINTSCR KC_PSCREEN +#define CALTDEL LCTL(LALT(KC_DEL)) +#define TSKMGR LCTL(LSFT(KC_ESC)) + + +typedef struct { + bool is_press_action; + int state; +} xtap; + +enum { + SINGLE_TAP = 1, + SINGLE_HOLD = 2, + DOUBLE_TAP = 3, + DOUBLE_HOLD = 4, + DOUBLE_SINGLE_TAP = 5, //send two single taps + TRIPLE_TAP = 6, + TRIPLE_HOLD = 7 +}; + +enum gordon_layers +{ + _QWERTY = 0, + _SYMBOLS, + _MOUSE, + _NUMPAD, + _NAV, + _MACROS, + _FUNCTION, + _TEXTNAV +}; + + + +void register_hyper (void); +void unregister_hyper (void); + +void register_ctrl_a (void); +void unregister_ctrl_a (void); + +void register_alt_f7 (void); +void unregister_alt_f7 (void); + +void register_shift_f6 (void); +void unregister_shift_f6 (void); + +void register_ctrl_shift (void); +void unregister_ctrl_shift (void); + +void register_alt_shift (void); +void unregister_alt_shift (void); + +int cur_dance (qk_tap_dance_state_t *state); +int hold_cur_dance (qk_tap_dance_state_t *state); + +void x_finished (qk_tap_dance_state_t *state, void *user_data); +void x_reset (qk_tap_dance_state_t *state, void *user_data); + +void h_finished (qk_tap_dance_state_t *state, void *user_data); +void h_reset (qk_tap_dance_state_t *state, void *user_data); + +void tab_finished (qk_tap_dance_state_t *state, void *user_data); +void tab_reset (qk_tap_dance_state_t *state, void *user_data); + +void comma_finished (qk_tap_dance_state_t *state, void *user_data); +void comma_reset (qk_tap_dance_state_t *state, void *user_data); + +void bt_finished (qk_tap_dance_state_t *state, void *user_data); +void bt_reset (qk_tap_dance_state_t *state, void *user_data); + +// Macro Declarations +enum { + INFOQM, + TIL_SLASH, + DEREF, + EQRIGHT, + TILD3, + TICK3, + ALTTAB_START, + ALTTAB_END +}; + +enum secret_strings { + KC_SECRET_1 = SAFE_RANGE, + KC_SECRET_2, + KC_SECRET_3, + KC_SECRET_4, + KC_SECRET_5, +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt); + +#endif \ No newline at end of file diff --git a/users/gordon/readme.md b/users/gordon/readme.md new file mode 100644 index 00000000..fdea33b6 --- /dev/null +++ b/users/gordon/readme.md @@ -0,0 +1,14 @@ +Copyright @ + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . \ No newline at end of file diff --git a/users/gordon/rules.mk b/users/gordon/rules.mk new file mode 100644 index 00000000..5dd62c20 --- /dev/null +++ b/users/gordon/rules.mk @@ -0,0 +1 @@ +SRC += gordon.c \ No newline at end of file