aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzunger-humu <zunger@humu.com>2019-01-25 09:46:49 -0800
committerDrashna Jaelre <drashna@live.com>2019-01-25 09:46:49 -0800
commit0ba9620d6541e5ade89271eccc7371d5a8a3ad15 (patch)
treeb1db0bb9a486f672194aa7ddc8fc89d3f2000b1b
parent4d8eefc694a9c45a6acf616ecad0b4d42db7a02e (diff)
downloadqmk_firmware-0ba9620d6541e5ade89271eccc7371d5a8a3ad15.tar.gz
qmk_firmware-0ba9620d6541e5ade89271eccc7371d5a8a3ad15.zip
[Keymap] New kbd67/hotswap keymap for writing both code and math (#4933)
* Custom keymap. * Fix magic layer, enable Unicode. * Update README. * Make Unicode config change keymap-local. * Move magic to AltGr, simplifying layout. * Changes per Drashna. * Fix magic+esc = backtick! * Change reset implementation per Drashna's suggestion. * Add a few more symbols so long as the commit is open - √ℜℂℤ⊙ℚℕ and the like. * Typo fix. * Slight simplification, drop an extra variable.
-rw-r--r--keyboards/kbd67/hotswap/keymaps/zunger/config.h22
-rw-r--r--keyboards/kbd67/hotswap/keymaps/zunger/keymap.c176
-rw-r--r--keyboards/kbd67/hotswap/keymaps/zunger/readme.md27
-rw-r--r--keyboards/kbd67/hotswap/keymaps/zunger/rules.mk2
4 files changed, 227 insertions, 0 deletions
diff --git a/keyboards/kbd67/hotswap/keymaps/zunger/config.h b/keyboards/kbd67/hotswap/keymaps/zunger/config.h
new file mode 100644
index 000000000..cc06440e0
--- /dev/null
+++ b/keyboards/kbd67/hotswap/keymaps/zunger/config.h
@@ -0,0 +1,22 @@
1/* Copyright 2018 MechMerlin
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19// Enable cmd-option-escape on mac.
20#define GRAVE_ESC_ALT_OVERRIDE
21
22// place overrides here
diff --git a/keyboards/kbd67/hotswap/keymaps/zunger/keymap.c b/keyboards/kbd67/hotswap/keymaps/zunger/keymap.c
new file mode 100644
index 000000000..0d542bf84
--- /dev/null
+++ b/keyboards/kbd67/hotswap/keymaps/zunger/keymap.c
@@ -0,0 +1,176 @@
1/* Copyright 2019 Yonatan Zunger
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include QMK_KEYBOARD_H
17
18enum custom_keycodes {
19 // Use this instead of RALT, so we can use it to switch layers but not trigger other alt-related
20 // behavior (like GRAVE_ESC_ALT_OVERRIDE).
21 MAGIC = SAFE_RANGE,
22};
23
24enum layers_keymap {
25 _QWERTY = 0,
26 _FUNCTION,
27
28 _MAGIC,
29 _SHIFTMAGIC,
30};
31
32// This is so that H(xxxx) has the same width as _______, which makes the grids more legible.
33#define H(x) UC(0x##x)
34
35
36const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
37/* Keymap (Base Layer) Default Layer
38 * ,----------------------------------------------------------------.
39 * |Esc | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Del|Brk|Home|
40 * |----------------------------------------------------------------|
41 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ |End |
42 * |----------------------------------------------------------------|
43 * |Ctrl | A| S| D| F| G| H| J| K| L| ;| '|Return |PgUp|
44 * |----------------------------------------------------------------|
45 * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | Up|PgDn|
46 * |----------------------------------------------------------------|
47 * |Ctrl|Alt |Win | Space |Alt| FN |||||Lef|Dow|Rig |
48 * `----------------------------------------------------------------'
49 */
50[_QWERTY] = LAYOUT(
51 KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_BRK, KC_HOME, \
52 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_END, \
53 KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, \
54 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN, \
55 KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, MAGIC, MO(_FUNCTION), KC_LEFT, KC_DOWN, KC_RGHT),
56
57 /* Keymap Fn Layer. Blank keys are deliberately NO, not TRNS.
58 * ,----------------------------------------------------------------.
59 * |Rst |F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|F13|PSc|PAUS|
60 * |----------------------------------------------------------------|
61 * |Debug| | | | | | | | | | | | | | |
62 * |----------------------------------------------------------------|
63 * |Ctrl | |Vo+| | | | | | | | | | | |
64 * |----------------------------------------------------------------|
65 * |Shift |REV|Vo-|FWD| | | | | | | | McL|MsU|McR |
66 * |----------------------------------------------------------------|
67 * |Ctrl|Alt |Win | |Alt| |||||MsL|MsD|MsR |
68 * `----------------------------------------------------------------'
69 */
70[_FUNCTION] = LAYOUT(
71 RESET, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_F13, KC_PSCR, KC_MPLY, \
72 DEBUG, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, _______, \
73 _______, KC_NO, KC__VOLUP, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
74 _______, KC_MRWD, KC__VOLDOWN, KC_MFFD, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_BTN1, KC_MS_U, KC_BTN2, \
75 _______, _______, _______, KC_NO, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R),
76
77 /* Mathematical lower layer. Blank keys are TRNS.
78 * Note that escape turns into grave here. This doesn't just generalize GRAVE_ESC; it means that
79 * magic+esc is a way to create backticks without a dedicated key.
80 * ,----------------------------------------------------------------.
81 * | ` | ¹| ² | ³ | ⁴ | ⁵ | ⁶ | ⁷ | ⁸ | ⁹ | ⁰ | ⁻ | ⁺ | ⊕ | ≠ | √ |
82 * |----------------------------------------------------------------|
83 * | | ± | ω | ε | ρ | τ | θ | υ | ι | ο | π | ∃ | ∀ | ℚ | ℝ |
84 * |----------------------------------------------------------------|
85 * | | α | σ | δ | φ | γ | η | ∅ | κ | λ | ∨ | ∧ | | ℕ |
86 * |----------------------------------------------------------------|
87 * | | ζ | ξ | χ | ψ | β | ν | μ | ≲ | ≳ | ∈ | | ↑ | ↔ |
88 * |----------------------------------------------------------------|
89 * | | | | | | ||||| ← | ↓ | → |
90 * `----------------------------------------------------------------'
91 */
92[_MAGIC] = LAYOUT(
93 KC_GRV, H(00b9), H(00b2), H(00b3), H(2074), H(2075), H(2076), H(2077), H(2078), H(2079), H(2070), H(207b), H(207a), H(2295), H(2260), H(221a), \
94 _______, H(00b1), H(03c9), H(03b5), H(03c1), H(03c4), H(03b8), H(03c5), H(03b9), H(03bf), H(03c0), H(2203), H(2200), H(211a), H(211d), \
95 _______, H(03b1), H(03c3), H(03b4), H(03c6), H(03b3), H(03b7), H(2205), H(03ba), H(03bb), H(2228), H(2227), _______, H(2115), \
96 _______, H(03b6), H(03be), H(03c7), H(03c8), H(03b2), H(03bd), H(03bc), H(2272), H(2273), H(2208), _______, H(2191), H(2194), \
97 _______, _______, _______, _______, _______, _______, H(2190), H(2193), H(2192)),
98
99 /* Mathematical upper layer. Blank keys are TRNS.
100 * ,----------------------------------------------------------------.
101 * | ` | ₁| ₂ | ₃ | ₄ | ₅ | ₆ | ₇ | ₈ | ₉ | ₀ | ₋ | ₊ | ⊗ | ≈ | ∂ |
102 * |----------------------------------------------------------------|
103 * | | ∓ | Ω | Ε | Ρ | Τ | Θ | Υ | Ι | Ο | Π | ∄ | ∞ | ⊙ | ℂ |
104 * |----------------------------------------------------------------|
105 * | | Α | Σ | Δ | Φ | Γ | Η | ¬ | Κ | Λ | ∪ | ∩ | | ℤ |
106 * |----------------------------------------------------------------|
107 * | | Ζ | Ξ | Χ | Ψ | Β | Ν | Μ | ⊆ | ⊇ | ∉ | | ⇑ | ⇔ |
108 * |----------------------------------------------------------------|
109 * | | | | | | ||||| ⇐ | ⇓ | ⇒ |
110 * `----------------------------------------------------------------'
111 */
112[_SHIFTMAGIC] = LAYOUT(
113 KC_GRV, H(2081), H(2082), H(2083), H(2084), H(2085), H(2086), H(2087), H(2088), H(2089), H(2080), H(208b), H(208a), H(2297), H(2248), H(2202), \
114 _______, H(2213), H(03a9), H(0395), H(03a1), H(03a4), H(0398), H(03a5), H(0399), H(039f), H(03a0), H(2204), H(221e), H(2299), H(2102), \
115 _______, H(0391), H(03a3), H(0394), H(03a6), H(0393), H(0397), H(00ac), H(039a), H(039b), H(222a), H(2229), _______, H(2124), \
116 _______, H(0396), H(039e), H(03a7), H(03a8), H(0392), H(039d), H(039c), H(2286), H(2287), H(2209), _______, H(21d1), H(21d4), \
117 _______, _______, _______, _______, _______, _______, H(21d0), H(21d3), H(21d2)),
118};
119
120// Layer bitfields.
121#define MAGIC_LAYER (1UL << _MAGIC)
122#define SHIFTMAGIC_LAYER (1UL << _SHIFTMAGIC)
123// The layers we don't touch.
124#define LAYER_MASK ~(MAGIC_LAYER|SHIFTMAGIC_LAYER)
125
126bool process_record_user(uint16_t keycode, keyrecord_t *record) {
127 // Activate the appropriate magic layer:
128 // User is holding AltGr+Shift => _SHIFTMAGIC
129 // User is holding AltGr => _MAGIC
130 // Not holding AltGr => None
131 // We do this the efficient way, by grabbing the non-magic bits from the current layer bitmap,
132 // setting the appropriate magic or shiftmagic bit, and doing an absolute layer set. (Layer
133 // sets are nontrivial, so we don't want to do extras!)
134
135 // We track shift and AltGr state on our own, because this function is called before get_mods is
136 // updated!
137 static bool shifted = false;
138 static bool magic = false;
139
140 if (keycode == KC_LSHIFT || keycode == KC_RSHIFT) {
141 shifted = record->event.pressed;
142 } else if (keycode == MAGIC) {
143 magic = record->event.pressed;
144 } else if (keycode == RESET) {
145 // Safe reset: Only actually let this keycode through if shift is held as well. Since there's no
146 // right-shift in the function layer, this means that reset is Fn+LShift+Esc, something you're
147 // not likely to hit by accident. (Especially since AltGr+Esc is backtick!)
148 return (record->event.pressed && shifted);
149 }
150
151 // Update the layer.
152 uint32_t new_layer_state = layer_state & LAYER_MASK;
153 if (magic) {
154 new_layer_state |= (shifted ? SHIFTMAGIC_LAYER : MAGIC_LAYER);
155 }
156 if (layer_state != new_layer_state) {
157 layer_state_set(new_layer_state);
158 }
159
160 return true;
161}
162
163void eeconfig_init_user(void) {
164 set_unicode_input_mode(UC_OSX);
165}
166
167void matrix_init_user(void) {
168}
169
170void matrix_scan_user(void) {
171
172}
173
174void led_set_user(uint8_t usb_led) {
175
176}
diff --git a/keyboards/kbd67/hotswap/keymaps/zunger/readme.md b/keyboards/kbd67/hotswap/keymaps/zunger/readme.md
new file mode 100644
index 000000000..923a4824a
--- /dev/null
+++ b/keyboards/kbd67/hotswap/keymaps/zunger/readme.md
@@ -0,0 +1,27 @@
1* Custom keymap for kbd67, for those who need to both code and type math.
2* Author: Yonatan Zunger (zunger@gmail.com)
3
4This keymap is presently rather Mac-centric, as it uses Mac media keys in its function layer and the
5OS X Unicode input mode for the "magic" layers.
6
7*Layer 0 (Base QWERTY):* The layout has a few minor quirks: grave escape, Home/End/PgUp/PgDn in the
8right-hand column (rather than the more common Home/PgUp/PgDn/End), and a pause key between
9backspace and home -- this being something I use for screen lock, a necessity when one works with
10and sits next to security engineers. (Using a heavier switch on the pause key greatly reduces the
11risk of accidental triggering) In OS X style, alt and win are swapped on the left-hand side.
12
13The right-hand alt and gui keys take on a different meaning: right-alt lives up to its old name of
14AltGr by invoking Greek (the "magic" layers, 2 and 3), and right-gui invokes the function layer.
15
16*Layer 1 (Functions):* This layer deliberately sets KC_NO for the keys it doesn't use. I realize
17this isn't common, but I like to keep my functions quite distinct from all other layers.
18
19RESET can be accessed at Fn+Left Shift+Escape.
20
21*Layers 2 and 3*: These are invoked by the "magic" key (AltGr) and by magic+shift. The
22letters mostly produce Greek; the numbers, superscripts (magic) and subscripts (magic+shift); and
23the various other keys, mathematical symbols. There unfortunately aren't nearly enough keys for all
24the symbols I'd like, so magic+alt and magic+alt+shift may end up existing as well, giving this a
25proper Space Cadet effect; but that said, it's going to be hard to remember where all these symbols
26are without some extremely custom keycaps. In the limit of arbitrarily complex layers, the keyboard
27will probably start running LISP and turn into EMACS.
diff --git a/keyboards/kbd67/hotswap/keymaps/zunger/rules.mk b/keyboards/kbd67/hotswap/keymaps/zunger/rules.mk
new file mode 100644
index 000000000..a61cfa33f
--- /dev/null
+++ b/keyboards/kbd67/hotswap/keymaps/zunger/rules.mk
@@ -0,0 +1,2 @@
1# You need Unicode for this map.
2UNICODE_ENABLE = yes # Unicode