aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbendk <ben@pculture.org>2019-01-17 02:16:18 -0500
committerDrashna Jaelre <drashna@live.com>2019-01-16 23:16:18 -0800
commitf97894d8dba1d20693e71289d284a03335507bd2 (patch)
tree091afdaf0f039eb3e69a537a5b3b2b2a67adaa99
parente48cb34de675b6ed1f82d565c8f9b41d6a3245a1 (diff)
downloadqmk_firmware-f97894d8dba1d20693e71289d284a03335507bd2.tar.gz
qmk_firmware-f97894d8dba1d20693e71289d284a03335507bd2.zip
[Keymap] Adding bdk keymap for ergobox_ez (#4850)
* Adding bdk keymap * Updating keymap after review from drashna
-rw-r--r--keyboards/ergodox_ez/keymaps/bdk/config.h5
-rw-r--r--keyboards/ergodox_ez/keymaps/bdk/keymap.c176
-rw-r--r--keyboards/ergodox_ez/keymaps/bdk/readme.md36
-rw-r--r--keyboards/ergodox_ez/keymaps/bdk/rules.mk3
4 files changed, 220 insertions, 0 deletions
diff --git a/keyboards/ergodox_ez/keymaps/bdk/config.h b/keyboards/ergodox_ez/keymaps/bdk/config.h
new file mode 100644
index 000000000..e824b7310
--- /dev/null
+++ b/keyboards/ergodox_ez/keymaps/bdk/config.h
@@ -0,0 +1,5 @@
1#pragma once
2
3#define ONESHOT_TAP_TOGGLE 2
4#define ONESHOT_TIMEOUT 167
5#define FORCE_NKRO
diff --git a/keyboards/ergodox_ez/keymaps/bdk/keymap.c b/keyboards/ergodox_ez/keymaps/bdk/keymap.c
new file mode 100644
index 000000000..20af6c18e
--- /dev/null
+++ b/keyboards/ergodox_ez/keymaps/bdk/keymap.c
@@ -0,0 +1,176 @@
1#include QMK_KEYBOARD_H
2
3#define SHIFT_DOWN() (get_mods() & (MOD_BIT(KC_LSFT)|MOD_BIT(KC_RSFT)))
4#define KC_FKEYS MO(FKEYS)
5
6// Layers
7enum {
8 BASE=0,
9 SYMNUM, // Symbols and numbers (activated by holding enter)
10 FKEYS, // Function keys (activated by a thumb button)
11};
12
13// counter that increments on all key press events. This is needed for our LT
14// handling
15uint16_t press_counter = 0;
16
17const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
18
19// Keymap 0: Base layer
20
21[BASE] = LAYOUT_ergodox(
22 // left hand ---------------------------------------------------------------------------------------------------
23 KC_NO, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_NO,
24 KC_GRV, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_LGUI,
25 KC_SLSH, KC_A, KC_O, KC_E, KC_U, KC_I,
26 KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_HOME,
27 KC_LCTL, KC_LALT, KC_PGUP, KC_PGDN, KC_NO,
28 // left thumb --------------------------------------------------------------------------------------------------
29 KC_NO, KC_NO,
30 KC_NO,
31 KC_SPC, KC_TAB, KC_FKEYS,
32 // right hand --------------------------------------------------------------------------------------------------
33 KC_NO, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_NO,
34 KC_RGUI, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSLS,
35 KC_D, KC_H, KC_T, KC_N, KC_S, KC_MINS,
36 KC_END, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_RSFT,
37 KC_LEFT, KC_UP, KC_DOWN, KC_RIGHT, KC_RCTL,
38 // right thumb -------------------------------------------------------------------------------------------------
39 KC_NO, KC_NO,
40 KC_NO,
41 KC_DEL, KC_BSPC, KC_ENT
42),
43// SYMNUM -- numpad and function keys
44[SYMNUM] = LAYOUT_ergodox(
45 // left hand ---------------------------------------------------------------------------------------------------
46 KC_TRNS, LALT(KC_1), LALT(KC_2), LALT(KC_3), LALT(KC_4), LALT(KC_5), KC_TRNS,
47 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_AMPR, KC_TRNS, KC_TRNS,
48 KC_TRNS, KC_LCBR, KC_LBRC, KC_LPRN, KC_0, KC_MINS,
49 KC_TRNS, KC_6, KC_7, KC_8, KC_9, KC_SLSH, KC_TRNS,
50 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
51 // left thumb --------------------------------------------------------------------------------------------------
52 KC_TRNS, KC_TRNS,
53 KC_TRNS,
54 KC_TRNS, KC_TRNS, KC_TRNS,
55 // right hand --------------------------------------------------------------------------------------------------
56 KC_TRNS, LALT(KC_6), LALT(KC_7), LALT(KC_8), LALT(KC_9), LALT(KC_0), KC_TRNS,
57 KC_TRNS, KC_PERC, KC_EQL, KC_LT, KC_GT, KC_EXLM, KC_TRNS,
58 KC_PLUS, KC_1, KC_RPRN, KC_RBRC, KC_RCBR, KC_TRNS,
59 KC_TRNS, KC_ASTR, KC_2, KC_3, KC_4, KC_5, KC_TRNS,
60 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
61 // right thumb -------------------------------------------------------------------------------------------------
62 KC_TRNS, KC_TRNS,
63 KC_TRNS,
64 KC_TRNS, KC_TRNS, KC_TRNS
65),
66// FKEYS -- function keys
67[FKEYS] = LAYOUT_ergodox(
68 // left hand ---------------------------------------------------------------------------------------------------
69 KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6,
70 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
71 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
72 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
73 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
74 // left thumb --------------------------------------------------------------------------------------------------
75 KC_TRNS, KC_TRNS,
76 KC_TRNS,
77 KC_TRNS, KC_TRNS, KC_TRNS,
78 // right hand --------------------------------------------------------------------------------------------------
79 KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS,
80 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
81 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
82 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
83 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
84 // right thumb -------------------------------------------------------------------------------------------------
85 KC_TRNS, KC_TRNS,
86 KC_TRNS,
87 KC_TRNS, KC_TRNS, KC_TRNS
88),
89};
90
91// Code to handle layer tap.
92//
93// The default code doesn't work for me, so I rolled my own code. The main
94// difference is that it always tries to send modifier+key combination, rather
95// than two keys. One place where this is noticable is if you tap the key,
96// then try hold it.
97
98struct tap_start_info {
99 uint16_t timer;
100 uint16_t initial_press_counter;
101};
102
103static struct tap_start_info tap_start_infos[5];
104
105// Quick check to see if a key is down. Note that this requires NKRO enabled
106static bool key_down(uint8_t code) {
107 return (keyboard_report->nkro.bits[code>>3] & 1<<(code&7)) != 0;
108}
109
110static bool handle_lt(uint16_t keycode, keyrecord_t *record, uint8_t layer, uint8_t index) {
111 struct tap_start_info* tap_start = tap_start_infos + index;
112
113 if(record->event.pressed) {
114 layer_on(layer);
115 tap_start->timer = timer_read();
116 tap_start->initial_press_counter = press_counter;
117 } else {
118 layer_off(layer);
119 // Only click the key if:
120 // - No other keys are pressed between the press and release events
121 // - The release happens before the ONESHOT_TIMEOUT
122 if(press_counter == tap_start->initial_press_counter && timer_elapsed(tap_start->timer) < ONESHOT_TIMEOUT) {
123 register_code16(keycode);
124 unregister_code16(keycode);
125 }
126 }
127 return false;
128}
129
130static bool handle_mt(uint16_t keycode, keyrecord_t *record, uint8_t mods, uint8_t index) {
131 struct tap_start_info* tap_start = tap_start_infos + index;
132
133 if(record->event.pressed) {
134 register_mods(mods);
135 tap_start->timer = timer_read();
136 tap_start->initial_press_counter = press_counter;
137 } else {
138 unregister_mods(mods);
139 // Only click the key if:
140 // - No other keys are pressed between the press and release events
141 // - The release happens before the ONESHOT_TIMEOUT
142 if(press_counter == tap_start->initial_press_counter && timer_elapsed(tap_start->timer) < ONESHOT_TIMEOUT) {
143 register_code16(keycode);
144 unregister_code16(keycode);
145 }
146 }
147 return false;
148}
149
150bool process_record_user(uint16_t keycode, keyrecord_t *record) {
151 if(record->event.pressed) {
152 press_counter++;
153 // The symbol layer allows sequences repeat the same "physical" key.
154 // For example "0)", which is like pressing the "0" key twice in a
155 // row. It's very easy to make a sequence of these where the ")"
156 // press comes before the "0" release. If that happens, force a
157 // release of the "0" key, otherwise nothing will happen.
158 uint8_t shortcode = keycode & 0xFF;
159 if(key_down(shortcode)) {
160 unregister_code(shortcode);
161 }
162 }
163
164 switch(keycode) {
165 case KC_ENTER:
166 return handle_lt(keycode, record, SYMNUM, 0);
167
168 case KC_TAB:
169 return handle_mt(keycode, record, MOD_BIT(KC_LCTL), 1);
170
171 case KC_LSFT:
172 case KC_RSFT:
173 return handle_mt(KC_ESC, record, MOD_BIT(keycode), 2);
174 }
175 return true;
176}
diff --git a/keyboards/ergodox_ez/keymaps/bdk/readme.md b/keyboards/ergodox_ez/keymaps/bdk/readme.md
new file mode 100644
index 000000000..36a211d32
--- /dev/null
+++ b/keyboards/ergodox_ez/keymaps/bdk/readme.md
@@ -0,0 +1,36 @@
1# The BDK Ergodox Keyboard Layout
2
3## Dvorak-based
4
5This was the first alternative layout I switched to and I don't want to change
6again.
7
8## Mod-tap / Layer-tap is great for thumb keys
9
10This means a key that activates a layer/modifier when you hold it down, but
11results in a keyclick when you tap it. Thumb keys are great for this since
12they are good for both high-usage keys as well as modifiers.
13
14The one thing to avoid is when you mean to tap a key, but hit the next key
15before you release, which results in the modifier/layer instead of a tap. To
16avoid this, I chose Enter/Tab as the tap keys, since they aren't chorded
17together with other keys often.
18
19The other issue is I found several problems with using the standard MT,LT code,
20so I rolled my own to handle it.
21
22## Don't have too many layers
23
24My first layouts had multiple layers that I could switch to, but that
25overloaded my brain. This layout basically only uses 1 extra layer.
26Technically there's also a function key layer, but I only use those keys for
27a handlful of things: boot order, rename, reload page, that's basically it.
28
29## Brackets should be easy to use
30
31There's a lot of ways to lay out a symbol layer. I organized mine around
32making the {[()]} chars easy to use since they're so frequent in programming.
33I put them all on the symbol layer home row.
34
35I also arranged the numbers so 0/1 were also on the symbol layer home row.
36This makes for fairly easy chording of "[0]" and "[1]".
diff --git a/keyboards/ergodox_ez/keymaps/bdk/rules.mk b/keyboards/ergodox_ez/keymaps/bdk/rules.mk
new file mode 100644
index 000000000..6c5163623
--- /dev/null
+++ b/keyboards/ergodox_ez/keymaps/bdk/rules.mk
@@ -0,0 +1,3 @@
1# CONSOLE_ENABLE = yes
2# DEBUG_ENABLE = yes
3COMMAND_ENABLE = no