diff --git a/keyboards/ergodox_ez/keymaps/algernon/Makefile b/keyboards/ergodox_ez/keymaps/algernon/Makefile index 005f9750c..6bf3976b9 100644 --- a/keyboards/ergodox_ez/keymaps/algernon/Makefile +++ b/keyboards/ergodox_ez/keymaps/algernon/Makefile @@ -4,13 +4,19 @@ SLEEP_LED_ENABLE=no UNICODE_ENABLE=no FORCE_NKRO ?= yes DEBUG_ENABLE = no -CONSOLE_ENABLE = yes +CONSOLE_ENABLE = no TAP_DANCE_ENABLE = yes +KEYLOGGER_ENABLE ?= yes ifeq (${FORCE_NKRO},yes) OPT_DEFS += -DFORCE_NKRO endif +ifeq (${KEYLOGGER_ENABLE},yes) +OPT_DEFS += -DKEYLOGGER_ENABLE +CONSOLE_ENABLE = yes +endif + KEYMAP_VERSION = $(shell \ if [ -d "${KEYMAP_PATH}/.git" ]; then \ cd "${KEYMAP_PATH}" && git describe --abbrev=6 --dirty --always --tags --match 'v*' 2>/dev/null; \ diff --git a/keyboards/ergodox_ez/keymaps/algernon/keymap.c b/keyboards/ergodox_ez/keymaps/algernon/keymap.c index 09d8dffd5..c12087292 100644 --- a/keyboards/ergodox_ez/keymaps/algernon/keymap.c +++ b/keyboards/ergodox_ez/keymaps/algernon/keymap.c @@ -95,7 +95,9 @@ enum { /* Custom keycodes */ enum { - CT_CLN = 0 + CT_CLN = 0, + CT_MNS, + CT_TA, }; /* States & timers */ @@ -115,7 +117,11 @@ uint16_t oh_left_blink_timer = 0; uint8_t oh_right_blink = 0; uint16_t oh_right_blink_timer = 0; +#if KEYLOGGER_ENABLE bool log_enable = false; +#endif + +bool time_travel = false; /* The Keymap */ @@ -146,7 +152,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { // left hand KC_GRV ,M(KF_1) ,M(KF_2) ,M(KF_3),M(KF_4),M(KF_5),M(A_PLVR) ,M(A_MPN) ,KC_QUOT ,KC_COMM ,KC_DOT ,KC_P ,KC_Y ,KC_LBRC -,LT(ARRW,KC_TAB) ,KC_A ,KC_O ,KC_E ,KC_U ,KC_I +,TD(CT_TA) ,KC_A ,KC_O ,KC_E ,KC_U ,KC_I ,KC_MPLY ,KC_SLSH ,KC_Q ,KC_J ,KC_K ,KC_X ,KC_LPRN ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,TD(CT_CLN) @@ -155,11 +161,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ,KC_BSPC,F(F_SFT),M(A_ESC) // right hand - ,KC_APP ,M(KF_6),M(KF_7),M(KF_8),M(KF_9) ,M(KF_10) ,KC_F11 - ,KC_RBRC ,KC_F ,KC_G ,KC_C ,KC_R ,KC_L ,KC_BSLS - ,KC_D ,KC_H ,KC_T ,KC_N ,KC_S ,LT(ARRW, KC_EQL) - ,KC_RPRN ,KC_B ,KC_M ,KC_W ,KC_V ,KC_Z ,KC_MSTP - ,KC_MINS,KC_NO ,KC_NO ,KC_NO ,KC_NO + ,KC_APP ,M(KF_6),M(KF_7) ,M(KF_8),M(KF_9) ,M(KF_10) ,KC_F11 + ,KC_RBRC ,KC_F ,KC_G ,KC_C ,KC_R ,KC_L ,KC_BSLS + ,KC_D ,KC_H ,KC_T ,KC_N ,KC_S ,KC_EQL + ,KC_RPRN ,KC_B ,KC_M ,KC_W ,KC_V ,KC_Z ,KC_MSTP + ,TD(CT_MNS),KC_NO ,KC_NO ,KC_NO ,KC_NO ,OSL(NMDIA),M(OH_LEFT) ,KC_LEAD @@ -191,7 +197,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { // left hand KC_GRV ,M(KF_1) ,M(KF_2) ,M(KF_3),M(KF_4),M(KF_5),M(A_PLVR) ,M(A_MPN) ,KC_COMM ,KC_DOT ,KC_L ,KC_W ,KC_M ,KC_LBRC -,LT(ARRW, KC_TAB) ,KC_A ,KC_O ,KC_E ,KC_I ,KC_U +,TD(CT_TA) ,KC_A ,KC_O ,KC_E ,KC_I ,KC_U ,KC_MPLY ,KC_SLSH ,KC_Z ,KC_QUOT,KC_K ,KC_X ,KC_LPRN ,KC_NO ,KC_NO ,KC_NO ,KC_NO ,TD(CT_CLN) @@ -200,11 +206,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ,KC_BSPC,F(F_SFT),M(A_ESC) // right hand - ,KC_APP ,M(KF_6),M(KF_7),M(KF_8),M(KF_9) ,M(KF_10) ,KC_F11 - ,KC_RBRC ,KC_F ,KC_H ,KC_C ,KC_P ,KC_Y ,KC_BSLS - ,KC_D ,KC_R ,KC_T ,KC_N ,KC_S ,LT(ARRW, KC_EQL) - ,KC_RPRN ,KC_B ,KC_G ,KC_V ,KC_J ,KC_Q ,KC_MSTP - ,KC_MINS,KC_NO ,KC_NO ,KC_NO ,KC_NO + ,KC_APP ,M(KF_6),M(KF_7) ,M(KF_8),M(KF_9) ,M(KF_10) ,KC_F11 + ,KC_RBRC ,KC_F ,KC_H ,KC_C ,KC_P ,KC_Y ,KC_BSLS + ,KC_D ,KC_R ,KC_T ,KC_N ,KC_S ,KC_EQL + ,KC_RPRN ,KC_B ,KC_G ,KC_V ,KC_J ,KC_Q ,KC_MSTP + ,TD(CT_MNS),KC_NO ,KC_NO ,KC_NO ,KC_NO ,OSL(NMDIA),M(OH_LEFT) ,KC_LEAD @@ -892,24 +898,92 @@ void ang_tap (uint16_t codes[]) { register_code (code); \ unregister_code (code) -void ang_tap_dance (qk_tap_dance_state_t *state) { - switch (state->keycode) { - case TD(CT_CLN): - if (state->count == 1) { - register_code (KC_RSFT); - register_code (KC_SCLN); - unregister_code (KC_SCLN); - unregister_code (KC_RSFT); - } else if (state->count == 2) { - register_code (KC_SCLN); - unregister_code (KC_SCLN); - reset_tap_dance (state); - } +void ang_tap_dance_cln_finished (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + register_code (KC_RSFT); + register_code (KC_SCLN); + } else if (state->count == 2) { + register_code (KC_SCLN); } } +void ang_tap_dance_cln_reset (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + unregister_code (KC_SCLN); + unregister_code (KC_RSFT); + } else if (state->count == 2) { + unregister_code (KC_SCLN); + } +} + +void ang_tap_dance_mns_finished (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + register_code (KC_MINS); + } else if (state->count == 2) { + register_code (KC_RSFT); + register_code (KC_MINS); + } +} + +void ang_tap_dance_mns_reset (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + unregister_code (KC_MINS); + } else if (state->count == 2) { + unregister_code (KC_RSFT); + unregister_code (KC_MINS); + } +} + +typedef struct { + bool layer_toggle; + bool sticky; + bool finished_once; +} td_ta_state_t; + +void ang_tap_dance_ta_finished (qk_tap_dance_state_t *state, void *user_data) { + td_ta_state_t *td_ta = (td_ta_state_t *) user_data; + + if (td_ta->finished_once) { + return; + } + + if (td_ta->sticky) { + td_ta->sticky = false; + td_ta->layer_toggle = false; + layer_off (ARRW); + return; + } + + td_ta->finished_once = true; + if (state->count == 1 && !state->pressed) { + register_code (KC_TAB); + td_ta->sticky = false; + td_ta->layer_toggle = false; + } else { + td_ta->layer_toggle = true; + layer_on (ARRW); + td_ta->sticky = (state->count == 2); + } +} + +void ang_tap_dance_ta_reset (qk_tap_dance_state_t *state, void *user_data) { + td_ta_state_t *td_ta = (td_ta_state_t *) user_data; + + if (!td_ta->layer_toggle) + unregister_code (KC_TAB); + if (!td_ta->sticky) + layer_off (ARRW); + + td_ta->finished_once = false; +} + const qk_tap_dance_action_t tap_dance_actions[] = { - [CT_CLN] = ACTION_TAP_DANCE_FN (ang_tap_dance) + [CT_CLN] = ACTION_TAP_DANCE_FN_ADVANCED (NULL, ang_tap_dance_cln_finished, ang_tap_dance_cln_reset) + ,[CT_MNS] = ACTION_TAP_DANCE_FN_ADVANCED (NULL, ang_tap_dance_mns_finished, ang_tap_dance_mns_reset) + ,[CT_TA] = { + .fn = { NULL, ang_tap_dance_ta_finished, ang_tap_dance_ta_reset }, + .user_data = (void *)&((td_ta_state_t) { false, false, false }) + } }; // Runs constantly in the background, in a loop. @@ -1002,9 +1076,18 @@ void matrix_scan_user(void) { leading = false; leader_end (); +#if KEYLOGGER_ENABLE SEQ_ONE_KEY (KC_D) { + ergodox_led_all_on(); + _delay_ms(100); + ergodox_led_all_off(); log_enable = !log_enable; } +#endif + + SEQ_ONE_KEY (KC_T) { + time_travel = !time_travel; + } SEQ_ONE_KEY (KC_U) { ang_do_unicode (); @@ -1093,13 +1176,41 @@ void matrix_scan_user(void) { } } +static uint16_t last4[4]; + bool process_record_user (uint16_t keycode, keyrecord_t *record) { +#if KEYLOGGER_ENABLE uint8_t layer = biton32(layer_state); if (log_enable && layer == BASE) { xprintf ("KL: col=%d, row=%d\n", record->event.key.col, record->event.key.row); } +#endif + + if (time_travel && !record->event.pressed) { + uint8_t p; + + // shift cache one to the left + for (p = 0; p < 3; p++) { + last4[p] = last4[p + 1]; + } + last4[3] = keycode; + + if (last4[0] == KC_D && last4[1] == KC_A && last4[2] == KC_T && last4[3] == KC_E) { + uint16_t codes[] = {KC_E, KC_SPC, KC_MINS, KC_D, KC_SPC, KC_QUOT, 0}; + ang_tap (codes); + register_code (KC_RSFT); + register_code (KC_EQL); + unregister_code (KC_EQL); + unregister_code (KC_RSFT); + + uint16_t codes2[] = {KC_4, KC_SPC, KC_D, KC_A, KC_Y, KC_S, KC_QUOT, 0}; + ang_tap (codes2); + + return false; + } + } return true; } diff --git a/keyboards/ergodox_ez/keymaps/algernon/readme.md b/keyboards/ergodox_ez/keymaps/algernon/readme.md index 2312dc59e..6fe177511 100644 --- a/keyboards/ergodox_ez/keymaps/algernon/readme.md +++ b/keyboards/ergodox_ez/keymaps/algernon/readme.md @@ -50,6 +50,7 @@ At its core, this is a Dvorak layout, with some minor changes. The more interest - `LEAD a` makes the [ADORE layer](#adore-layer) the default. - `LEAD v` prints the firmware version, the keyboard and the keymap. - `LEAD d` toggles logging keypress positions to the HID console. + - `LEAD t` toggles time travel. Figuring out the current `date` is left as an exercise to the reader. ## ADORE layer @@ -148,6 +149,14 @@ The keymap default to forcing NKRO, which seems to upset Windows, and except the # Changelog +## v1.4 - 2016-07-29 + +* When toggling the key logging on or off, the LEDs will do a little dance. +* The keylogger is now optional, but enabled by default. Use `KEYLOGGER_ENABLE=no` on the `make` command line to disable it. +* The `TAB`/`ARRW` key was turned into a tap-dance key, allowing one to toggle the **ARROW** layer on by double-tapping, and as such, avoid the need to hold the key. +* The `-`/`_` key was turned into a tap-dance key too. +* There is now a way to travel time with the keyboard, toggle the feature on by hitting `LEAD t`. + ## v1.3 - 2016-07-06 * Added support for logging keys, by pressing `LEAD d`. Also included is a tool to generate a [heatmap](#heatmap) out of the logs. diff --git a/keyboards/ergodox_ez/keymaps/algernon/tools/heatmap-adore-layout.json b/keyboards/ergodox_ez/keymaps/algernon/tools/heatmap-adore-layout.json new file mode 100644 index 000000000..544f61ce8 --- /dev/null +++ b/keyboards/ergodox_ez/keymaps/algernon/tools/heatmap-adore-layout.json @@ -0,0 +1,533 @@ +[ + { + "backcolor": "#ffffff", + "name": "ErgoDox - algernon's layout: Heatmap", + "author": "Gergely Nagy ", + "notes": "See [here](https://github.com/algernon/ergodox-layout#readme) for the QMK keymap source.", + "switchMount": "cherry", + "switchBrand": "gateron", + "switchType": "KS-3-Tea", + "pcb": true, + "css": ".keyborder { -webkit-filter: blur(5px); filter: blur(5px); } .keytop { -webkit-filter: blur(10px); } .keylabels { border: 1px solid black; }" + }, + [ + { + "x": 3.5, + "c": "#a7d0db", + "fa": [ + 0, + 0, + 2 + ] + }, + "#\n3\nF3", + { + "x": 10.5, + "c": "#a7d0db", + "t": "#000000", + "a": 4, + "fa": [ + 0, + 0, + 2 + ] + }, + "*\n8\nF8" + ], + [ + { + "y": -0.875, + "x": 2.5, + "c": "#bfbad1", + "t": "#0d0d0b" + }, + "@\n2\nF2", + { + "x": 1, + "c": "#7adabd", + "t": "#000000" + }, + "$\n4\nF4", + { + "x": 8.5 + }, + "&\n7\nF7", + { + "x": 1, + "c": "#bfbad1", + "t": "#0d0d0b" + }, + "(\n9\nF9" + ], + [ + { + "y": -0.875, + "x": 5.5, + "c": "#7adabd", + "t": "#000000" + }, + "%\n5\nF5", + { + "c": "#f9cd31", + "a": 7, + "f": 2 + }, + "STENO", + { + "x": 4.5, + "f": 6 + }, + "", + { + "c": "#7adabd", + "a": 4, + "f": 3, + "fa": [ + 0, + 0, + 2 + ] + }, + "^\n6\nF6" + ], + [ + { + "y": -0.875, + "c": "#ffb2d2", + "f": 3, + "w": 1.5 + }, + "\n\n~\n`", + { + "t": "#0d0d0b" + }, + "!\n1\nF1", + { + "x": 14.5 + }, + ")\n0\nF10", + { + "a": 7, + "w": 1.5 + }, + "F11" + ], + [ + { + "y": -0.375, + "x": 3.5, + "c": "#a7d0db", + "t": "#000000", + "a": 6 + }, + "L", + { + "x": 10.5 + }, + "C" + ], + [ + { + "y": -0.875, + "x": 2.5, + "c": "#bfbad1", + "t": "#0d0d0b", + "a": 4 + }, + ">\n.", + { + "x": 1, + "c": "#7adabd", + "t": "#000000", + "a": 6 + }, + "W", + { + "x": 8.5 + }, + "H", + { + "x": 1, + "c": "#bfbad1", + "t": "#0d0d0b" + }, + "P" + ], + [ + { + "y": -0.875, + "x": 5.5, + "c": "#7adabd", + "t": "#000000" + }, + "M", + { + "c": "#93c9b7", + "a": 4, + "h": 1.5 + }, + "{\n[", + { + "x": 4.5, + "h": 1.5 + }, + "}\n]", + { + "c": "#7adabd", + "a": 6 + }, + "F" + ], + [ + { + "y": -0.875, + "c": "#ffb07b", + "t": "#0d0d0b", + "f": 6, + "w": 1.5 + }, + "\n\n", + { + "c": "#ffb2d2", + "a": 4, + "f": 3 + }, + "<\n,", + { + "x": 14.5, + "a": 6 + }, + "Y", + { + "a": 4, + "w": 1.5 + }, + "|\n\\" + ], + [ + { + "y": -0.375, + "x": 3.5, + "c": "#a7d0db", + "t": "#000000", + "a": 6 + }, + "E", + { + "x": 10.5 + }, + "T" + ], + [ + { + "y": -0.875, + "x": 2.5, + "c": "#bfbad1", + "t": "#0d0d0b" + }, + "O", + { + "x": 1, + "c": "#7adabd", + "t": "#000000", + "n": true + }, + "I", + { + "x": 8.5, + "n": true + }, + "R", + { + "x": 1, + "c": "#bfbad1", + "t": "#0d0d0b" + }, + "N" + ], + [ + { + "y": -0.875, + "x": 5.5, + "c": "#7adabd", + "t": "#000000" + }, + "U", + { + "x": 6.5 + }, + "D" + ], + [ + { + "y": -0.875, + "c": "#ffb2d2", + "t": "#0d0d0b", + "fa": [ + 6 + ], + "w": 1.5 + }, + "\n\nTab", + { + "f": 3 + }, + "A", + { + "x": 14.5, + "f": 3 + }, + "S", + { + "a": 4, + "fa": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 6 + ], + "w": 1.5 + }, + "+\n=" + ], + [ + { + "y": -0.625, + "x": 6.5, + "c": "#93c9b7", + "t": "#000000", + "a": 7, + "h": 1.5 + }, + "(", + { + "x": 4.5, + "h": 1.5 + }, + ")" + ], + [ + { + "y": -0.75, + "x": 3.5, + "c": "#a7d0db", + "a": 4, + "f": 3 + }, + "\"\n'", + { + "x": 10.5 + }, + "V" + ], + [ + { + "y": -0.875, + "x": 2.5, + "c": "#bfbad1", + "t": "#0d0d0b" + }, + "Z", + { + "x": 1, + "c": "#7adabd", + "t": "#000000" + }, + "K", + { + "x": 8.5 + }, + "G", + { + "x": 1, + "c": "#bfbad1", + "t": "#0d0d0b" + }, + "J" + ], + [ + { + "y": -0.875, + "x": 5.5, + "c": "#7adabd", + "t": "#000000" + }, + "X", + { + "x": 6.5 + }, + "B" + ], + [ + { + "y": -0.875, + "c": "#ffb07b", + "f": 9, + "w": 1.5 + }, + "\n\n", + { + "c": "#ffb2d2", + "t": "#0d0d0b", + "a": 4, + "f": 3 + }, + "?\n/", + { + "x": 14.5, + "a": 6 + }, + "Q", + { + "c": "#ffb07b", + "t": "#000000", + "f": 9, + "w": 1.5 + }, + "" + ], + [ + { + "y": -0.375, + "x": 3.5, + "c": "#d9dae0", + "g": true, + "a": 7, + "f": 3 + }, + "", + { + "x": 10.5 + }, + "" + ], + [ + { + "y": -0.875, + "x": 2.5 + }, + "", + { + "x": 1, + "c": "#d4872a", + "g": false, + "a": 5 + }, + ";\n:", + { + "x": 8.5 + }, + "_\n-", + { + "x": 1, + "c": "#d9dae0", + "g": true, + "a": 7 + }, + "" + ], + [ + { + "y": -0.75, + "x": 0.5 + }, + "", + {}, + "", + { + "x": 14.5 + }, + "", + {}, + "" + ], + [ + { + "r": 30, + "rx": 6.5, + "ry": 4.25, + "y": -1, + "x": 1, + "c": "#f9cd31", + "g": false + }, + "Alt", + { + "a": 4, + "fa": [ + 0, + 0, + 0, + 9 + ] + }, + "\n\n\n" + ], + [ + { + "c": "#d4872a", + "a": 7, + "f": 9, + "h": 2 + }, + "", + { + "h": 2 + }, + "", + { + "c": "#f9cd31", + "f": 3 + }, + "Ctrl" + ], + [ + { + "x": 2, + "c": "#e26757" + }, + "ESC" + ], + [ + { + "r": -30, + "rx": 13, + "y": -1, + "x": -3, + "c": "#f9cd31", + "f": 2 + }, + "MEDIA", + {}, + "1HAND" + ], + [ + { + "x": -3 + }, + "LEAD", + { + "c": "#d4872a", + "f": 9, + "h": 2 + }, + "", + { + "f": 3, + "h": 2 + }, + "SPC" + ], + [ + { + "x": -3, + "c": "#f9cd31", + "f": 2 + }, + "HUN" + ] +]