]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/planck/keymaps/originerd/keymap.c
Merge pull request #1331 from ariasuni/master
[qmk_firmware.git] / keyboards / planck / keymaps / originerd / keymap.c
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
18 enum planck_layers {
19   _NERD,
20   _LOWER,
21   _RAISE,
22   _ADJUST
23 };
24
25 enum planck_keycodes {
26   NERD = SAFE_RANGE,
27   LOWER,
28   RAISE
29 };
30
31 // Fillers to make layering more clear
32 #define _______ KC_TRNS
33 #define XXXXXXX KC_NO
34
35 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
36
37 /* NERD
38  * ,-----------------------------------------------------------------------------------.
39  * | Esc  |   Q  |   W  |   E  |   R  |   T  |   Y  |   U  |   I  |   O  |   P  | Bksp |
40  * |------+------+------+------+------+-------------+------+------+------+------+------|
41  * | Tab  |   A  |   S  |   D  |   F  |   G  |   H  |   J  |   K  |   L  |   ;  |Enter |
42  * |------+------+------+------+------+------|------+------+------+------+------+------|
43  * | Shift|   Z  |   X  |   C  |   V  |   B  |   N  |   M  |   ,  |   .  |   /  |Shift |
44  * |------+------+------+------+------+------+------+------+------+------+------+------|
45  * | DEL  | Ctrl | Alt  | GUI  |Lower |    Space    |Raise | Left | Down |  Up  |Right |
46  * `-----------------------------------------------------------------------------------'
47  */
48 [_NERD] = {
49   {KC_ESC,  KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_U,    KC_I,    KC_O,    KC_P,    KC_BSPC},
50   {KC_TAB,  KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,    KC_SCLN, KC_ENT },
51   {KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_RSFT},
52   {KC_DEL,  KC_LCTL, KC_LALT, KC_LGUI, LOWER,   KC_SPC,  KC_SPC,  RAISE,   KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT}
53 },
54
55
56 /* Lower
57  * ,-----------------------------------------------------------------------------------.
58  * |   ~  |   !  |   @  |   #  |   $  |   %  |   ^  |   &  |   *  |   (  |   )  | Bksp |
59  * |------+------+------+------+------+-------------+------+------+------+------+------|
60  * | Del  |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |   _  |   +  |   {  |   }  |  \   |
61  * |------+------+------+------+------+------|------+------+------+------+------+------|
62  * |      |  F7  |  F8  |  F9  |  F10 |  F11 |  F12 |ISO ~ |ISO | | Home | End  |      |
63  * |------+------+------+------+------+------+------+------+------+------+------+------|
64  * |      |      |      |      |      |             |      | Next | Vol- | Vol+ | Play |
65  * `-----------------------------------------------------------------------------------'
66  */
67 [_LOWER] = {
68   {KC_TILD, KC_EXLM, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, KC_CIRC, KC_AMPR,    KC_ASTR,    KC_LPRN, KC_RPRN, KC_BSPC},
69   {KC_DEL,  KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_UNDS,    KC_PLUS,    KC_LCBR, KC_RCBR, KC_BSLS},
70   {_______, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  S(KC_NUHS), S(KC_NUBS), KC_HOME, KC_END,  _______},
71   {_______, _______, _______, _______, _______, _______, _______, _______,    KC_MNXT,    KC_VOLD, KC_VOLU, KC_MPLY}
72 },
73
74 /* Raise
75  * ,-----------------------------------------------------------------------------------.
76  * |   `  |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |   9  |   0  | Bksp |
77  * |------+------+------+------+------+-------------+------+------+------+------+------|
78  * | Del  |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |   -  |   =  |   [  |   ]  |  '   |
79  * |------+------+------+------+------+------|------+------+------+------+------+------|
80  * |      |  F7  |  F8  |  F9  |  F10 |  F11 |  F12 |ISO # |ISO / |Pg Up |Pg Dn |      |
81  * |------+------+------+------+------+------+------+------+------+------+------+------|
82  * |      |      |      |      |      |             |      | Next | Vol- | Vol+ | Play |
83  * `-----------------------------------------------------------------------------------'
84  */
85 [_RAISE] = {
86   {KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC},
87   {KC_DEL,  KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_MINS, KC_EQL,  KC_LBRC, KC_RBRC, KC_QUOT},
88   {_______, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  KC_NUHS, KC_NUBS, KC_PGUP, KC_PGDN, _______},
89   {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
90 },
91
92
93 /* Adjust (Lower + Raise)
94  * ,-----------------------------------------------------------------------------------.
95  * |      | Reset|      |      |      |      |      |      |      |      |      |  Del |
96  * |------+------+------+------+------+-------------+------+------+------+------+------|
97  * |      |      |      |Aud on|Audoff|AGnorm|AGswap| NERD |      |      |      |      |
98  * |------+------+------+------+------+------|------+------+------+------+------+------|
99  * |      |Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof|      |      |      |      |      |
100  * |------+------+------+------+------+------+------+------+------+------+------+------|
101  * |      |      |      |      |      |             |      |      |      |      |      |
102  * `-----------------------------------------------------------------------------------'
103  */
104 [_ADJUST] = {
105   {_______, RESET,   _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL },
106   {_______, _______, _______, AU_ON,   AU_OFF,  AG_NORM, AG_SWAP, NERD,    _______, _______, _______, _______},
107   {_______, MUV_DE,  MUV_IN,  MU_ON,   MU_OFF,  MI_ON,   MI_OFF,  _______, _______, _______, _______, _______},
108   {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
109 }
110
111
112 };
113
114 #ifdef AUDIO_ENABLE
115
116 float tone_startup[][2]    = SONG(STARTUP_SOUND);
117 float tone_nerd[][2]       = SONG(QWERTY_SOUND);
118 float music_scale[][2]     = SONG(MUSIC_SCALE_SOUND);
119
120 float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
121 #endif
122
123
124 void persistent_default_layer_set(uint16_t default_layer) {
125   eeconfig_update_default_layer(default_layer);
126   default_layer_set(default_layer);
127 }
128
129 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
130   switch (keycode) {
131     case NERD:
132       if (record->event.pressed) {
133         #ifdef AUDIO_ENABLE
134           PLAY_NOTE_ARRAY(tone_nerd, false, 0);
135         #endif
136         persistent_default_layer_set(1UL<<_NERD);
137       }
138       return false;
139       break;
140     case LOWER:
141       if (record->event.pressed) {
142         layer_on(_LOWER);
143         update_tri_layer(_LOWER, _RAISE, _ADJUST);
144       } else {
145         layer_off(_LOWER);
146         update_tri_layer(_LOWER, _RAISE, _ADJUST);
147       }
148       return false;
149       break;
150     case RAISE:
151       if (record->event.pressed) {
152         layer_on(_RAISE);
153         update_tri_layer(_LOWER, _RAISE, _ADJUST);
154       } else {
155         layer_off(_RAISE);
156         update_tri_layer(_LOWER, _RAISE, _ADJUST);
157       }
158       return false;
159       break;
160   }
161   return true;
162 }
163
164 void matrix_init_user(void) {
165     #ifdef AUDIO_ENABLE
166         startup_user();
167     #endif
168 }
169
170 #ifdef AUDIO_ENABLE
171
172 void startup_user()
173 {
174     _delay_ms(20); // gets rid of tick
175     PLAY_NOTE_ARRAY(tone_startup, false, 0);
176 }
177
178 void shutdown_user()
179 {
180     PLAY_NOTE_ARRAY(tone_goodbye, false, 0);
181     _delay_ms(150);
182     stop_all_notes();
183 }
184
185 void music_on_user(void)
186 {
187     music_scale_user();
188 }
189
190 void music_scale_user(void)
191 {
192     PLAY_NOTE_ARRAY(music_scale, false, 0);
193 }
194
195 #endif