diff options
Diffstat (limited to 'keyboards/comet46/keymaps/default/keymap.c')
-rw-r--r-- | keyboards/comet46/keymaps/default/keymap.c | 253 |
1 files changed, 253 insertions, 0 deletions
diff --git a/keyboards/comet46/keymaps/default/keymap.c b/keyboards/comet46/keymaps/default/keymap.c new file mode 100644 index 000000000..7a8c29dcb --- /dev/null +++ b/keyboards/comet46/keymaps/default/keymap.c | |||
@@ -0,0 +1,253 @@ | |||
1 | // this is the style you want to emulate. | ||
2 | // This is the canonical layout file for the Quantum project. If you want to add another keyboard, | ||
3 | |||
4 | #include QMK_KEYBOARD_H | ||
5 | #ifdef SSD1306OLED | ||
6 | #include "ssd1306.h" | ||
7 | #endif | ||
8 | |||
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 | enum comet46_layers | ||
15 | { | ||
16 | _QWERTY, | ||
17 | _COLEMAK, | ||
18 | _DVORAK, | ||
19 | _LOWER, | ||
20 | _RAISE, | ||
21 | _ADJUST, | ||
22 | }; | ||
23 | |||
24 | enum custom_keycodes { | ||
25 | QWERTY = SAFE_RANGE, | ||
26 | COLEMAK, | ||
27 | DVORAK, | ||
28 | LOWER, | ||
29 | RAISE, | ||
30 | }; | ||
31 | |||
32 | #define LOWER MO(_LOWER) | ||
33 | #define RAISE MO(_RAISE) | ||
34 | |||
35 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
36 | |||
37 | /* Qwerty | ||
38 | * ,-----------------------------------------+ +-----------------------------------------. | ||
39 | * | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp | | ||
40 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------| | ||
41 | * | Ctl | A | S | D | F | G | Esc | | Del | H | J | K | L | ; | " | | ||
42 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------| | ||
43 | * | Shift| Z | X | C | V | B | { | | } | N | M | , | . | / | Shift| | ||
44 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+-------------| | ||
45 | * | GUI | Lower| Space| | Enter| Raise| Alt | | ||
46 | * +--------------------/ \--------------------+ | ||
47 | */ | ||
48 | [_QWERTY] = LAYOUT( | ||
49 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, | ||
50 | KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_ESC, KC_DEL, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, | ||
51 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LCBR, KC_RCBR, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, | ||
52 | KC_LGUI, LOWER, KC_SPC, KC_ENT, RAISE, KC_LALT | ||
53 | ), | ||
54 | |||
55 | /* Colemak | ||
56 | * ,-----------------------------------------+ +-----------------------------------------. | ||
57 | * | Tab | Q | W | F | P | G | | J | L | U | Y | ; | Bksp | | ||
58 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------| | ||
59 | * | Ctl | A | R | S | T | D | Esc | | Del | H | N | E | I | O | " | | ||
60 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------| | ||
61 | * | Shift| Z | X | C | V | B | { | | } | K | M | , | . | / | Shift| | ||
62 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+-------------| | ||
63 | * | GUI | Lower| Space| | Enter| Raise| Alt | | ||
64 | * +--------------------/ \--------------------+ | ||
65 | */ | ||
66 | [_COLEMAK] = LAYOUT( | ||
67 | KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, | ||
68 | KC_LCTL, KC_A, KC_R, KC_S, KC_T, KC_D, KC_ESC, KC_DEL, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, | ||
69 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LCBR, KC_RCBR, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, | ||
70 | KC_LGUI, LOWER, KC_SPC, KC_ENT, RAISE, KC_LALT | ||
71 | ), | ||
72 | |||
73 | /* Dvorak | ||
74 | * ,-----------------------------------------+ +-----------------------------------------. | ||
75 | * | Tab | " | , | . | P | Y | | F | G | C | R | L | Bksp | | ||
76 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------| | ||
77 | * | Ctl | A | O | E | U | I | Esc | | Del | D | H | T | N | S | / | | ||
78 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------| | ||
79 | * | Shift| ; | Q | J | K | X | { | | } | B | M | W | V | Z | Shift| | ||
80 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+-------------| | ||
81 | * | GUI | Lower| Space| | Enter| Raise| Alt | | ||
82 | * +--------------------/ \--------------------+ | ||
83 | */ | ||
84 | [_DVORAK] = LAYOUT( | ||
85 | KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC, | ||
86 | KC_LCTL, KC_A, KC_O, KC_E, KC_U, KC_I, KC_ESC, KC_DEL, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, | ||
87 | KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_LCBR, KC_RCBR, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_RSFT, | ||
88 | KC_LGUI, LOWER, KC_SPC, KC_ENT, RAISE, KC_LALT | ||
89 | ), | ||
90 | |||
91 | /* Lower | ||
92 | * ,-----------------------------------------+ +-----------------------------------------. | ||
93 | * | | ! | @ | # | $ | % | | ^ | & | * | ( | ) | | | ||
94 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------| | ||
95 | * | | | | | | | | | ` | \ | - | = | [ | ] | | | ||
96 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------| | ||
97 | * | | | | | | | | | ~ | | | _ | + | { | } | | | ||
98 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+-------------| | ||
99 | * | | | | | | | | | ||
100 | * +--------------------/ \--------------------+ | ||
101 | */ | ||
102 | [_LOWER] = LAYOUT( | ||
103 | _______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, | ||
104 | _______, _______, _______, _______, _______, _______, _______, KC_GRV, KC_BSLS, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, _______, | ||
105 | _______, _______, _______, _______, _______, _______, _______, KC_TILD, KC_PIPE, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, _______, | ||
106 | _______, _______, _______, _______, _______, _______ | ||
107 | ), | ||
108 | |||
109 | /* Raise | ||
110 | * ,-----------------------------------------+ +-----------------------------------------. | ||
111 | * | | 1 | 2 | 3 | 4 | 5 | | | | | | | | | ||
112 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------| | ||
113 | * | | F1 | F2 | F3 | F4 | F5 | F6 | | | Left | Down | Up |Right | End | | | ||
114 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------| | ||
115 | * | | F7 | F8 | F9 | F10 | F11 | F12 | | Home | | PgDn | PgUp | | | | | ||
116 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+-------------| | ||
117 | * | | | | | | | | | ||
118 | * +--------------------/ \--------------------+ | ||
119 | */ | ||
120 | [_RAISE] = LAYOUT( | ||
121 | _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, | ||
122 | _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, XXXXXXX, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_END, _______, | ||
123 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_HOME, XXXXXXX, KC_PGDN, KC_PGUP, XXXXXXX, XXXXXXX, _______, | ||
124 | _______, _______, _______, _______, _______, _______ | ||
125 | ), | ||
126 | |||
127 | /* Adjust | ||
128 | * ,-----------------------------------------+ +-----------------------------------------. | ||
129 | * | | | | | | | | | | | | | | | ||
130 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------| | ||
131 | * | | | | | | |Qwerty| |Colemk| | | | | | | | ||
132 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------| | ||
133 | * | | | | | | |Reset | |Dvorak| | | | | | | | ||
134 | * |------+------+------+------+------+------+------+ +------+------+------+------+------+-------------| | ||
135 | * | | | | | | | | | ||
136 | * +--------------------/ \--------------------+ | ||
137 | */ | ||
138 | [_ADJUST] = LAYOUT( | ||
139 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
140 | _______, _______, _______, _______, _______, _______, QWERTY, COLEMAK, _______, _______, _______, _______, _______, _______, | ||
141 | _______, _______, _______, _______, _______, _______, RESET, DVORAK, _______, _______, _______, _______, _______, _______, | ||
142 | _______, _______, _______, _______, _______, _______ | ||
143 | ) | ||
144 | }; | ||
145 | |||
146 | |||
147 | layer_state_t layer_state_set_user(layer_state_t state) { | ||
148 | return update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST); | ||
149 | } | ||
150 | |||
151 | //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h | ||
152 | #ifdef SSD1306OLED | ||
153 | |||
154 | // You need to add source files to SRC in rules.mk when using OLED display functions | ||
155 | void set_keylog(uint16_t keycode); | ||
156 | const char *read_keylog(void); | ||
157 | const char *read_modifier_state(void); | ||
158 | const char *read_host_led_state(void); | ||
159 | |||
160 | void matrix_init_user(void) { | ||
161 | iota_gfx_init(false); // turns on the display | ||
162 | } | ||
163 | |||
164 | void matrix_scan_user(void) { | ||
165 | iota_gfx_task(); // this is what updates the display continuously | ||
166 | } | ||
167 | |||
168 | void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) { | ||
169 | if (memcmp(dest->display, source->display, sizeof(dest->display))) { | ||
170 | memcpy(dest->display, source->display, sizeof(dest->display)); | ||
171 | dest->dirty = true; | ||
172 | } | ||
173 | } | ||
174 | |||
175 | void render_status(struct CharacterMatrix *matrix) { | ||
176 | // Layer state | ||
177 | char layer_str[22]; | ||
178 | matrix_write(matrix, "Layer: "); | ||
179 | uint8_t layer = biton32(layer_state); | ||
180 | uint8_t default_layer = biton32(eeconfig_read_default_layer()); | ||
181 | switch (layer) { | ||
182 | case _QWERTY: | ||
183 | switch (default_layer) { | ||
184 | case _QWERTY: | ||
185 | snprintf(layer_str, sizeof(layer_str), "Qwerty"); | ||
186 | break; | ||
187 | case _COLEMAK: | ||
188 | snprintf(layer_str, sizeof(layer_str), "Colemak"); | ||
189 | break; | ||
190 | case _DVORAK: | ||
191 | snprintf(layer_str, sizeof(layer_str), "Dvorak"); | ||
192 | break; | ||
193 | default: | ||
194 | snprintf(layer_str, sizeof(layer_str), "Undef-%d", default_layer); | ||
195 | break; | ||
196 | } | ||
197 | break; | ||
198 | case _RAISE: | ||
199 | snprintf(layer_str, sizeof(layer_str), "Raise"); | ||
200 | break; | ||
201 | case _LOWER: | ||
202 | snprintf(layer_str, sizeof(layer_str), "Lower"); | ||
203 | break; | ||
204 | case _ADJUST: | ||
205 | snprintf(layer_str, sizeof(layer_str), "Adjust"); | ||
206 | break; | ||
207 | default: | ||
208 | snprintf(layer_str, sizeof(layer_str), "Undef-%d", layer); | ||
209 | } | ||
210 | matrix_write_ln(matrix, layer_str); | ||
211 | // Last entered keycode | ||
212 | matrix_write_ln(matrix, read_keylog()); | ||
213 | // Modifier state | ||
214 | matrix_write_ln(matrix, read_modifier_state()); | ||
215 | // Host Keyboard LED Status | ||
216 | matrix_write(matrix, read_host_led_state()); | ||
217 | } | ||
218 | |||
219 | |||
220 | void iota_gfx_task_user(void) { | ||
221 | struct CharacterMatrix matrix; | ||
222 | matrix_clear(&matrix); | ||
223 | render_status(&matrix); | ||
224 | matrix_update(&display, &matrix); | ||
225 | } | ||
226 | |||
227 | #endif//SSD1306OLED | ||
228 | |||
229 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
230 | #ifdef SSD1306OLED | ||
231 | if (record->event.pressed) { | ||
232 | set_keylog(keycode); | ||
233 | } | ||
234 | #endif | ||
235 | switch (keycode) { | ||
236 | case QWERTY: | ||
237 | if (record->event.pressed) { | ||
238 | set_single_persistent_default_layer(_QWERTY); | ||
239 | } | ||
240 | break; | ||
241 | case COLEMAK: | ||
242 | if (record->event.pressed) { | ||
243 | set_single_persistent_default_layer(_COLEMAK); | ||
244 | } | ||
245 | break; | ||
246 | case DVORAK: | ||
247 | if (record->event.pressed) { | ||
248 | set_single_persistent_default_layer(_DVORAK); | ||
249 | } | ||
250 | break; | ||
251 | } | ||
252 | return true; | ||
253 | } | ||