Merge pull request #535 from algernon/ergodox-ez/algernon

ergodox_ez: Update my keymap to v1.3
master
Erez Zukerman 2016-07-24 11:34:33 -07:00 committed by GitHub
commit 36f2e22283
9 changed files with 855 additions and 214 deletions

View File

@ -3,6 +3,9 @@ COMMAND_ENABLE=no
SLEEP_LED_ENABLE=no
UNICODE_ENABLE=no
FORCE_NKRO ?= yes
DEBUG_ENABLE = no
CONSOLE_ENABLE = yes
TAP_DANCE_ENABLE = yes
ifeq (${FORCE_NKRO},yes)
OPT_DEFS += -DFORCE_NKRO

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

View File

@ -10,12 +10,13 @@
#include "mousekey.h"
#include "timer.h"
#include "keymap_plover.h"
#include "eeconfig.h"
/* Layers */
enum {
BASE = 0,
EXPRM,
ADORE,
ARRW,
APPSEL,
HUN,
@ -94,7 +95,7 @@ enum {
/* Custom keycodes */
enum {
CT_CLN = 0x7101
CT_CLN = 0
};
/* States & timers */
@ -114,8 +115,7 @@ uint16_t oh_left_blink_timer = 0;
uint8_t oh_right_blink = 0;
uint16_t oh_right_blink_timer = 0;
uint8_t ct_cln_count = 0;
uint16_t ct_cln_timer = 0;
bool log_enable = false;
/* The Keymap */
@ -124,18 +124,18 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap 0: Base Layer
*
* ,-----------------------------------------------------. ,-----------------------------------------------------.
* | `~ | 1 F1 | 2 F2 | 3 F3 | 4 F4 | 5 F5 | Plvr | | 1HND | 6 F6 | 7 F7 | 8 F8 | 9 F9 | 0 F10| F11 |
* | `~ | 1 F1 | 2 F2 | 3 F3 | 4 F4 | 5 F5 | Plvr | | Apps | 6 F6 | 7 F7 | 8 F8 | 9 F9 | 0 F10| F11 |
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
* | Next/Prev | ' | , | . | P | Y | [ | | ] | F | G | C | R | L | \ |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | Tab | A | O | E | U | I |------| |------| D | H | T | N | S | = |
* | Tab/ARROW | A | O | E | U | I |------| |------| D | H | T | N | S | = / Arrow |
* |-----------+------+------+------+------+------| ( | | ) |------+------+------+------+------+-----------|
* | Play/Pause| / | Q | J | K | X | | | | B | M | W | V | Z | Stop |
* `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
* | | | Left | Up | : | | - | Down | Rght | | |
* | | | | | : | | - | | | | |
* `-----------------------------------' `-----------------------------------'
* ,-------------. ,-------------.
* | LAlt | GUI | | MDIA | ARRW |
* | LAlt | GUI | | MDIA | 1HND |
* ,------|------|------| |------+------+------.
* | | | Ctrl | | LEAD | | |
* |Backsp|LShift|------| |------| Enter| Space|
@ -146,67 +146,67 @@ 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
,KC_TAB ,KC_A ,KC_O ,KC_E ,KC_U ,KC_I
,LT(ARRW,KC_TAB) ,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_LEFT ,KC_UP ,CT_CLN
,KC_NO ,KC_NO ,KC_NO ,KC_NO ,TD(CT_CLN)
,F(F_ALT),F(F_GUI)
,F(F_CTRL)
,KC_BSPC,F(F_SFT),M(A_ESC)
// right hand
,M(OH_LEFT),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
,KC_MINS,KC_DOWN,KC_RGHT ,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 ,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
,OSL(NMDIA),OSL(ARRW)
,OSL(NMDIA),M(OH_LEFT)
,KC_LEAD
,F(F_HUN) ,KC_ENT ,KC_SPC
),
/* Keymap 1: Experimental layer
/* Keymap 1: Adore layer
*
* ,-----------------------------------------------------. ,-----------------------------------------------------.
* | `~ | 1 F1 | 2 F2 | 3 F3 | 4 F4 | 5 F5 | Plvr | | 1HND | 6 F6 | 7 F7 | 8 F8 | 9 F9 | 0 F10| F11 |
* | `~ | 1 F1 | 2 F2 | 3 F3 | 4 F4 | 5 F5 | Plvr | | Apps | 6 F6 | 7 F7 | 8 F8 | 9 F9 | 0 F10| F11 |
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
* | Next/Prev | ' | , | . | P | Y | [ | | ] | L | F | C | R | J | = |
* | Next/Prev | , | . | L | W | M | [ | | ] | F | H | C | P | Y | \ |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | Tab | A | O | E | U | I |------| |------| D | H | T | N | S | \ |
* | Tab/Arrow | A | O | E | I | U |------| |------| D | R | T | N | S | = / Arrow |
* |-----------+------+------+------+------+------| ( | | ) |------+------+------+------+------+-----------|
* | Play/Pause| Z | G | V | K | X | | | | Q | M | W | B | / | Stop |
* | Play/Pause| / | Z | ' | K | X | | | | B | G | V | J | Q | Stop |
* `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
* | | | Left | Up | : | | - | Down | Rght | | |
* | | | | | : | | - | | | | |
* `-----------------------------------' `-----------------------------------'
* ,-------------. ,-------------.
* | LAlt | GUI | | MDIA | ARRW |
* | LAlt | GUI | | MDIA | 1HND |
* ,------|------|------| |------+------+------.
* | | | Ctrl | | LEAD | | |
* |Backsp|LShift|------| |------| Enter| Space|
* | | | ESC | | HUN | | |
* `--------------------' `--------------------'
*/
[EXPRM] = KEYMAP(
[ADORE] = KEYMAP(
// 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
,KC_TAB ,KC_A ,KC_O ,KC_E ,KC_U ,KC_I
,KC_MPLY ,KC_Z ,KC_G ,KC_V ,KC_K ,KC_X ,KC_LPRN
,KC_NO ,KC_NO ,KC_LEFT ,KC_UP ,CT_CLN
,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
,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)
,F(F_ALT),F(F_GUI)
,F(F_CTRL)
,KC_BSPC,F(F_SFT),M(A_ESC)
// right hand
,M(OH_LEFT),M(KF_6),M(KF_7),M(KF_8),M(KF_9) ,M(KF_10) ,KC_F11
,KC_RBRC ,KC_L ,KC_F ,KC_C ,KC_R ,KC_J ,KC_BSLS
,KC_D ,KC_H ,KC_T ,KC_N ,KC_S ,KC_EQL
,KC_RPRN ,KC_Q ,KC_M ,KC_W ,KC_B ,KC_SLSH ,KC_MSTP
,KC_MINS,KC_DOWN,KC_RGHT ,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 ,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
,OSL(NMDIA),OSL(ARRW)
,OSL(NMDIA),M(OH_LEFT)
,KC_LEAD
,F(F_HUN) ,KC_ENT ,KC_SPC
),
@ -216,19 +216,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* ,-----------------------------------------------------. ,-----------------------------------------------------.
* | | | | | | | | | | | | | | | |
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
* | | | | | | | | | | | | | | | |
* | | | | | | | | | | | Home | Up | End | | |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | | | | | | |------| |------| | | | | | |
* | | | | | | |------| |------| | Left | Down | Rght | | |
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
* | | | | | | | | | | | | | | | |
* `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
* | | | Home | PgUp | | | | PgDn | End | | |
* | | | | | | | | | | | |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | | | | | |
* ,------|------|------| |------+------+------.
* | | | | | | | |
* | | |------| |------| | |
* | | |------| |------| PgUp | PgDn |
* | | | | | | | |
* `--------------------' `--------------------'
*/
@ -239,7 +239,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_TRNS ,KC_TRNS ,KC_HOME ,KC_PGUP ,KC_TRNS
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_TRNS ,KC_TRNS
,KC_TRNS
@ -247,14 +247,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// right hand
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_TRNS ,KC_TRNS ,KC_HOME ,KC_UP ,KC_END ,KC_TRNS ,KC_TRNS
,KC_TRNS ,KC_LEFT ,KC_DOWN ,KC_RGHT ,KC_TRNS ,KC_TRNS
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_TRNS ,KC_PGDN ,KC_END ,KC_TRNS ,KC_TRNS
,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_TRNS ,KC_TRNS
,KC_TRNS
,KC_TRNS ,KC_TRNS ,KC_TRNS
,KC_TRNS ,KC_PGUP ,KC_PGDN
),
/* Keymap 3: Application select layer
@ -843,8 +843,12 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
return MACRO_NONE;
};
uint8_t is_adore = 0;
// Runs just one time when the keyboard initializes.
void matrix_init_user(void) {
uint8_t dl;
ergodox_led_all_on();
for (int i = LED_BRIGHTNESS_HI; i > LED_BRIGHTNESS_LO; i--) {
ergodox_led_all_set (i);
@ -856,6 +860,12 @@ void matrix_init_user(void) {
_delay_ms (10);
}
ergodox_led_all_off();
if (!eeconfig_is_enabled())
eeconfig_init();
dl = eeconfig_read_default_layer ();
if (dl == (1UL << ADORE))
is_adore = 1;
};
LEADER_EXTERNS();
@ -882,7 +892,25 @@ void ang_tap (uint16_t codes[]) {
register_code (code); \
unregister_code (code)
uint8_t is_exp = 0;
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);
}
}
}
const qk_tap_dance_action_t tap_dance_actions[] = {
[CT_CLN] = ACTION_TAP_DANCE_FN (ang_tap_dance)
};
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {
@ -891,21 +919,6 @@ void matrix_scan_user(void) {
if (gui_timer && timer_elapsed (gui_timer) > TAPPING_TERM)
unregister_code (KC_LGUI);
if (ct_cln_timer && timer_elapsed (ct_cln_timer) > TAPPING_TERM) {
if (ct_cln_count == 1) {
register_code (KC_RSFT);
register_code (KC_SCLN);
unregister_code (KC_SCLN);
unregister_code (KC_RSFT);
} else if (ct_cln_count == 2) {
register_code (KC_SCLN);
unregister_code (KC_SCLN);
}
ct_cln_count = 0;
ct_cln_timer = 0;
}
if (layer != OHLFT)
oh_left_blink = 0;
if (layer != OHRGT)
@ -921,7 +934,7 @@ void matrix_scan_user(void) {
ergodox_right_led_1_on ();
ergodox_right_led_2_on ();
ergodox_right_led_3_on ();
} else if (layer == EXPRM) {
} else if (layer == ADORE) {
ergodox_right_led_1_on ();
ergodox_right_led_2_on ();
ergodox_right_led_3_on ();
@ -961,7 +974,7 @@ void matrix_scan_user(void) {
ergodox_right_led_1_on ();
} else {
ergodox_right_led_1_set (LED_BRIGHTNESS_LO);
if (layer != OHLFT && layer != NMDIA && layer != PLVR && layer != EXPRM)
if (layer != OHLFT && layer != NMDIA && layer != PLVR && layer != ADORE)
ergodox_right_led_1_off ();
}
@ -971,7 +984,7 @@ void matrix_scan_user(void) {
ergodox_right_led_2_on ();
} else {
ergodox_right_led_2_set (LED_BRIGHTNESS_LO);
if (layer != OHRGT && layer != HUN && layer != OHLFT && layer != NMDIA && layer != PLVR && layer != EXPRM)
if (layer != OHRGT && layer != HUN && layer != OHLFT && layer != NMDIA && layer != PLVR && layer != ADORE)
ergodox_right_led_2_off ();
}
@ -981,7 +994,7 @@ void matrix_scan_user(void) {
ergodox_right_led_3_on ();
} else {
ergodox_right_led_3_set (LED_BRIGHTNESS_LO);
if (layer != OHRGT && layer != HUN && layer != PLVR && layer != EXPRM)
if (layer != OHRGT && layer != HUN && layer != PLVR && layer != ADORE)
ergodox_right_led_3_off ();
}
@ -989,6 +1002,10 @@ void matrix_scan_user(void) {
leading = false;
leader_end ();
SEQ_ONE_KEY (KC_D) {
log_enable = !log_enable;
}
SEQ_ONE_KEY (KC_U) {
ang_do_unicode ();
}
@ -1036,11 +1053,12 @@ void matrix_scan_user(void) {
unregister_code (KC_LGUI);
}
SEQ_ONE_KEY (KC_E) {
if (is_exp == 0) {
SEQ_ONE_KEY (KC_A) {
if (is_adore == 0) {
default_layer_and (0);
default_layer_or ((1 << EXPRM));
is_exp = 1;
default_layer_or ((1UL << ADORE));
eeconfig_update_default_layer ((1UL << ADORE));
is_adore = 1;
ergodox_led_all_off ();
ergodox_right_led_3_on ();
@ -1054,9 +1072,10 @@ void matrix_scan_user(void) {
_delay_ms (100);
ergodox_right_led_1_off ();
} else {
is_exp = 0;
is_adore = 0;
default_layer_and (0);
default_layer_or (1 << BASE);
default_layer_or (1UL << BASE);
eeconfig_update_default_layer ((1UL << BASE));
ergodox_led_all_off ();
ergodox_right_led_1_on ();
@ -1075,29 +1094,11 @@ void matrix_scan_user(void) {
}
bool process_record_user (uint16_t keycode, keyrecord_t *record) {
switch(keycode) {
case CT_CLN:
if (record->event.pressed) {
ct_cln_count++;
ct_cln_timer = timer_read ();
} else {
}
return false;
break;
uint8_t layer = biton32(layer_state);
default:
if (ct_cln_count == 1) {
register_code (KC_RSFT);
register_code (KC_SCLN);
unregister_code (KC_SCLN);
unregister_code (KC_RSFT);
} else if (ct_cln_count == 2) {
register_code (KC_SCLN);
unregister_code (KC_SCLN);
}
ct_cln_count = 0;
ct_cln_timer = 0;
break;
if (log_enable && layer == BASE) {
xprintf ("KL: col=%d, row=%d\n", record->event.key.col,
record->event.key.row);
}
return true;

View File

@ -1,27 +1,28 @@
<!-- -*- mode: markdown; fill-column: 8192 -*- -->
algernon's layout
=======================
This is an unconventional layout for the ErgoDox EZ. For more details about the
history of the layout, see my
[blog posts about my ErgoDox journey][blog-ergodox].
This is an unconventional layout for the ErgoDox EZ. For more details about the history of the layout, see my [blog posts about my ErgoDox journey][blog-ergodox].
[blog-ergodox]: https://asylum.madhouse-project.org/blog/tags/ergodox/
Some of the things in the layout only work when one uses Spacemacs and GNOME
under Linux. Your mileage may vary.
Some of the things in the layout only work when one uses Spacemacs and GNOME under Linux. Your mileage may vary.
## Table of Contents
* [Layouts](#layouts)
- [Base layer](#base-layer)
- [Experimental layer](#experimental-layer)
- [Hungarian layer](#hungarian-layer)
- [Navigation and media layer](#navigation-and-media-layer)
- [One-handed layer](#one-handed-layer)
- [Steno layer](#steno-layer)
- [LED states](#led-states)
- [Base layer](#base-layer)
- [ADORE layer](#adore-layer)
- [Hungarian layer](#hungarian-layer)
- [Navigation and media layer](#navigation-and-media-layer)
- [One-handed layer](#one-handed-layer)
- [Steno layer](#steno-layer)
- [LED states](#led-states)
* [Tools](#tools)
- [Heatmap](#heatmap)
* [Building](#building)
- [Using on Windows](#using-on-windows)
- [Using on Windows](#using-on-windows)
* [Changelog](#changelog)
* [License](#license)
@ -31,133 +32,98 @@ under Linux. Your mileage may vary.
[![Base layer](images/base-layer.png)](http://www.keyboard-layout-editor.com/#/gists/28f7eb305fdbff943613e1dc7aa9e82b)
At its core, this is a Dvorak layout, with some minor changes. The more
interesting parts are how certain keys behave:
At its core, this is a Dvorak layout, with some minor changes. The more interesting parts are how certain keys behave:
* The keys on the number row double as function keys, when held for a bit longer
than an usual tap. This allows me to use the function keys without having to
switch layers.
* The `Shift`, `Alt`, and `Control` modifiers are one-shot. When tapped, they
are considered active for the next key press only. When double tapped, they
toggle on, until a third, single tap sometime later. When held, they act as
expected. My usual pattern is that I use these for the next keypress only, so
this behaviour is perfect. If I need them held, I'll just double-tap.
* The `GUI` key is special, because when I double-tap it, it sends `GUI + w`,
which pops up an application selector. It also switches to a one-shot layer,
where the number row on the left half turns into app selector macros, for the
most common things I usually want to switch to. Otherwise it behaves as on a
normal layout.
* The `ESC` key also doubles as a one-shot cancel key: if tapped while any of
the one-shot modifiers are in-flight (as in, single-tapped, and not expired
yet), it cancels all one-shot modifiers. It also cancels the **Hun** layer, if
active. Otherwise it sends the usual keycode.
* The **Media**, **Arrow**, and **Hun** layer keys are one-shot, the **1Hand**
and **STENO** keys are toggles.
* Toggling the **Arrow** layer toggles between the cursor arrows and the paging
keys on the bottom row.
* The keys on the number row double as function keys, when held for a bit longer than an usual tap. This allows me to use the function keys without having to switch layers.
* The `Shift`, `Alt`, and `Control` modifiers are one-shot. When tapped, they are considered active for the next key press only. When double tapped, they toggle on, until a third, single tap sometime later. When held, they act as expected. My usual pattern is that I use these for the next keypress only, so this behaviour is perfect. If I need them held, I'll just double-tap.
* The `GUI` key is special, because when I double-tap it, it sends `GUI + w`, which pops up an application selector. It also switches to a one-shot layer, where the number row on the left half turns into app selector macros, for the most common things I usually want to switch to. Otherwise it behaves as on a normal layout.
* The `ESC` key also doubles as a one-shot cancel key: if tapped while any of the one-shot modifiers are in-flight (as in, single-tapped, and not expired yet), it cancels all one-shot modifiers. It also cancels the **Hun** layer, if active. Otherwise it sends the usual keycode.
* The **Media** and **Hun** layer keys are one-shot, the **1Hand** and **STENO** keys are toggles.
* When holding any of the **Arrow** layer keys, the arrow layer activates while the layer key is held. Tapping the key produces the normal key.
* Tapping the `:` key once yields `:`, tapping it twice yields `;`.
* The **Lead** key allows me to type in a sequence of keys, and trigger some
actions:
- `LEAD u` enters unicode input mode, by sending the GTK+ key sequence that
does this.
* The **Lead** key allows me to type in a sequence of keys, and trigger some actions:
- `LEAD u` enters unicode input mode, by sending the GTK+ key sequence that does this.
- `LEAD l` uses the unicode input method to enter a `λ`.
- `LEAD s` does a lot of magic to type in a shruggie: `¯\_(ツ)_/¯`
- `LEAD y` types `\o/`.
- `LEAD w m` maximises the currently focused window.
- `LEAD e` makes the [experimental layer](#experimental-layer) the default.
- `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.
## Experimental layer
## ADORE layer
[![Experimental layer](images/experimental-layer.png)](http://www.keyboard-layout-editor.com/#/gists/6ff50bf71248e05aab5b3fec4fae3d08)
[![ADORE layer](images/adore-layer.png)](http://www.keyboard-layout-editor.com/#/gists/45681a17453d235925b6028dd83bf12a)
While using the standard Dvorak layout, I encountered a number of
inconveniences, and on this layer, I am playing with ideas to make the layout
feel better. Initially, it was based on [Capewell-Dvorak][cpd], but that too,
had shortcomings I was not happy with. So now this is something inbetween, with
own observations thrown in. How it works out in the long run remains to be seen.
While using the standard Dvorak layout, I encountered a number of inconveniences, and on this layer, I am playing with ideas to make the layout feel better. Initially, it was based on [Capewell-Dvorak][cpd], but that too, had shortcomings I was not happy with. So now this is something inbetween, with own observations thrown in. How it works out in the long run remains to be seen.
[cpd]: http://www.michaelcapewell.com/projects/keyboard/layout_capewell-dvorak.htm
Based on a week and a half of typing, the keys were rearranged, and the home row neatly spelled out **ADORE**, that gave the layout its name.
## Hungarian layer
[![Hungarian layer](images/hun-layer.png)](http://www.keyboard-layout-editor.com/#/gists/b160f6ec90d58c127c114c89f66e9dc9)
On this layer, the accented characters are at the same position as their base
variant. For some, which can have other diatribes, the long one is on top,
short's on bottom. Tapping any of the accented characters takes us back to the
base layer.
On this layer, the accented characters are at the same position as their base variant. For some, which can have other diatribes, the long one is on top, short's on bottom. Tapping any of the accented characters takes us back to the base layer.
## Navigation and media layer
[![Navigation and media layer](images/nav-n-media-layer.png)](http://www.keyboard-layout-editor.com/#/gists/c59c453f9fe1a3238ba1494e7e5c6892)
This layer is primarily for navigating with the cursor or the mouse, and some
media things.
This layer is primarily for navigating with the cursor or the mouse, and some media things.
## One-handed layer
[![One-handed layer](images/one-handed-layer.png)](http://www.keyboard-layout-editor.com/#/gists/edff2495135955b8963198dace7f7ece)
The one-handed layer is used in situations where the right hand is occupied, by
mousing around, for example. Tapping the `OTHER` key switches which side is
active. For the most part, keys remain in their usual position. When the right
half is active, keys are mirrored to the left half.
The one-handed layer is used in situations where the right hand is occupied, by mousing around, for example. Tapping the `OTHER` key switches which side is active. For the most part, keys remain in their usual position. When the right half is active, keys are mirrored to the left half.
The differences are as follows:
* The `ESC` key has been moved to the bottom row, so the `OTHER` key is easier
to tap.
* Most keys on the thumb cluster now have dual uses, and these do not change
when switching sides:
- The `Space`/`Backspace` key sends `Space` on tap, `Backspace` when held
for longer than a normal tap.
* The `ESC` key has been moved to the bottom row, so the `OTHER` key is easier to tap.
* Most keys on the thumb cluster now have dual uses, and these do not change when switching sides:
- The `Space`/`Backspace` key sends `Space` on tap, `Backspace` when held for longer than a normal tap.
- The `Enter`/`Shift` key sends `Enter` on short-tap, `Shift` on long-tap.
* The `Apps`/`BASE` key can be used to go back to the base layer, by
long-tapping it. A short-tap will send the `App` key, as usual.
* The `Apps`/`BASE` key can be used to go back to the base layer, by long-tapping it. A short-tap will send the `App` key, as usual.
## Steno layer
[![Steno layer for Plover](images/steno-layer.png)](http://www.keyboard-layout-editor.com/#/gists/401ef9a84369e47c57f9aedcf0a0d667)
This is to be used with [Plover](http://www.openstenoproject.org/plover/),
nothing really fancy here. The **STENO** key toggles the layer on and off, and
sends the toggle command to Plover too.
This is to be used with [Plover](http://www.openstenoproject.org/plover/), nothing really fancy here. The **STENO** key toggles the layer on and off, and sends the toggle command to Plover too.
## LED states
The primary purpose of the LEDs is to show the modifier status, a secondary, to
show which layer is active. Each modifier, `Shift`, `Alt` and `Control` each
have their designated LEDs: the *red*, *green* and *blue*, respectively. When a
modifier is in a one-shot state, the respective LED will turn on with a dimmer
light. If the modifier is toggled on, the brightness of the LED turns full.
The primary purpose of the LEDs is to show the modifier status, a secondary, to show which layer is active. Each modifier, `Shift`, `Alt` and `Control` each have their designated LEDs: the *red*, *green* and *blue*, respectively. When a modifier is in a one-shot state, the respective LED will turn on with a dimmer light. If the modifier is toggled on, the brightness of the LED turns full.
For the layers, the following rules apply:
* When the [Experimental layer](#experimental-layer) is toggled on, LEDs will
light up from left to right in a sequence, then turn off. When the layer is
toggled off, the LEDs light up and turn off in the other direction. No LEDs
are on while the layer is active.
* When the [Hungarian layer](#hungarian-layer) is active, the *green* and *blue*
LEDs are on.
* When the [Navigation and media layer](#navigation-and-media-layer) is active,
the *red* and *green* ones are on.
* When the [One-handed layer](#one-handed-layer) is active, the *green* LED is
on and bright, and either the *red* or the *blue* one is going to slowly
blink, depending on the currently active side.
* When the [ADORE layer](#adore-layer) is toggled on, LEDs will light up from left to right in a sequence, then turn off. When the layer is toggled off, the LEDs light up and turn off in the other direction. No LEDs are on while the layer is active.
* When the [Hungarian layer](#hungarian-layer) is active, the *green* and *blue* LEDs are on.
* When the [Navigation and media layer](#navigation-and-media-layer) is active, the *red* and *green* ones are on.
* When the [One-handed layer](#one-handed-layer) is active, the *green* LED is on and bright, and either the *red* or the *blue* one is going to slowly blink, depending on the currently active side.
* For the [Steno layer](#steno-layer), all LEDs will be turned on.
Unless noted otherwise, the layers use a dim light for the LEDs, while modifiers
use a stronger one, and modifiers override any layer preferences. For example,
when on the one-handed layer, with the left side active (*red* light blinking),
if `Shift` is on, the *red* light will be constantly on.
Unless noted otherwise, the layers use a dim light for the LEDs, while modifiers use a stronger one, and modifiers override any layer preferences. For example, when on the one-handed layer, with the left side active (*red* light blinking), if `Shift` is on, the *red* light will be constantly on.
# Tools
## Heatmap
When the keypress logging functionality is enabled (by `LEAD d`), the keyboard will output a line every time a key is pressed, containing the position of the key in the matrix. This allows one to collect this information, and build analytics over it, such as a heat map, including dead keys too.
Included with the firmware is a small tool that can parse these logs, and create a heatmap that one can import into [KLE][kle]. To use it, simply point `tools/log-to-heatmap.py` to a base layout file (one is included in the `tools/` directory), and the key position log. The latter one can create by running `hid-listen`, and redirecting its output to a file.
[kle]: http://www.keyboard-layout-editor.com/
The generated heatmap looks somewhat like this:
![Heatmap](images/heatmap.png)
# Building
To make my workflow easier, this layout is maintained in
[its own repository][algernon:ez-layout]. To build it, you will need the
[QMK][qmk] firmware checked out, and this repo either checked out to something
like `keyboards/ergodox_ez/algernon-master`. One way to achieve that is this:
To make my workflow easier, this layout is maintained in [its own repository][algernon:ez-layout]. To build it, you will need the [QMK][qmk] firmware checked out, and this repo either checked out to something like `keyboards/ergodox_ez/algernon-master`. One way to achieve that is this:
[algernon:ez-layout]: https://github.com/algernon/ergodox-layout
[qmk]: https://github.com/jackhumbert/qmk_firmware
@ -170,9 +136,7 @@ $ git clone https://github.com/algernon/ergodox-layout.git \
$ make KEYBOARD=ergodox_ez KEYMAP=algernon-master
```
From time to time, updates may be submitted back to the QMK repository. If you
are reading it there, you can build the firmware like any other firmware
included with it (assuming you are in the root directory of the firmware):
From time to time, updates may be submitted back to the QMK repository. If you are reading it there, you can build the firmware like any other firmware included with it (assuming you are in the root directory of the firmware):
```
$ make KEYBOARD=ergodox_ez KEYMAP=algernon
@ -180,43 +144,40 @@ $ make KEYBOARD=ergodox_ez KEYMAP=algernon
## Using on Windows
The keymap default to forcing NKRO, which seems to upset Windows, and except the
modifiers, none of them work. If you experience this problem, recompile the
firmware with `FORCE_NKRO=no` added to the `make` command line.
The keymap default to forcing NKRO, which seems to upset Windows, and except the modifiers, none of them work. If you experience this problem, recompile the firmware with `FORCE_NKRO=no` added to the `make` command line.
# Changelog
## 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.
* The arrow and navigation keys were rearranged again, and now require an additional key being held to activate. See the [base layer](#base-layer) for an image that shows where arrows are.
* The **experimental** layer has been redone, and is now called [ADORE](#adore-layer), and as such, can be enabled by `LEAD a` now.
* Switching between Dvorak and ADORE is now persisted into EEPROM, and survives a reboot.
## v1.2 - 2016-06-22
* The forced NKRO mode can be easily toggled off at compile-time, to make the
firmware compatible with [certain operating systems](#using-on-windows).
* The `:;` key has changed behaviour: to access the `;` symbol, the key needs to
be double-tapped, instead of shifted.
* The `=` and `\` keys were swapped, `=` moved to the home row, on both the
[base](#base-layer) and the [experimental](#experimental-layer) layers.
* The arrow and navigation keys were redone, they are now more accessible, but
the navigation keys require an extra tap to access.
* The **Emacs** layer is gone, replaced by a simplified
[navigation and media](#navigation-and-media-layer) layer.
* The forced NKRO mode can be easily toggled off at compile-time, to make the firmware compatible with [certain operating systems](#using-on-windows).
* The `:;` key has changed behaviour: to access the `;` symbol, the key needs to be double-tapped, instead of shifted.
* The `=` and `\` keys were swapped, `=` moved to the home row, on both the [base](#base-layer) and the **experimental** layers.
* The arrow and navigation keys were redone, they are now more accessible, but the navigation keys require an extra tap to access.
* The **Emacs** layer is gone, replaced by a simplified [navigation and media](#navigation-and-media-layer) layer.
* `LEAD v` types the firmware version, and the keymap version.
* On the [experimental](#experimental-layer) layer, the `L` and `Q`, and the `K`
and `G` keys were swapped.
* The [Steno](#steno-layer) layer gained a few more `#` and `*` keys, to make it
easier on my fingers.
* On the **experimental** layer, the `L` and `Q`, and the `K` and `G` keys were swapped.
* The [Steno](#steno-layer) layer gained a few more `#` and `*` keys, to make it easier on my fingers.
## v1.1 - 2016-06-14
* The keyboard starts in NKRO mode, bootmagic and other things are disabled.
* A [Steno](#steno-layer) layer was added, to be used with Plover.
* An [experimental](#experimental-layer) layer was added, something halfway
between Dvorak and Capewell-Dvorak. A work in progress.
* An **experimental** layer was added, something halfway between Dvorak and Capewell-Dvorak. A work in progress.
* `LEAD y` types `\o/`.
* Some keys on the [Base](#base-layer) layer have been moved around:
- `?` moved to the left pinky, left of `Q`.
- `=` shifted one row down, but `F11` stayed where it was.
- `-` on the left half was replaced by `Tab`.
- `Tab`'s original position is taken by a `Media Next`/`Media Prev` key.
- `:` now inputs `;` when shifted.
- `?` moved to the left pinky, left of `Q`.
- `=` shifted one row down, but `F11` stayed where it was.
- `-` on the left half was replaced by `Tab`.
- `Tab`'s original position is taken by a `Media Next`/`Media Prev` key.
- `:` now inputs `;` when shifted.
* `ESC` cancels the [Hungarian](#hungarian-layer) layer too, not just modifiers.
## v1.0 - 2016-05-26
@ -225,6 +186,4 @@ Initial version.
# License
The layout, being a derivative of the original TMK firmware which is under the
GPL-2+, this layout is under the GPL as well, but GPL-3+, rather than the older
version.
The layout, being a derivative of the original TMK firmware which is under the GPL-2+, this layout is under the GPL as well, but GPL-3+, rather than the older version.

View File

@ -0,0 +1,533 @@
[
{
"backcolor": "#ffffff",
"name": "ErgoDox - algernon's layout: Heatmap",
"author": "Gergely Nagy <kbd@gergo.csillger.hu>",
"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
},
"<i class='mss mss-Unicode-Option-3'></i>",
{
"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": 4
},
">\n.",
{
"x": 10.5,
"a": 6
},
"C"
],
[
{
"y": -0.875,
"x": 2.5,
"c": "#bfbad1",
"t": "#0d0d0b",
"a": 4
},
"<\n,",
{
"x": 1,
"c": "#7adabd",
"t": "#000000",
"a": 6
},
"P",
{
"x": 8.5
},
"G",
{
"x": 1,
"c": "#bfbad1",
"t": "#0d0d0b"
},
"R"
],
[
{
"y": -0.875,
"x": 5.5,
"c": "#7adabd",
"t": "#000000"
},
"Y",
{
"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
},
"<i class='fa fa-fast-backward'></i>\n\n<i class='fa fa-fast-forward'></i>",
{
"c": "#ffb2d2",
"a": 4,
"f": 3
},
"\"\n'",
{
"x": 14.5,
"a": 6
},
"L",
{
"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
},
"U",
{
"x": 8.5,
"n": true
},
"H",
{
"x": 1,
"c": "#bfbad1",
"t": "#0d0d0b"
},
"N"
],
[
{
"y": -0.875,
"x": 5.5,
"c": "#7adabd",
"t": "#000000"
},
"I",
{
"x": 6.5
},
"D"
],
[
{
"y": -0.875,
"c": "#ffb2d2",
"t": "#0d0d0b",
"fa": [
6
],
"w": 1.5
},
"<i class='fa fa-arrows'></i>\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": 6
},
"J",
{
"x": 10.5
},
"W"
],
[
{
"y": -0.875,
"x": 2.5,
"c": "#bfbad1",
"t": "#0d0d0b"
},
"Q",
{
"x": 1,
"c": "#7adabd",
"t": "#000000"
},
"K",
{
"x": 8.5
},
"M",
{
"x": 1,
"c": "#bfbad1",
"t": "#0d0d0b"
},
"V"
],
[
{
"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<i class='kb kb-Multimedia-Play-Pause'></i>",
{
"c": "#ffb2d2",
"t": "#0d0d0b",
"a": 4,
"f": 3
},
"?\n/",
{
"x": 14.5,
"a": 6
},
"Z",
{
"c": "#ffb07b",
"t": "#000000",
"f": 9,
"w": 1.5
},
"<i class='kb kb-Multimedia-Stop'></i>"
],
[
{
"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<i class='kb kb-logo-linux-debian fa-large'></i>"
],
[
{
"c": "#d4872a",
"a": 7,
"f": 9,
"h": 2
},
"<i class='kb kb-Unicode-BackSpace-DeleteLeft-Big'></i>",
{
"h": 2
},
"<i class='fa fa-angle-double-up'></i>",
{
"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
},
"<i class='kb kb-Return-2'></i>",
{
"f": 3,
"h": 2
},
"SPC"
],
[
{
"x": -3,
"c": "#f9cd31",
"f": 2
},
"HUN"
]
]

View File

@ -0,0 +1,145 @@
#! /usr/bin/env python
import json
import os
import sys
import re
from math import floor
cr_coord_map = [
[
# Row 0
[ 4, 0], [ 4, 2], [ 2, 0], [ 1, 0], [ 2, 2], [ 3, 0], [ 3, 2],
[ 3, 4], [ 3, 6], [ 2, 4], [ 1, 2], [ 2, 6], [ 4, 4], [ 4, 6],
],
[
# Row 1
[ 8, 0], [ 8, 2], [ 6, 0], [ 5, 0], [ 6, 2], [ 7, 0], [ 7, 2],
[ 7, 4], [ 7, 6], [ 6, 4], [ 5, 2], [ 6, 6], [ 8, 4], [ 8, 6],
],
[
# Row 2
[12, 0], [12, 2], [10, 0], [ 9, 0], [10, 2], [11, 0], [ ],
[ ], [11, 2], [10, 4], [ 9, 2], [10, 6], [12, 4], [12, 6],
],
[
# Row 3
[17, 0], [17, 2], [15, 0], [14, 0], [15, 2], [16, 0], [13, 0],
[13, 2], [16, 2], [15, 4], [14, 2], [15, 6], [17, 4], [17, 6],
],
[
# Row 4
[20, 0], [20, 2], [19, 0], [18, 0], [19, 2], [], [], [], [],
[19, 4], [18, 2], [19, 6], [20, 4], [20, 6],
],
[
# Row 5
[ ], [23, 0], [22, 2], [22, 0], [22, 4], [21, 0], [21, 2],
[24, 0], [24, 2], [25, 0], [25, 4], [25, 2], [26, 0], [ ],
],
]
def set_attr_at(j, b, n, attr, fn, val):
blk = j[b][n]
if attr in blk:
blk[attr] = fn(blk[attr], val)
else:
blk[attr] = fn(None, val)
def coord(col, row):
return cr_coord_map[row][col]
def set_attr(orig, new):
return new
def set_bg(j, (b, n), color):
set_attr_at(j, b, n, "c", set_attr, color)
#set_attr_at(j, b, n, "g", set_attr, False)
def _set_tap_info(o, count, cap):
ns = 4 - o.count ("\n")
return o + "\n" * ns + "%.02f%%" % (float(count) / float(cap) * 100)
def set_tap_info(j, (b, n), count, cap):
j[b][n + 1] = _set_tap_info (j[b][n + 1], count, cap)
def heatmap_color (v):
colors = [ [0.3, 0.3, 1], [0.3, 1, 0.3], [1, 1, 0.3], [1, 0.3, 0.3]]
fb = 0
if v <= 0:
idx1, idx2 = 0, 0
elif v >= 1:
idx1, idx2 = len(colors) - 1, len(colors) - 1
else:
val = v * (len(colors) - 1)
idx1 = int(floor(val))
idx2 = idx1 + 1
fb = val - float(idx1)
r = (colors[idx2][0] - colors[idx1][0]) * fb + colors[idx1][0]
g = (colors[idx2][1] - colors[idx1][1]) * fb + colors[idx1][1]
b = (colors[idx2][2] - colors[idx1][2]) * fb + colors[idx1][2]
r, g, b = [x * 255 for x in r, g, b]
return "#%02x%02x%02x" % (r, g, b)
# Load the keylog
def load_keylog(fname, restrict_row):
keylog = {}
total = 0
with open(fname, "r") as f:
lines = f.readlines()
for line in lines:
m = re.search ('KL: col=(\d+), row=(\d+)', line)
if not m:
continue
(c, r) = (int(m.group (2)), int(m.group (1)))
if restrict_row != None and r != int(restrict_row):
continue
if (c, r) in keylog:
keylog[(c, r)] = keylog[(c, r)] + 1
else:
keylog[(c, r)] = 1
total = total + 1
return total / 2, keylog
def l_flat(s):
f = s.split("\n")
return ", ".join (f)
def main(base_fn, log_fn, restrict_row = None):
with open(base_fn, "r") as f:
layout = json.load (f)
## Reset colors
for row in cr_coord_map:
for col in row:
if col != []:
set_bg (layout, col, "#d9dae0")
#set_attr_at (layout, col[0], col[1], "g", set_attr, True)
total, log = load_keylog (log_fn, restrict_row)
max_cnt = 0
for (c, r) in log:
max_cnt = max(max_cnt, log[(c, r)])
# Create the heatmap
for (c, r) in log:
coords = coord(c, r)
b, n = coords
cap = max_cnt
v = float(log[(c, r)]) / cap
print >> sys.stderr, "%s => %d/%d => %f = %s" % (l_flat(layout[b][n+1]), log[(c,r)], cap, v, heatmap_color(v))
set_bg (layout, coord(c, r), heatmap_color (v))
set_tap_info (layout, coord (c, r), log[(c, r)], total)
print json.dumps(layout)
if __name__ == "__main__":
if len(sys.argv) < 3:
print """Log to Heatmap -- creates a heatmap out of keyboard logs
Usage: log-to-heatmap.py base-layout.json logfile [row] >layout.json"""
sys.exit (1)
main(*sys.argv[1:])