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