diff options
| author | zunger-humu <zunger@humu.com> | 2019-06-01 14:35:52 -0700 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2019-06-01 14:35:52 -0700 |
| commit | 912b6a591643990cca5d4b795bdcc2ad9f172b2f (patch) | |
| tree | f922c8f83dec72000259b07c3ce8745296f482d7 | |
| parent | 67105b2a219f6d0e2d391706149152c24878a4e7 (diff) | |
| download | qmk_firmware-912b6a591643990cca5d4b795bdcc2ad9f172b2f.tar.gz qmk_firmware-912b6a591643990cca5d4b795bdcc2ad9f172b2f.zip | |
[Keymap] "Cadet-style" keymap + improved LAYOUT macro for melody96 (#5985)
* [melody96] "Cadet-style" keymap for melody96; LAYOUT macro for hotswap keyboard.
* Rename macro.
* Fix layer types.
| -rw-r--r-- | keyboards/melody96/keymaps/zunger/config.h | 22 | ||||
| -rw-r--r-- | keyboards/melody96/keymaps/zunger/keymap.c | 250 | ||||
| -rw-r--r-- | keyboards/melody96/keymaps/zunger/readme.md | 78 | ||||
| -rw-r--r-- | keyboards/melody96/keymaps/zunger/rules.mk | 2 | ||||
| -rw-r--r-- | keyboards/melody96/melody96.h | 39 |
5 files changed, 391 insertions, 0 deletions
diff --git a/keyboards/melody96/keymaps/zunger/config.h b/keyboards/melody96/keymaps/zunger/config.h new file mode 100644 index 000000000..cc06440e0 --- /dev/null +++ b/keyboards/melody96/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/melody96/keymaps/zunger/keymap.c b/keyboards/melody96/keymaps/zunger/keymap.c new file mode 100644 index 000000000..9031447cd --- /dev/null +++ b/keyboards/melody96/keymaps/zunger/keymap.c | |||
| @@ -0,0 +1,250 @@ | |||
| 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 | |||
| 18 | enum custom_keycodes { | ||
| 19 | // We provide special layer management keys: | ||
| 20 | // GREEK triggers the Greek (aka "Front") layer, or the SHIFTGREEK layer when shift is held. | ||
| 21 | // (Because we use Unicode, we need to implement shift-handling at the firmware level, | ||
| 22 | // rather than the OS level like we do in the QWERTY layer) | ||
| 23 | // CADET or GREEK+ALT triggers the Cadet (aka "Top") layer, or the SHIFTCADET layer when | ||
| 24 | // shift is held. | ||
| 25 | // LAYER_LOCK locks the "base" layer (i.e., QWERTY, GREEK, or CADET) to the value which is | ||
| 26 | // pressed at the moment that it is being released. When a layer lock is set, the | ||
| 27 | // analogous layer modifier key is reversed; e.g., if you lock the GREEK layer, then the | ||
| 28 | // GREEK button bounces you back to QWERTY. | ||
| 29 | // | ||
| 30 | // We also parse the shift, alt, and caps lock keys to provide management of those which is | ||
| 31 | // compatible with these various layers. | ||
| 32 | KC_GREEK = SAFE_RANGE, | ||
| 33 | KC_CADET, | ||
| 34 | KC_LAYER_LOCK, | ||
| 35 | }; | ||
| 36 | |||
| 37 | enum layers_keymap { | ||
| 38 | _QWERTY = 0, | ||
| 39 | _FUNCTION, | ||
| 40 | |||
| 41 | _GREEK, | ||
| 42 | _SHIFTGREEK, | ||
| 43 | _CADET, | ||
| 44 | _SHIFTCADET, | ||
| 45 | }; | ||
| 46 | |||
| 47 | // This is so that H(xxxx) has the same width as _______, which makes the grids more legible. | ||
| 48 | #define H(x) UC(0x##x) | ||
| 49 | #define MO_FN MO(_FUNCTION) | ||
| 50 | #define KC_LLCK KC_LAYER_LOCK | ||
| 51 | |||
| 52 | // TODO: To generalize this, we want some #defines that let us specify how each key on the base | ||
| 53 | // layer should map to the four special layers, and then use that plus the base layer definition to | ||
| 54 | // autogenerate the keymaps for the other layers. | ||
| 55 | // TODO: It would also be nice to be able to put the actual code points in here, rather than | ||
| 56 | // numbers. | ||
| 57 | // TODO: Also add checkmark and dengir. | ||
| 58 | |||
| 59 | |||
| 60 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 61 | /* The diagram below shows five rows for each key: from top to bottom, the QWERTY layer, the | ||
| 62 | * GREEK layer, the SHIFTGREEK layer, the CADET layer, and the SHIFTCADET layer. (The single | ||
| 63 | * diagram is to make it easier to see what goes where with this many layers!) | ||
| 64 | * | ||
| 65 | * ,---------------------------------------------------------------------------- | ||
| 66 | * | ` |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|HOM|END|PGU|PGD|MUT|BRK| QWERTY | ||
| 67 | * | ` | ¹ | ² | ³ | ⁴ | ⁵ | ⁶ | ⁷ | ⁸ | ⁹ | ⁰ | ⁻ | ⁺ | ⁽ | ⁾ | | | | | GREEK | ||
| 68 | * | ` | ₁ | ₂ | ₃ | ₄ | ₅ | ₆ | ₇ | ₈ | ₉ | ₀ | ₋ | ₊ | ₍ | ₎ | | | | | SHIFTGREEK | ||
| 69 | * | ¬ | | | | | | | | | | | | | | | | | | | CADET | ||
| 70 | * | ∅ | | | | | | | | | | | | | | | | | | | SHIFTCADET | ||
| 71 | * |---------------------------------------------------------------------------| | ||
| 72 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | + | BKSPC |LCK| / | * | - | | ||
| 73 | * | ` | | | | | | | | | | | ∝ | ∼ | BKSPC |LCK| ⊘ | ⊙ | ⊖ | | ||
| 74 | * | ` | | | | | | | | | | | | ≁ | BKSPC |LCK| | ⊗ | | | ||
| 75 | * | | | | | | | | | | | | | ± | BKSPC |LCK| | | | | ||
| 76 | * | | | | | | | | | | | | | ∓ | BKSPC |LCK| | | | | ||
| 77 | * |---------------------------------------------------------------------------| | ||
| 78 | * | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | \ | 7 | 8 | 9 | | | ||
| 79 | * | | θ | ω | ε | ρ | τ | ψ | υ | ι | ο | π | | | | | | | | | ||
| 80 | * | | Θ | Ω | Ε | Ρ | Τ | Ψ | Υ | Ι | Ο | Π | | | | | | | | | ||
| 81 | * | | ∧ | ∨ | ∩ | ∪ | ⊂ | ⊃ | ∀ | ∞ | ∃ | ∂ | ∈ | | | * | * | * | | [1] | ||
| 82 | * | | ℚ | | | ℝ | ⊆ | ⊇ | | ℵ | ∄ | | ∉ | | | * | * | * | | | ||
| 83 | * |-----------------------------------------------------------------------| + | | ||
| 84 | * | CTRL | A | S | D | F | G | H | J | K | L | ; | ' | RET | 4 | 5 | 6 | ⊕ | | ||
| 85 | * | CTRL | α | σ | δ | φ | γ | η | ϑ | κ | λ | ⋯ | ⋅ | RET | | | | | | ||
| 86 | * | CTRL | Α | Σ | Δ | Φ | Γ | Η | | Κ | Λ | … | ∴ | RET | | | | | | ||
| 87 | * | CTRL | ⟘ | ⊤ | ⊢ | ⊣ | ↑ | ↓ | ← | → | ↔ | | | RET | * | * | * | | [1] | ||
| 88 | * | CTRL | Å | | ∇ | | ⇑ | ⇓ | ⇐ | ⇒ | ⇔ | | | RET | * | * | * | | | ||
| 89 | * |-----------------------------------------------------------------------|---| | ||
| 90 | * | SHIFT | Z | X | C | V | B | N | M | , | . | / |SHFT | ↑ | 1 | 2 | 3 | | | ||
| 91 | * | SHIFT | ζ | ξ | χ | ς | β | ν | μ | ≪ | ≫ | ∫ |SHFT | | | | | | | ||
| 92 | * | SHIFT | Ζ | Ξ | Χ | ✔ | Β | Ν | Μ | ≲ | ≳ | |SHFT | | | | | | | ||
| 93 | * | SHIFT | | | ≠ | ≈ | ≡ | ≤ | ≥ | | | ÷ |SHFT | | * | * | * | | [1] | ||
| 94 | * | SHIFT | ℤ | | ℂ | ≉ | ≢ | ℕ | | | | |SHFT | | * | * | * | | | ||
| 95 | * |-----------------------------------------------------------------------|ENT| | ||
| 96 | * | CTL | ALT| CMD| SPACE | α | β | γ | ← | ↓ | → | 0 | . | | [2] | ||
| 97 | * | CTL | ALT| CMD| SPACE | α | β | γ | | | | | | | | ||
| 98 | * | CTL | ALT| CMD| SPACE | α | β | γ | | | | | | | | ||
| 99 | * | CTL | ALT| CMD| SPACE | α | β | γ | | | | | | | | ||
| 100 | * | CTL | ALT| CMD| SPACE | α | β | γ | | | | | | | | ||
| 101 | * `---------------------------------------------------------------------------' | ||
| 102 | * | ||
| 103 | * [1] CADET + numpad moves the mouse. SHIFT+CADET+NUMPAD moves it more quickly. CADET+5 | ||
| 104 | * clicks the mouse, and SHIFT+CADET+FIVE right-clicks. | ||
| 105 | * [2] The Greek letters in this row are the three modifier keys (GREEK, CADET, FN), | ||
| 106 | * not the Unicode Greek letters. | ||
| 107 | */ | ||
| 108 | // NB: Using GESC for escape in the QWERTY layer as a temporary hack because I messed up the | ||
| 109 | // switch on the KC_GRV key; change back to KC_ESC once this is fixed. | ||
| 110 | [_QWERTY] = LAYOUT_hotswap( | ||
| 111 | KC_GESC, 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_HOME, KC_END, KC_PGUP, KC_PGDN, KC_MPLY, KC_BRK, | ||
| 112 | KC_GRV, 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_LLCK, KC_PSLS, KC_PAST, KC_PMNS, | ||
| 113 | 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_P7, KC_P8, KC_P9, | ||
| 114 | 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_P4, KC_P5, KC_P6, KC_PPLS, | ||
| 115 | 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_P1, KC_P2, KC_P3, | ||
| 116 | KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_GREEK,KC_CADET,MO_FN, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT, KC_PENT), | ||
| 117 | [_GREEK] = LAYOUT_hotswap( | ||
| 118 | 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(207d), H(207e), XXXXXXX, XXXXXXX, XXXXXXX, _______, | ||
| 119 | KC_GRV, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, H(221d), H(223c), _______, _______, H(2298), H(2299), H(2296), | ||
| 120 | _______, H(03b8), H(03c9), H(03b5), H(03c1), H(03c4), H(03c8), H(03c5), H(03b9), H(03bf), H(03c0), KC_LBRC, KC_RBRC, KC_BSLS, KC_P7, KC_P8, KC_P9, | ||
| 121 | _______, H(03b1), H(03c3), H(03b4), H(03c6), H(03b3), H(03b7), H(03d1), H(03ba), H(03bb), H(22ef), H(22c5), _______, KC_P4, KC_P5, KC_P6, H(2295), | ||
| 122 | _______, H(03b6), H(03be), H(03c7), H(03c2), H(03b2), H(03bd), H(03bc), H(226a), H(226b), H(222b), _______, _______, KC_P1, KC_P2, KC_P3, | ||
| 123 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_P0, KC_PDOT, KC_PENT), | ||
| 124 | [_SHIFTGREEK] = LAYOUT_hotswap( | ||
| 125 | 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(208d), H(208e), XXXXXXX, XXXXXXX, XXXXXXX, _______, | ||
| 126 | KC_GRV, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX, H(2241), _______, _______, XXXXXXX, H(2297), XXXXXXX, | ||
| 127 | _______, H(0398), H(03a9), H(0395), H(03a1), H(03a4), H(03a8), H(03a5), H(0399), H(039f), H(03a0), KC_LBRC, KC_RBRC, KC_BSLS, KC_P7, KC_P8, KC_P9, | ||
| 128 | _______, H(0391), H(03a3), H(0394), H(03a6), H(0393), H(0397), XXXXXXX, H(039a), H(039b), H(2026), H(2234), _______, KC_P4, KC_P5, KC_P6, H(2295), | ||
| 129 | _______, H(0396), H(039e), H(03a7), H(2714), H(0392), H(039d), H(039c), H(2272), H(2273), XXXXXXX, _______, _______, KC_P1, KC_P2, KC_P3, | ||
| 130 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_P0, KC_PDOT, KC_PENT), | ||
| 131 | // TODO: Add mouse keys to keypad. | ||
| 132 | [_CADET] = LAYOUT_hotswap( | ||
| 133 | H(00AC), KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, | ||
| 134 | KC_GRV, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, H(00b1), _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, | ||
| 135 | _______, H(2227), H(2228), H(2229), H(222a), H(2282), H(2283), H(2200), H(221e), H(2203), H(2202), H(2208), XXXXXXX, XXXXXXX, KC_P7, KC_P8, KC_P9, | ||
| 136 | _______, H(22a5), H(22a4), H(22a2), H(22a3), H(2191), H(2193), H(2190), H(2192), H(2194), XXXXXXX, XXXXXXX, _______, KC_P4, KC_P5, KC_P6, XXXXXXX, | ||
| 137 | _______, XXXXXXX, XXXXXXX, H(2260), H(2248), H(2261), H(2264), H(2265), XXXXXXX, XXXXXXX, H(00f7), _______, _______, KC_P1, KC_P2, KC_P3, | ||
| 138 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_P0, KC_PDOT, KC_PENT), | ||
| 139 | [_SHIFTCADET] = LAYOUT_hotswap( | ||
| 140 | H(2205), KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, | ||
| 141 | KC_GRV, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, H(2213), _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, | ||
| 142 | _______, H(211a), XXXXXXX, XXXXXXX, H(211d), H(2286), H(2287), XXXXXXX, H(2135), H(2204), XXXXXXX, H(2209), XXXXXXX, XXXXXXX, KC_P7, KC_P8, KC_P9, | ||
| 143 | _______, H(212b), XXXXXXX, H(2207), XXXXXXX, H(21d1), H(21d3), H(21d0), H(21d2), H(21d4), XXXXXXX, XXXXXXX, _______, KC_P4, KC_P5, KC_P6, XXXXXXX, | ||
| 144 | _______, H(2124), XXXXXXX, H(2102), H(2249), H(2262), H(2115), XXXXXXX, XXXXXXX, XXXXXXX, H(00f7), _______, _______, KC_P1, KC_P2, KC_P3, | ||
| 145 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_P0, KC_PDOT, KC_PENT), | ||
| 146 | |||
| 147 | // Function layer is mostly for keyboard meta-control operations. Lots of this is just from the | ||
| 148 | // default layout; TODO make it nicer, add Unicode mode switchers. | ||
| 149 | [_FUNCTION] = LAYOUT_hotswap( | ||
| 150 | RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, _______, | ||
| 151 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 152 | _______, RGB_TOG, _______, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, _______, _______, _______, _______, _______, | ||
| 153 | BL_TOGG, _______, _______, UC_M_OS, UC_M_LN, UC_M_WI, UC_M_BS, UC_M_WC, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 154 | _______, _______, _______, BL_DEC, BL_TOGG, BL_INC, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 155 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), | ||
| 156 | }; | ||
| 157 | |||
| 158 | // Layer bitfields. | ||
| 159 | #define GREEK_LAYER (1UL << _GREEK) | ||
| 160 | #define SHIFTGREEK_LAYER (1UL << _SHIFTGREEK) | ||
| 161 | #define CADET_LAYER (1UL << _CADET) | ||
| 162 | #define SHIFTCADET_LAYER (1UL << _SHIFTCADET) | ||
| 163 | // The layers we don't touch. | ||
| 164 | #define LAYER_MASK ~(GREEK_LAYER|SHIFTGREEK_LAYER|CADET_LAYER|SHIFTCADET_LAYER) | ||
| 165 | |||
| 166 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 167 | // We track these persistent globals and manage them on our own, rather than trying to rely on | ||
| 168 | // get_mods or the like, because this function is called *before* that's updated! | ||
| 169 | static bool shift_held = false; | ||
| 170 | static bool alt_held = false; | ||
| 171 | static bool greek_held = false; | ||
| 172 | static bool cadet_held = false; | ||
| 173 | |||
| 174 | // These are where we remember the values of lock states. | ||
| 175 | static bool shift_lock = false; | ||
| 176 | static int layer_lock = _QWERTY; | ||
| 177 | |||
| 178 | // Process any modifier key presses. | ||
| 179 | if (keycode == KC_LSHIFT || keycode == KC_RSHIFT) { | ||
| 180 | shift_held = record->event.pressed; | ||
| 181 | } else if (keycode == KC_LALT || keycode == KC_RALT) { | ||
| 182 | alt_held = record->event.pressed; | ||
| 183 | } else if (keycode == KC_GREEK) { | ||
| 184 | greek_held = record->event.pressed; | ||
| 185 | } else if (keycode == KC_CADET) { | ||
| 186 | cadet_held = record->event.pressed; | ||
| 187 | } | ||
| 188 | |||
| 189 | // Now let's transform these into the "cadet request" and "greek request." | ||
| 190 | const bool greek_request = (greek_held && !alt_held); | ||
| 191 | const bool cadet_request = (cadet_held || (greek_held && alt_held)); | ||
| 192 | |||
| 193 | // Now, handle the lock keys. We store next_layer_lock in a local variable so that we can | ||
| 194 | // determine the layer to pick right now before we update layer_lock. | ||
| 195 | int next_layer_lock = layer_lock; | ||
| 196 | if (keycode == KC_CAPS) { | ||
| 197 | // If we're in QWERTY mode, caps lock is already going to be managed by the host OS, but by | ||
| 198 | // tracking it ourselves we can also usefully apply it to the GREEK and CADET layers. | ||
| 199 | if (record->event.pressed) { | ||
| 200 | shift_lock = !shift_lock; | ||
| 201 | } | ||
| 202 | } else if (keycode == KC_LAYER_LOCK) { | ||
| 203 | if (record->event.pressed) { | ||
| 204 | if (cadet_request) { | ||
| 205 | next_layer_lock = _CADET; | ||
| 206 | } else if (greek_request) { | ||
| 207 | next_layer_lock = _GREEK; | ||
| 208 | } else { | ||
| 209 | next_layer_lock = _QWERTY; | ||
| 210 | } | ||
| 211 | } | ||
| 212 | } | ||
| 213 | |||
| 214 | // OK! Now we know which buttons are being held, and the current and upcoming states of the locks. | ||
| 215 | // We can compute our new base layer. Remember that the CADET and GREEK keys act as their own | ||
| 216 | // antonyms if they match the layer lock -- e.g., if you have CADET locked, then CADET+X generates | ||
| 217 | // QWERTY-X. | ||
| 218 | int base_layer; | ||
| 219 | if (cadet_request) { | ||
| 220 | base_layer = (layer_lock == _CADET ? _QWERTY : _CADET); | ||
| 221 | } else if (greek_request) { | ||
| 222 | base_layer = (layer_lock == _GREEK ? _QWERTY : _GREEK); | ||
| 223 | } else { | ||
| 224 | base_layer = layer_lock; | ||
| 225 | } | ||
| 226 | |||
| 227 | const bool shifted = (shift_held != shift_lock); | ||
| 228 | int actual_layer; | ||
| 229 | if (base_layer == _CADET) { | ||
| 230 | actual_layer = (shifted ? _SHIFTCADET : _CADET); | ||
| 231 | } else if (base_layer == _GREEK) { | ||
| 232 | actual_layer = (shifted ? _SHIFTGREEK : _GREEK); | ||
| 233 | } else { | ||
| 234 | // We don't do shifting for the QWERTY layer, since for that we emit USB HID codes and shifting | ||
| 235 | // is managed by the host OS. | ||
| 236 | actual_layer = _QWERTY; | ||
| 237 | } | ||
| 238 | |||
| 239 | // And now we can update the layer lock and the actual firmware layer selector. | ||
| 240 | layer_lock = next_layer_lock; | ||
| 241 | layer_state_t new_layer_state = (layer_state & LAYER_MASK) | (1UL << actual_layer); | ||
| 242 | if (new_layer_state != layer_state) { | ||
| 243 | layer_state_set(new_layer_state); | ||
| 244 | } | ||
| 245 | |||
| 246 | // TODO: We can update LED states based on shift_lock (caps), layer_lock (layer lock), and | ||
| 247 | // base_layer (base layer). | ||
| 248 | |||
| 249 | return true; | ||
| 250 | } | ||
diff --git a/keyboards/melody96/keymaps/zunger/readme.md b/keyboards/melody96/keymaps/zunger/readme.md new file mode 100644 index 000000000..3eb64a2e7 --- /dev/null +++ b/keyboards/melody96/keymaps/zunger/readme.md | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | * The "Cadet-Style" keymap for the melody96. | ||
| 2 | * Author: Yonatan Zunger (zunger@gmail.com) | ||
| 3 | |||
| 4 | This is an experimental keymap being used both for practical reasons (as my daily driver) and to | ||
| 5 | work out the ideas of a "space-cadet-style" keyboard which can type text and mathematical symbols | ||
| 6 | with equal ease. It's designed for anyone who frequently needs to do this outside of a LaTeX | ||
| 7 | environment, or for anyone who loves the old "Space Cadet" keyboard! And it works at its best when | ||
| 8 | you have actual Cadet keycaps (like SA Symbolics) installed, because those keycaps will actually | ||
| 9 | show what you get. | ||
| 10 | |||
| 11 | The core idea of this keyboard is that, in addition to a QWERTY base layer and a function layer, it | ||
| 12 | supports two additional base layers -- the GREEK layer (the analogue of the Space Cadet "Greek," or | ||
| 13 | "Front," keys) and the CADET layer (the analogue of the Space Cadet "Top" keys). These layers use | ||
| 14 | Unicode to generate all of the mathematical symbols you can find on a traditional Space Cadet | ||
| 15 | layout, plus a bunch of extras. | ||
| 16 | |||
| 17 | Because Unicode can't be encoded using the traditional USB HID protocol, QMK does some clever but | ||
| 18 | horrifying things to fool your OS. One consequence of this is that the shift key needs to be handled | ||
| 19 | by the keyboard firmware, not the host OS. To handle this, we have two additional layers -- | ||
| 20 | SHIFTGREEK and SHIFTCADET -- and handle the flipping between all of these layers here in the | ||
| 21 | firmware. | ||
| 22 | |||
| 23 | *The simple bit: Using this layout on a Melody96* | ||
| 24 | |||
| 25 | At the core of this layout are three special modifier keys and two special lock keys: | ||
| 26 | |||
| 27 | * The GREEK key, to the right of the spacebar, activates the GREEK layer. GREEK+SHIFT activates | ||
| 28 | SHIFTGREEK. These keys generate Greek letters on the letter keys (thus the name), and a few | ||
| 29 | mathematical symbols on other keys. They correspond to the notations on the front of traditional | ||
| 30 | Space Cadet keys; if your capset doesn't include those (alas, most don't), they're the "pretty | ||
| 31 | obvious" mappings. | ||
| 32 | * The CADET key, to the right of GREEK, activates the CADET layer. These are the symbols above the | ||
| 33 | letters on a Space Cadet layout. CADET+SHIFT activates the SHIFTCADET layer, with even more | ||
| 34 | symbols. | ||
| 35 | * The FUNCTION key, to the right of CADET, activates the function layer. This is where you have a | ||
| 36 | reset mechanism, a selector for which Unicode input type you want, and so on. | ||
| 37 | |||
| 38 | Additionally, GREEK+ALT is equivalent to CADET. This is handy for other keyboards where you don't | ||
| 39 | have room for this many modifiers. | ||
| 40 | |||
| 41 | The lock keys are: | ||
| 42 | |||
| 43 | * Caps lock, if you use it, will also act as a "shift lock" for the Greek and Cadet layers. Shift | ||
| 44 | lock is slightly different, in that while it is engaged shift will _dis_engage it; that's actually | ||
| 45 | pretty useful when typing math. | ||
| 46 | * An additional "layer lock" key, by default where "num lock" usually goes, will lock the choice of | ||
| 47 | base layer. To use it, hold down any invocation of the GREEK or CADET layers, or none at all, and | ||
| 48 | hit lock; it will then put you in that layer. The corresponding modifier key will then toggle you | ||
| 49 | back to the QWERTY layer. (So for example, if you hit GREEK+LAYER_LOCK and release them, you're | ||
| 50 | now typing in Greek; the GREEK modifier would cause you to type QWERTY momentarily. To go back to | ||
| 51 | ordinary QWERTY mode, you'd just hit LAYER_LOCK again with no modifiers held) | ||
| 52 | |||
| 53 | To see the full layout, check out the big comment in keymap.c. | ||
| 54 | |||
| 55 | *A less-simple bit: Adapting this to other keyboards* | ||
| 56 | |||
| 57 | This is really a canary for generic Cadet implementations. Before this can be made generic, a few | ||
| 58 | things will have to happen: | ||
| 59 | |||
| 60 | (1) Instead of a fixed keymap, this has to be refactored into some kind of array showing the | ||
| 61 | mappings of QWERTY-layer keys onto the appropriate code points in the GREEK and CADET layers, and | ||
| 62 | some preprocessor magic needs to auto-transform this plus a traditional keymap for the QWERTY layer | ||
| 63 | into keymaps for all five of the core layers. (Function layers would presumably be handled on a | ||
| 64 | per-keyboard basis) | ||
| 65 | |||
| 66 | (2) The standard mapping of those should have some #define's to control things like whether there | ||
| 67 | are physical F-keys (you would probably want to move superscript and subscripts onto the numbers if | ||
| 68 | there weren't, and figure out what to do with the non-numeric super/sub keys), whether you actually | ||
| 69 | want to enable GREEK+ALT=CADET, and so on; | ||
| 70 | |||
| 71 | (3) There should be support for controlling indicator LEDs based on the base layer selection, | ||
| 72 | caps/shift lock state, and layer lock state, as well as for triggering audio on transitions; | ||
| 73 | |||
| 74 | (4) All the core fancy logic in process_record_user which implements the layer handling should be | ||
| 75 | factored out into its own function, so that keyboards can easily reuse that, too. | ||
| 76 | |||
| 77 | This is a lovely TODO for future work, and could be particularly fun to go along with new releases | ||
| 78 | of SA Symbolics and the like. Anyone interested in such things, ping me! | ||
diff --git a/keyboards/melody96/keymaps/zunger/rules.mk b/keyboards/melody96/keymaps/zunger/rules.mk new file mode 100644 index 000000000..a61cfa33f --- /dev/null +++ b/keyboards/melody96/keymaps/zunger/rules.mk | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | # You need Unicode for this map. | ||
| 2 | UNICODE_ENABLE = yes # Unicode | ||
diff --git a/keyboards/melody96/melody96.h b/keyboards/melody96/melody96.h index f60f054ca..d846fa28d 100644 --- a/keyboards/melody96/melody96.h +++ b/keyboards/melody96/melody96.h | |||
| @@ -25,4 +25,43 @@ | |||
| 25 | { K110, K111, K112, K113, K114, K115, K116, K117, K118 } \ | 25 | { K110, K111, K112, K113, K114, K115, K116, K117, K118 } \ |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | /* | ||
| 29 | * The layout macro for the layout of hotswap keyboards, with illustrative grid of a typical | ||
| 30 | * assignment. | ||
| 31 | * ,--------------------------------------------------------------------------- | ||
| 32 | * |ESC|F1|F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|PSC|HOM|END|PGU|PGD|DEL| | ||
| 33 | * ,--------------------------------------------------------------------------| | ||
| 34 | * | ` |1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | + | BKSPC |NLK| / | * | - | | ||
| 35 | * |--------------------------------------------------------------------------| | ||
| 36 | * | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | \ | 7 | 8 | 9 | | | ||
| 37 | * |----------------------------------------------------------------------| + | | ||
| 38 | * | CTRL | A | S | D | F | G | H | J | K | L | ; | ' | RET | 4 | 5 | 6 | | | ||
| 39 | * |----------------------------------------------------------------------|---| | ||
| 40 | * | LSHIFT | Z | X | C | V | B | N | M | , | . | / |RSHFT| ↑ | 1 | 2 | 3 | | | ||
| 41 | * |----------------------------------------------------------------------|ENT| | ||
| 42 | * |LCTL|LWIN|LALT| SPACE |CTL|ALT|FN | ← | ↓ | → | 0 | . | | | ||
| 43 | * `--------------------------------------------------------------------------- | ||
| 44 | */ | ||
| 45 | #define LAYOUT_hotswap( \ | ||
| 46 | K050, K051, K052, K053, K054, K055, K056, K057, K058, K118, K117, K115, K114, K113, K116, K112, K111, K110, K063, \ | ||
| 47 | K040, K041, K042, K043, K044, K045, K046, K047, K048, K108, K107, K105, K104, K106, K102, K101, K100, K064, \ | ||
| 48 | K030, K031, K032, K033, K034, K035, K036, K037, K038, K098, K097, K095, K094, K093, K096, K092, K091, \ | ||
| 49 | K020, K021, K022, K023, K024, K025, K026, K027, K028, K088, K087, K085, K084, K086, K082, K081, K080, \ | ||
| 50 | K010, K012, K013, K014, K015, K016, K017, K018, K078, K077, K075, K074, K073, K076, K072, K071, \ | ||
| 51 | K000, K001, K002, K006, K008, K007, K005, K004, K003, K066, K062, K061, K060 \ | ||
| 52 | ) { \ | ||
| 53 | { K000, K001, K002, K003, K004, K005, K006, K007, K008 }, \ | ||
| 54 | { K010, KC_NO, K012, K013, K014, K015, K016, K017, K018 }, \ | ||
| 55 | { K020, K021, K022, K023, K024, K025, K026, K027, K028 }, \ | ||
| 56 | { K030, K031, K032, K033, K034, K035, K036, K037, K038 }, \ | ||
| 57 | { K040, K041, K042, K043, K044, K045, K046, K047, K048 }, \ | ||
| 58 | { K050, K051, K052, K053, K054, K055, K056, K057, K058 }, \ | ||
| 59 | { K060, K061, K062, K063, K064, KC_NO, K066, KC_NO, KC_NO }, \ | ||
| 60 | { KC_NO, K071, K072, K073, K074, K075, K076, K077, K078 }, \ | ||
| 61 | { K080, K081, K082, KC_NO, K084, K085, K086, K087, K088 }, \ | ||
| 62 | { KC_NO, K091, K092, K093, K094, K095, K096, K097, K098 }, \ | ||
| 63 | { K100, K101, K102, KC_NO, K104, K105, K106, K107, K108 }, \ | ||
| 64 | { K110, K111, K112, K113, K114, K115, K116, K117, K118 } \ | ||
| 65 | } | ||
| 66 | |||
| 28 | #endif | 67 | #endif |
