aboutsummaryrefslogtreecommitdiff
path: root/keyboards/comet46/keymaps/default-rgbled/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/comet46/keymaps/default-rgbled/keymap.c')
-rw-r--r--keyboards/comet46/keymaps/default-rgbled/keymap.c223
1 files changed, 223 insertions, 0 deletions
diff --git a/keyboards/comet46/keymaps/default-rgbled/keymap.c b/keyboards/comet46/keymaps/default-rgbled/keymap.c
new file mode 100644
index 000000000..d1e5b663d
--- /dev/null
+++ b/keyboards/comet46/keymaps/default-rgbled/keymap.c
@@ -0,0 +1,223 @@
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
6// Each layer gets a name for readability, which is then used in the keymap matrix below.
7// The underscores don't mean anything - you can have a layer called STUFF or any other name.
8// Layer names don't all need to be of the same length, obviously, and you can also skip them
9// entirely and just use numbers.
10enum comet46_layers
11{
12 _QWERTY,
13 _COLEMAK,
14 _DVORAK,
15 _LOWER,
16 _RAISE,
17 _ADJUST,
18};
19
20enum custom_keycodes {
21 QWERTY = SAFE_RANGE,
22 COLEMAK,
23 DVORAK,
24 LOWER,
25 RAISE,
26};
27
28#define LOWER MO(_LOWER)
29#define RAISE MO(_RAISE)
30
31const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
32
33 /* Qwerty
34 * ,-----------------------------------------+ +-----------------------------------------.
35 * | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp |
36 * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------|
37 * | Ctl | A | S | D | F | G | Esc | | Del | H | J | K | L | ; | " |
38 * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------|
39 * | Shift| Z | X | C | V | B | { | | } | N | M | , | . | / | Shift|
40 * |------+------+------+------+------+------+------+ +------+------+------+------+------+-------------|
41 * | GUI | Lower| Space| | Enter| Raise| Alt |
42 * +--------------------/ \--------------------+
43 */
44 [_QWERTY] = LAYOUT(
45 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
46 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,
47 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,
48 KC_LGUI, LOWER, KC_SPC, KC_ENT, RAISE, KC_LALT
49 ),
50
51 /* Colemak
52 * ,-----------------------------------------+ +-----------------------------------------.
53 * | Tab | Q | W | F | P | G | | J | L | U | Y | ; | Bksp |
54 * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------|
55 * | Ctl | A | R | S | T | D | Esc | | Del | H | N | E | I | O | " |
56 * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------|
57 * | Shift| Z | X | C | V | B | { | | } | K | M | , | . | / | Shift|
58 * |------+------+------+------+------+------+------+ +------+------+------+------+------+-------------|
59 * | GUI | Lower| Space| | Enter| Raise| Alt |
60 * +--------------------/ \--------------------+
61 */
62 [_COLEMAK] = LAYOUT(
63 KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC,
64 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,
65 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,
66 KC_LGUI, LOWER, KC_SPC, KC_ENT, RAISE, KC_LALT
67 ),
68
69 /* Dvorak
70 * ,-----------------------------------------+ +-----------------------------------------.
71 * | Tab | " | , | . | P | Y | | F | G | C | R | L | Bksp |
72 * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------|
73 * | Ctl | A | O | E | U | I | Esc | | Del | D | H | T | N | S | / |
74 * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------|
75 * | Shift| ; | Q | J | K | X | { | | } | B | M | W | V | Z | Shift|
76 * |------+------+------+------+------+------+------+ +------+------+------+------+------+-------------|
77 * | GUI | Lower| Space| | Enter| Raise| Alt |
78 * +--------------------/ \--------------------+
79 */
80 [_DVORAK] = LAYOUT(
81 KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC,
82 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,
83 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,
84 KC_LGUI, LOWER, KC_SPC, KC_ENT, RAISE, KC_LALT
85 ),
86
87 /* Lower
88 * ,-----------------------------------------+ +-----------------------------------------.
89 * | | ! | @ | # | $ | % | | ^ | & | * | ( | ) | |
90 * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------|
91 * | | | | | | | | | ` | \ | - | = | [ | ] | |
92 * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------|
93 * | | | | | | | | | ~ | | | _ | + | { | } | |
94 * |------+------+------+------+------+------+------+ +------+------+------+------+------+-------------|
95 * | | | | | | | |
96 * +--------------------/ \--------------------+
97 */
98 [_LOWER] = LAYOUT(
99 _______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______,
100 _______, _______, _______, _______, _______, _______, _______, KC_GRV, KC_BSLS, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, _______,
101 _______, _______, _______, _______, _______, _______, _______, KC_TILD, KC_PIPE, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, _______,
102 _______, _______, _______, _______, _______, _______
103 ),
104
105 /* Raise
106 * ,-----------------------------------------+ +-----------------------------------------.
107 * | | 1 | 2 | 3 | 4 | 5 | | | | | | | |
108 * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------|
109 * | | F1 | F2 | F3 | F4 | F5 | F6 | | | Left | Down | Up |Right | End | |
110 * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------|
111 * | | F7 | F8 | F9 | F10 | F11 | F12 | | Home | | PgDn | PgUp | | | |
112 * |------+------+------+------+------+------+------+ +------+------+------+------+------+-------------|
113 * | | | | | | | |
114 * +--------------------/ \--------------------+
115 */
116 [_RAISE] = LAYOUT(
117 _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______,
118 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, XXXXXXX, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_END, _______,
119 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_HOME, XXXXXXX, KC_PGDN, KC_PGUP, XXXXXXX, XXXXXXX, _______,
120 _______, _______, _______, _______, _______, _______
121 ),
122
123 /* Adjust
124 * ,-----------------------------------------+ +-----------------------------------------.
125 * | | | | | | | | | | | | | |
126 * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------|
127 * | | | | | | |Qwerty| |Colemk| | | | | | |
128 * |------+------+------+------+------+------+------+ +------+------+------+------+------+------+------|
129 * | | | | | | |Reset | |Dvorak| | | | | | |
130 * |------+------+------+------+------+------+------+ +------+------+------+------+------+-------------|
131 * | | | | | | | |
132 * +--------------------/ \--------------------+
133 */
134 [_ADJUST] = LAYOUT(
135 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
136 _______, _______, _______, _______, _______, _______, QWERTY, COLEMAK, _______, _______, _______, _______, _______, _______,
137 _______, _______, _______, _______, _______, _______, RESET, DVORAK, _______, _______, _______, _______, _______, _______,
138 _______, _______, _______, _______, _______, _______
139 )
140};
141
142
143layer_state_t layer_state_set_user(layer_state_t state) {
144 return update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
145}
146
147// settings for LED on receiver
148void led_init(void) {
149 DDRD |= (1<<1);
150 PORTD |= (1<<1);
151 DDRF |= (1<<4) | (1<<5);
152 PORTF |= (1<<4) | (1<<5);
153}
154
155#define red_led_off PORTF |= (1<<5)
156#define red_led_on PORTF &= ~(1<<5)
157#define blu_led_off PORTF |= (1<<4)
158#define blu_led_on PORTF &= ~(1<<4)
159#define grn_led_off PORTD |= (1<<1)
160#define grn_led_on PORTD &= ~(1<<1)
161
162#define set_led_off red_led_off; grn_led_off; blu_led_off
163#define set_led_red red_led_on; grn_led_off; blu_led_off
164#define set_led_blue red_led_off; grn_led_off; blu_led_on
165#define set_led_green red_led_off; grn_led_on; blu_led_off
166#define set_led_yellow red_led_on; grn_led_on; blu_led_off
167#define set_led_magenta red_led_on; grn_led_off; blu_led_on
168#define set_led_cyan red_led_off; grn_led_on; blu_led_on
169#define set_led_white red_led_on; grn_led_on; blu_led_on
170
171void matrix_init_user(void) {
172 led_init();
173}
174
175void matrix_scan_user(void) {
176 uint8_t layer = biton32(layer_state);
177 uint8_t default_layer = biton32(eeconfig_read_default_layer());
178 switch (layer) {
179 case _LOWER:
180 set_led_red;
181 break;
182 case _RAISE:
183 set_led_blue;
184 break;
185 case _ADJUST:
186 set_led_magenta;
187 break;
188 default:
189 switch (default_layer) {
190 case _COLEMAK:
191 set_led_white;
192 break;
193 case _DVORAK:
194 set_led_yellow;
195 break;
196 default:
197 set_led_green;
198 break;
199 }
200 break;
201 }
202};
203
204bool process_record_user(uint16_t keycode, keyrecord_t *record) {
205 switch (keycode) {
206 case QWERTY:
207 if (record->event.pressed) {
208 set_single_persistent_default_layer(_QWERTY);
209 }
210 break;
211 case COLEMAK:
212 if (record->event.pressed) {
213 set_single_persistent_default_layer(_COLEMAK);
214 }
215 break;
216 case DVORAK:
217 if (record->event.pressed) {
218 set_single_persistent_default_layer(_DVORAK);
219 }
220 break;
221 }
222 return true;
223}