diff options
Diffstat (limited to 'keyboards/clueboard_66/keymaps/magicmonty/keymap.c')
-rw-r--r-- | keyboards/clueboard_66/keymaps/magicmonty/keymap.c | 230 |
1 files changed, 230 insertions, 0 deletions
diff --git a/keyboards/clueboard_66/keymaps/magicmonty/keymap.c b/keyboards/clueboard_66/keymaps/magicmonty/keymap.c new file mode 100644 index 000000000..6df7d7869 --- /dev/null +++ b/keyboards/clueboard_66/keymaps/magicmonty/keymap.c | |||
@@ -0,0 +1,230 @@ | |||
1 | #include "clueboard_66.h" | ||
2 | |||
3 | // Helpful defines | ||
4 | #define _______ KC_TRNS | ||
5 | #define xxxxxxx KC_NO | ||
6 | |||
7 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
8 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
9 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
10 | // entirely and just use numbers. | ||
11 | #define _BL 0 // BASE Layer | ||
12 | #define _FL 1 // Function Layer | ||
13 | #define _ME 2 // Media Layer | ||
14 | #define _CL 3 // Control Layer | ||
15 | #define _ML 4 // Mouse Layer | ||
16 | #if defined(MIDI_ENABLE) | ||
17 | #define _MI 5 // MIDI Layer | ||
18 | #define TO_MIDI TO(_MI) | ||
19 | #else | ||
20 | #define TO_MIDI _______ | ||
21 | #endif | ||
22 | |||
23 | // go back to base layer | ||
24 | #define TO_BASE TO(_BL) | ||
25 | |||
26 | // switch to function layer while helde | ||
27 | #define MO_FUNC MO(_FL) | ||
28 | |||
29 | // switch to media layer while held | ||
30 | #define MEDIA MO(_ME) | ||
31 | |||
32 | // switch to Control layer while helde | ||
33 | #define MO_CTL MO(_CL) | ||
34 | |||
35 | // switch to mouse layer if held, else space | ||
36 | #define L_MOUSE LT(_ML, KC_SPC) | ||
37 | |||
38 | // Function key when held, else ESC | ||
39 | #define ESC_FUN LT(_FL, KC_ESC) | ||
40 | |||
41 | // Hyper (CTRL+ALT+SHIFT+SUPER) when held, TAB when tapped | ||
42 | #define HPR_TAB ALL_T(KC_TAB) | ||
43 | |||
44 | // CTRL when held, ESC when tapped | ||
45 | #define CTL_ESC CTL_T(KC_ESC) | ||
46 | |||
47 | // Reset RGB mode to layer signalling | ||
48 | #define RGB_RST F(0) | ||
49 | |||
50 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
51 | /* Keymap _BL: Base Layer (Default Layer) */ | ||
52 | [_BL] = KEYMAP( | ||
53 | KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, _______, KC_BSPC, KC_INS, \ | ||
54 | HPR_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, \ | ||
55 | ESC_FUN, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_NUHS, KC_ENT, \ | ||
56 | KC_LSFT, KC_NUBS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, _______, KC_RSFT, KC_UP, \ | ||
57 | KC_LCTL, KC_LGUI, KC_LALT,_______, L_MOUSE, L_MOUSE, _______, KC_RALT, KC_RCTL, MO_FUNC, KC_LEFT, KC_DOWN, KC_RGHT), | ||
58 | |||
59 | /* Keymap _FL: Function layer */ | ||
60 | [_FL] = KEYMAP( | ||
61 | KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, BL_STEP, \ | ||
62 | _______, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, _______, KC_PAUS, _______, _______, _______, _______, \ | ||
63 | _______, _______, MO_CTL, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, _______, _______, _______, \ | ||
64 | KC_LSPO, _______, _______, _______, _______, _______, _______, _______, MEDIA, _______, _______, TO_MIDI, _______, KC_RSPC, KC_PGUP, \ | ||
65 | _______, _______, _______, _______, _______, _______, _______, _______, _______, MO_FUNC, KC_HOME, KC_PGDN, KC_END), | ||
66 | |||
67 | /* Keymap _ME: Media layer */ | ||
68 | [_ME] = KEYMAP( | ||
69 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, KC_VOLU, \ | ||
70 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_VOLD, \ | ||
71 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
72 | _______, _______, _______, _______, _______, _______, _______, _______, MEDIA, _______, _______, _______, _______, _______, _______, \ | ||
73 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MPLY, KC_MNXT), | ||
74 | |||
75 | /* Keymap _CL: Control layer */ | ||
76 | [_CL] = KEYMAP( | ||
77 | _______, RGB_RST, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_VAI, \ | ||
78 | _______, _______, _______, _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_VAD, \ | ||
79 | _______, _______, MO_CTL, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
80 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SAI, \ | ||
81 | _______, _______, _______, _______, RGB_MOD, RGB_MOD, _______, _______, _______, _______, RGB_HUD, RGB_SAD, RGB_HUI), | ||
82 | |||
83 | /* Keymap _ML: Mouse layer */ | ||
84 | [_ML] = KEYMAP( | ||
85 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
86 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
87 | _______, _______, KC_BTN2, KC_BTN3, KC_BTN1, _______, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, _______, _______, _______, _______, \ | ||
88 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MS_U, \ | ||
89 | _______, _______, _______, _______, L_MOUSE, L_MOUSE, _______, KC_BTN1, KC_BTN3, KC_BTN2, KC_MS_L, KC_MS_D, KC_MS_R), | ||
90 | |||
91 | #if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED) | ||
92 | /* Keymap _MI: MIDI layer (Advanced)*/ | ||
93 | [_MI] = KEYMAP( | ||
94 | TO_BASE,MI_VEL_1,MI_VEL_2,MI_VEL_3,MI_VEL_4,MI_VEL_5,MI_VEL_6,MI_VEL_7,MI_VEL_8,MI_VEL_9,MI_VEL_10, MI_CHD, MI_CHU, xxxxxxx, xxxxxxx, xxxxxxx, \ | ||
95 | xxxxxxx, xxxxxxx, MI_Cs, MI_Ds, xxxxxxx, MI_Fs, MI_Gs, MI_As, xxxxxxx, MI_Cs_1, MI_Ds_1, xxxxxxx, MI_Fs_1, xxxxxxx, xxxxxxx, \ | ||
96 | MI_MOD, MI_C, MI_D, MI_E, MI_F, MI_G, MI_A, MI_B, MI_C_1, MI_D_1, MI_E_1, MI_F_1, MI_G_1, xxxxxxx, \ | ||
97 | MI_SUS, xxxxxxx, MI_OCTD, MI_OCTU,MI_MODSD,MI_MODSU, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, MI_TRNSD,MI_TRNSU,MI_TRNS_0, MI_SUS, xxxxxxx, \ | ||
98 | xxxxxxx, xxxxxxx, xxxxxxx,xxxxxxx, MI_ALLOFF, MI_ALLOFF, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx), | ||
99 | #elif defined(MIDI_ENABLE) && defined(MIDI_BASIC) | ||
100 | /* Keymap _MI: MIDI layer (Basic)*/ | ||
101 | [_MI] = KEYMAP( | ||
102 | TO_BASE, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, \ | ||
103 | xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, \ | ||
104 | xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, \ | ||
105 | xxxxxxx, xxxxxxx, MI_ON, MI_OFF, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, \ | ||
106 | xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx, xxxxxxx), | ||
107 | #endif | ||
108 | }; | ||
109 | |||
110 | /* This is a list of user defined functions. F(N) corresponds to item N | ||
111 | of this list. | ||
112 | */ | ||
113 | const uint16_t PROGMEM fn_actions[] = { | ||
114 | [0] = ACTION_FUNCTION(0), // Calls action_function() | ||
115 | }; | ||
116 | |||
117 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { | ||
118 | switch (id) { | ||
119 | case 0: | ||
120 | if (record->event.pressed) { | ||
121 | rgblight_mode(1); | ||
122 | rgblight_sethsv(206, 255, 255); | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | |||
127 | enum layer_id { | ||
128 | LAYER_BASE, | ||
129 | LAYER_FUNCTION, | ||
130 | LAYER_MEDIA, | ||
131 | LAYER_CONTROL, | ||
132 | LAYER_MOUSE, | ||
133 | #if defined(MIDI_ENABLE) | ||
134 | LAYER_MIDI | ||
135 | #endif | ||
136 | }; | ||
137 | |||
138 | void clueboard_set_led(uint8_t id, uint8_t val) { | ||
139 | switch (id) { | ||
140 | case LAYER_BASE: | ||
141 | rgblight_sethsv_noeeprom(0, 0, val); | ||
142 | break; | ||
143 | case LAYER_FUNCTION: | ||
144 | rgblight_sethsv_noeeprom(46, 255, val); | ||
145 | break; | ||
146 | case LAYER_MEDIA: | ||
147 | rgblight_sethsv_noeeprom(86, 255, val); | ||
148 | break; | ||
149 | case LAYER_CONTROL: | ||
150 | rgblight_sethsv_noeeprom(346, 255, val); | ||
151 | break; | ||
152 | case LAYER_MOUSE: | ||
153 | rgblight_sethsv_noeeprom(206, 255, val); | ||
154 | break; | ||
155 | #if defined(MIDI_ENABLE) | ||
156 | case LAYER_MIDI: | ||
157 | rgblight_sethsv_noeeprom(316, 255, val); | ||
158 | break; | ||
159 | #endif | ||
160 | } | ||
161 | }; | ||
162 | |||
163 | const uint16_t oct_hues[10] = { | ||
164 | 0, | ||
165 | 30, | ||
166 | 60, | ||
167 | 90, | ||
168 | 120, | ||
169 | 150, | ||
170 | 180, | ||
171 | 210, | ||
172 | 240, | ||
173 | 300 | ||
174 | }; | ||
175 | |||
176 | #define MAX_OCT 9 | ||
177 | |||
178 | void clueboard_set_midi_led(uint8_t base_oct, uint8_t val) | ||
179 | { | ||
180 | uint8_t sat = 255; | ||
181 | |||
182 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | ||
183 | sethsv(oct_hues[base_oct], sat, val, (LED_TYPE *)&led[i]); | ||
184 | } | ||
185 | |||
186 | uint8_t next_oct = base_oct < MAX_OCT ? base_oct + 1 : base_oct; | ||
187 | |||
188 | uint16_t next_hue = base_oct < MAX_OCT ? oct_hues[next_oct] : 0; | ||
189 | uint8_t next_val = base_oct < MAX_OCT ? val : 0; | ||
190 | uint8_t next_sat = base_oct < MAX_OCT ? sat : 0; | ||
191 | |||
192 | |||
193 | for (uint8_t i = 0; i < 3; i++) { | ||
194 | sethsv(next_hue, next_sat, next_val, (LED_TYPE *)&led[i]); | ||
195 | } | ||
196 | |||
197 | for (uint8_t i = 11; i < 14; i++) { | ||
198 | sethsv(next_hue, next_sat, next_val, (LED_TYPE *)&led[i]); | ||
199 | } | ||
200 | |||
201 | rgblight_set(); | ||
202 | } | ||
203 | |||
204 | void matrix_scan_user(void) { | ||
205 | rgblight_config_t rgblight_config; | ||
206 | rgblight_config.raw = eeconfig_read_rgblight(); | ||
207 | |||
208 | if (!rgblight_config.enable || rgblight_config.mode != 1) { return; } | ||
209 | |||
210 | uint32_t layer = layer_state; | ||
211 | uint8_t val = rgblight_config.val; | ||
212 | |||
213 | if (layer & (1<<_FL)) { | ||
214 | if (layer & (1<<_ME)) { | ||
215 | clueboard_set_led(LAYER_MEDIA, val); | ||
216 | } else if (layer & (1<<_CL)) { | ||
217 | clueboard_set_led(LAYER_CONTROL, val); | ||
218 | } else { | ||
219 | clueboard_set_led(LAYER_FUNCTION, val); | ||
220 | } | ||
221 | } else if (layer & (1<<_ML)) { | ||
222 | clueboard_set_led(LAYER_MOUSE, val); | ||
223 | #if defined(MIDI_ENABLE) | ||
224 | } else if (layer & (1<<_MI)) { | ||
225 | clueboard_set_midi_led(midi_config.octave, val); | ||
226 | #endif | ||
227 | } else { | ||
228 | clueboard_set_led(LAYER_BASE, val); | ||
229 | } | ||
230 | }; | ||