diff options
Diffstat (limited to 'keyboards/planck/keymaps/thermal_printer/keymap.c')
| -rw-r--r-- | keyboards/planck/keymaps/thermal_printer/keymap.c | 314 |
1 files changed, 314 insertions, 0 deletions
diff --git a/keyboards/planck/keymaps/thermal_printer/keymap.c b/keyboards/planck/keymaps/thermal_printer/keymap.c new file mode 100644 index 000000000..e88059731 --- /dev/null +++ b/keyboards/planck/keymaps/thermal_printer/keymap.c | |||
| @@ -0,0 +1,314 @@ | |||
| 1 | // This is the canonical layout file for the Quantum project. If you want to add another keyboard, | ||
| 2 | // this is the style you want to emulate. | ||
| 3 | |||
| 4 | #include "planck.h" | ||
| 5 | #include "action_layer.h" | ||
| 6 | #ifdef AUDIO_ENABLE | ||
| 7 | #include "audio.h" | ||
| 8 | #endif | ||
| 9 | #include "eeconfig.h" | ||
| 10 | |||
| 11 | extern keymap_config_t keymap_config; | ||
| 12 | |||
| 13 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
| 14 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
| 15 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
| 16 | // entirely and just use numbers. | ||
| 17 | #define _QWERTY 0 | ||
| 18 | #define _COLEMAK 1 | ||
| 19 | #define _DVORAK 2 | ||
| 20 | #define _LOWER 3 | ||
| 21 | #define _RAISE 4 | ||
| 22 | #define _PLOVER 5 | ||
| 23 | #define _ADJUST 16 | ||
| 24 | |||
| 25 | enum planck_keycodes { | ||
| 26 | QWERTY = SAFE_RANGE, | ||
| 27 | COLEMAK, | ||
| 28 | DVORAK, | ||
| 29 | PLOVER, | ||
| 30 | LOWER, | ||
| 31 | RAISE, | ||
| 32 | BACKLIT, | ||
| 33 | EXT_PLV | ||
| 34 | }; | ||
| 35 | |||
| 36 | // Fillers to make layering more clear | ||
| 37 | #define _______ KC_TRNS | ||
| 38 | #define XXXXXXX KC_NO | ||
| 39 | |||
| 40 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 41 | |||
| 42 | /* Qwerty | ||
| 43 | * ,-----------------------------------------------------------------------------------. | ||
| 44 | * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp | | ||
| 45 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 46 | * | Esc | A | S | D | F | G | H | J | K | L | ; | " | | ||
| 47 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 48 | * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter | | ||
| 49 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 50 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | | ||
| 51 | * `-----------------------------------------------------------------------------------' | ||
| 52 | */ | ||
| 53 | [_QWERTY] = { | ||
| 54 | {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, | ||
| 55 | {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, | ||
| 56 | {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, | ||
| 57 | {BACKLIT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} | ||
| 58 | }, | ||
| 59 | |||
| 60 | /* Colemak | ||
| 61 | * ,-----------------------------------------------------------------------------------. | ||
| 62 | * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp | | ||
| 63 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 64 | * | Esc | A | R | S | T | D | H | N | E | I | O | " | | ||
| 65 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 66 | * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter | | ||
| 67 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 68 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | | ||
| 69 | * `-----------------------------------------------------------------------------------' | ||
| 70 | */ | ||
| 71 | [_COLEMAK] = { | ||
| 72 | {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC}, | ||
| 73 | {KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT}, | ||
| 74 | {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, | ||
| 75 | {BACKLIT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} | ||
| 76 | }, | ||
| 77 | |||
| 78 | /* Dvorak | ||
| 79 | * ,-----------------------------------------------------------------------------------. | ||
| 80 | * | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp | | ||
| 81 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 82 | * | Esc | A | O | E | U | I | D | H | T | N | S | / | | ||
| 83 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 84 | * | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter | | ||
| 85 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 86 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | | ||
| 87 | * `-----------------------------------------------------------------------------------' | ||
| 88 | */ | ||
| 89 | [_DVORAK] = { | ||
| 90 | {KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC}, | ||
| 91 | {KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH}, | ||
| 92 | {KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT }, | ||
| 93 | {BACKLIT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} | ||
| 94 | }, | ||
| 95 | |||
| 96 | /* Lower | ||
| 97 | * ,-----------------------------------------------------------------------------------. | ||
| 98 | * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp | | ||
| 99 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 100 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | | | ||
| 101 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 102 | * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter | | ||
| 103 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 104 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
| 105 | * `-----------------------------------------------------------------------------------' | ||
| 106 | */ | ||
| 107 | [_LOWER] = { | ||
| 108 | {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, | ||
| 109 | {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, | ||
| 110 | {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______}, | ||
| 111 | {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} | ||
| 112 | }, | ||
| 113 | |||
| 114 | /* Raise | ||
| 115 | * ,-----------------------------------------------------------------------------------. | ||
| 116 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
| 117 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 118 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | | ||
| 119 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 120 | * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter | | ||
| 121 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 122 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
| 123 | * `-----------------------------------------------------------------------------------' | ||
| 124 | */ | ||
| 125 | [_RAISE] = { | ||
| 126 | {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, | ||
| 127 | {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, | ||
| 128 | {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______}, | ||
| 129 | {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} | ||
| 130 | }, | ||
| 131 | |||
| 132 | /* Plover layer (http://opensteno.org) | ||
| 133 | * ,-----------------------------------------------------------------------------------. | ||
| 134 | * | # | # | # | # | # | # | # | # | # | # | # | # | | ||
| 135 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 136 | * | | S | T | P | H | * | * | F | P | L | T | D | | ||
| 137 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 138 | * |TogOut| S | K | W | R | * | * | R | B | G | S | Z | | ||
| 139 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 140 | * | Exit | | | A | O | | E | U | | | | | ||
| 141 | * `-----------------------------------------------------------------------------------' | ||
| 142 | */ | ||
| 143 | |||
| 144 | [_PLOVER] = { | ||
| 145 | {KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1 }, | ||
| 146 | {XXXXXXX, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC}, | ||
| 147 | {XXXXXXX, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, | ||
| 148 | {EXT_PLV, XXXXXXX, XXXXXXX, KC_C, KC_V, XXXXXXX, XXXXXXX, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX} | ||
| 149 | }, | ||
| 150 | |||
| 151 | /* Adjust (Lower + Raise) | ||
| 152 | * ,-----------------------------------------------------------------------------------. | ||
| 153 | * | | Reset| | Print|no prnt | | | | | | | Del | | ||
| 154 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 155 | * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak|Plover| | | ||
| 156 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 157 | * | |Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof| | | | | | | ||
| 158 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 159 | * | | | | | | | | | | | | | ||
| 160 | * `-----------------------------------------------------------------------------------' | ||
| 161 | */ | ||
| 162 | [_ADJUST] = { | ||
| 163 | {_______, RESET, _______, PRINT_ON, PRINT_OFF, _______, _______, _______, _______, _______, _______, KC_DEL}, | ||
| 164 | {_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______}, | ||
| 165 | {_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______}, | ||
| 166 | {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} | ||
| 167 | } | ||
| 168 | |||
| 169 | |||
| 170 | }; | ||
| 171 | |||
| 172 | #ifdef AUDIO_ENABLE | ||
| 173 | |||
| 174 | float tone_startup[][2] = SONG(STARTUP_SOUND); | ||
| 175 | float tone_qwerty[][2] = SONG(QWERTY_SOUND); | ||
| 176 | float tone_dvorak[][2] = SONG(DVORAK_SOUND); | ||
| 177 | float tone_colemak[][2] = SONG(COLEMAK_SOUND); | ||
| 178 | float tone_plover[][2] = SONG(PLOVER_SOUND); | ||
| 179 | float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); | ||
| 180 | float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); | ||
| 181 | |||
| 182 | float tone_goodbye[][2] = SONG(GOODBYE_SOUND); | ||
| 183 | #endif | ||
| 184 | |||
| 185 | |||
| 186 | void persistant_default_layer_set(uint16_t default_layer) { | ||
| 187 | eeconfig_update_default_layer(default_layer); | ||
| 188 | default_layer_set(default_layer); | ||
| 189 | } | ||
| 190 | |||
| 191 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 192 | switch (keycode) { | ||
| 193 | case QWERTY: | ||
| 194 | if (record->event.pressed) { | ||
| 195 | #ifdef AUDIO_ENABLE | ||
| 196 | PLAY_NOTE_ARRAY(tone_qwerty, false, 0); | ||
| 197 | #endif | ||
| 198 | persistant_default_layer_set(1UL<<_QWERTY); | ||
| 199 | } | ||
| 200 | return false; | ||
| 201 | break; | ||
| 202 | case COLEMAK: | ||
| 203 | if (record->event.pressed) { | ||
| 204 | #ifdef AUDIO_ENABLE | ||
| 205 | PLAY_NOTE_ARRAY(tone_colemak, false, 0); | ||
| 206 | #endif | ||
| 207 | persistant_default_layer_set(1UL<<_COLEMAK); | ||
| 208 | } | ||
| 209 | return false; | ||
| 210 | break; | ||
| 211 | case DVORAK: | ||
| 212 | if (record->event.pressed) { | ||
| 213 | #ifdef AUDIO_ENABLE | ||
| 214 | PLAY_NOTE_ARRAY(tone_dvorak, false, 0); | ||
| 215 | #endif | ||
| 216 | persistant_default_layer_set(1UL<<_DVORAK); | ||
| 217 | } | ||
| 218 | return false; | ||
| 219 | break; | ||
| 220 | case LOWER: | ||
| 221 | if (record->event.pressed) { | ||
| 222 | layer_on(_LOWER); | ||
| 223 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
| 224 | } else { | ||
| 225 | layer_off(_LOWER); | ||
| 226 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
| 227 | } | ||
| 228 | return false; | ||
| 229 | break; | ||
| 230 | case RAISE: | ||
| 231 | if (record->event.pressed) { | ||
| 232 | layer_on(_RAISE); | ||
| 233 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
| 234 | } else { | ||
| 235 | layer_off(_RAISE); | ||
| 236 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
| 237 | } | ||
| 238 | return false; | ||
| 239 | break; | ||
| 240 | case BACKLIT: | ||
| 241 | if (record->event.pressed) { | ||
| 242 | register_code(KC_RSFT); | ||
| 243 | #ifdef BACKLIGHT_ENABLE | ||
| 244 | backlight_step(); | ||
| 245 | #endif | ||
| 246 | } else { | ||
| 247 | unregister_code(KC_RSFT); | ||
| 248 | } | ||
| 249 | return false; | ||
| 250 | break; | ||
| 251 | case PLOVER: | ||
| 252 | if (record->event.pressed) { | ||
| 253 | #ifdef AUDIO_ENABLE | ||
| 254 | stop_all_notes(); | ||
| 255 | PLAY_NOTE_ARRAY(tone_plover, false, 0); | ||
| 256 | #endif | ||
| 257 | layer_off(_RAISE); | ||
| 258 | layer_off(_LOWER); | ||
| 259 | layer_off(_ADJUST); | ||
| 260 | layer_on(_PLOVER); | ||
| 261 | if (!eeconfig_is_enabled()) { | ||
| 262 | eeconfig_init(); | ||
| 263 | } | ||
| 264 | keymap_config.raw = eeconfig_read_keymap(); | ||
| 265 | keymap_config.nkro = 1; | ||
| 266 | eeconfig_update_keymap(keymap_config.raw); | ||
| 267 | } | ||
| 268 | return false; | ||
| 269 | break; | ||
| 270 | case EXT_PLV: | ||
| 271 | if (record->event.pressed) { | ||
| 272 | #ifdef AUDIO_ENABLE | ||
| 273 | PLAY_NOTE_ARRAY(tone_plover_gb, false, 0); | ||
| 274 | #endif | ||
| 275 | layer_off(_PLOVER); | ||
| 276 | } | ||
| 277 | return false; | ||
| 278 | break; | ||
| 279 | } | ||
| 280 | return true; | ||
| 281 | } | ||
| 282 | |||
| 283 | void matrix_init_user(void) { | ||
| 284 | #ifdef AUDIO_ENABLE | ||
| 285 | startup_user(); | ||
| 286 | #endif | ||
| 287 | } | ||
| 288 | |||
| 289 | #ifdef AUDIO_ENABLE | ||
| 290 | |||
| 291 | void startup_user() | ||
| 292 | { | ||
| 293 | _delay_ms(20); // gets rid of tick | ||
| 294 | PLAY_NOTE_ARRAY(tone_startup, false, 0); | ||
| 295 | } | ||
| 296 | |||
| 297 | void shutdown_user() | ||
| 298 | { | ||
| 299 | PLAY_NOTE_ARRAY(tone_goodbye, false, 0); | ||
| 300 | _delay_ms(150); | ||
| 301 | stop_all_notes(); | ||
| 302 | } | ||
| 303 | |||
| 304 | void music_on_user(void) | ||
| 305 | { | ||
| 306 | music_scale_user(); | ||
| 307 | } | ||
| 308 | |||
| 309 | void music_scale_user(void) | ||
| 310 | { | ||
| 311 | PLAY_NOTE_ARRAY(music_scale, false, 0); | ||
| 312 | } | ||
| 313 | |||
| 314 | #endif | ||
