aboutsummaryrefslogtreecommitdiff
path: root/keyboards/mlego/m60_split/keymaps/default/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/mlego/m60_split/keymaps/default/keymap.c')
-rw-r--r--keyboards/mlego/m60_split/keymaps/default/keymap.c193
1 files changed, 193 insertions, 0 deletions
diff --git a/keyboards/mlego/m60_split/keymaps/default/keymap.c b/keyboards/mlego/m60_split/keymaps/default/keymap.c
new file mode 100644
index 000000000..5e3912b0b
--- /dev/null
+++ b/keyboards/mlego/m60_split/keymaps/default/keymap.c
@@ -0,0 +1,193 @@
1/*
2Copyright 2021-2022 Alin M Elena <alinm.elena@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include QMK_KEYBOARD_H
19
20enum layer_names {
21 _QW = 0,
22 _LWR,
23 _RSE,
24 _ADJ
25};
26
27#define LOWER TT(_LWR)
28#define RAISE TT(_RSE)
29
30#ifdef RGBLIGHT_ENABLE
31
32const rgblight_segment_t PROGMEM my_qwerty_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_PURPLE});
33const rgblight_segment_t PROGMEM my_lwr_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_CYAN});
34const rgblight_segment_t PROGMEM my_rse_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_RED});
35const rgblight_segment_t PROGMEM my_adj_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_GREEN});
36
37const rgblight_segment_t* const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(my_qwerty_layer, my_lwr_layer, my_rse_layer, my_adj_layer);
38#endif
39
40// clang-format off
41const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
42[_QW] = LAYOUT_ortho_5x12(
43
44 KC_GRV , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , KC_BSPC,
45 KC_ESC , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P , KC_DEL ,
46 KC_TAB , KC_A , KC_S , KC_D , KC_F , KC_G , 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_N , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_ENT ,
48 KC_LCTL, KC_LGUI, KC_LALT, KC_APP, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP , KC_RGHT
49
50 ),
51
52[_LWR] = LAYOUT_ortho_5x12(
53
54 KC_TILD, KC_EXLM, KC_AT , KC_HASH, KC_DLR , KC_PERC, KC_CIRC, KC_AMPR , KC_ASTR , KC_LPRN, KC_RPRN, KC_DEL ,
55 KC_DEL , KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_UNDS , KC_PLUS , KC_LCBR, KC_RCBR, KC_PIPE,
56 _______, KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , S(KC_NUHS), S(KC_NUBS), _______, _______, _______,
57 _______, _______, _______, _______, _______, _______, _______, _______ , KC_MNXT , KC_VOLD, KC_VOLU, KC_MPLY,
58 _______, _______, _______, _______, _______, _______, _______, _______ , _______ , _______, _______, _______
59
60 ),
61
62[_RSE] = LAYOUT_ortho_5x12(
63
64 KC_GRV , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , KC_DEL ,
65 KC_DEL , KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_MINS, KC_EQL , KC_LBRC, KC_RBRC, KC_BSLS,
66 _______, KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , KC_NUHS, KC_NUBS, _______, _______, _______,
67 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY,
68 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
69
70 ),
71
72[_ADJ] = LAYOUT_ortho_5x12(
73
74 _______, RESET , _______, _______, _______, _______, RGB_TOG, RGB_MOD, RGB_RMOD, RGB_M_G, RESET , _______,
75 _______, _______, _______, _______, _______, _______, RGB_HUI, RGB_SAI, RGB_VAI , _______, _______, _______,
76 _______, _______, _______, _______, _______, _______, RGB_HUD, RGB_SAD, RGB_VAD , _______, _______, _______,
77 _______, _______, _______, _______, _______, _______, _______, _______, _______ , _______, _______, _______,
78 _______, _______, _______, _______, _______, _______, _______, _______, _______ , _______, _______, _______
79
80 )
81
82};
83// clang-format on
84
85// let us assume we start with both layers off
86bool toggle_lwr = false;
87bool toggle_rse = false;
88
89bool led_update_user(led_t led_state) {
90 // Disable the default LED update code, so that lock LEDs could be reused to show layer status.
91 return false;
92}
93
94void matrix_scan_user(void) {
95 led_lwr(toggle_lwr);
96 led_rse(toggle_rse);
97 led_t led_state = host_keyboard_led_state();
98 led_caps(led_state.caps_lock);
99 if (layer_state_is(_ADJ)) {
100 led_lwr(true);
101 led_rse(true);
102 }
103}
104
105void matrix_slave_scan_user(void) {
106 matrix_scan_user();
107 if (IS_LAYER_ON(_LWR)) {
108 led_lwr(layer_state_is(_LWR));
109 }
110 if (IS_LAYER_ON(_RSE)) {
111 led_rse(layer_state_is(_RSE));
112 }
113}
114
115bool process_record_user(uint16_t keycode, keyrecord_t* record) {
116 switch (keycode) {
117 case (TT(_LWR)):
118 if (!record->event.pressed && record->tap.count == TAPPING_TOGGLE) {
119 // This runs before the TT() handler toggles the layer state, so the current layer state is the opposite of the final one after toggle.
120 toggle_lwr = !layer_state_is(_LWR);
121 }
122 return true;
123 break;
124 case (TT(_RSE)):
125 if (record->event.pressed && record->tap.count == TAPPING_TOGGLE) {
126 toggle_rse = !layer_state_is(_RSE);
127 }
128 return true;
129 break;
130 default:
131 return true;
132 }
133}
134
135layer_state_t layer_state_set_user(layer_state_t state) {
136#ifdef RGBLIGHT_ENABLE
137
138 rgblight_set_layer_state(0, layer_state_cmp(state, _QW));
139 rgblight_set_layer_state(1, layer_state_cmp(state, _LWR));
140 rgblight_set_layer_state(2, layer_state_cmp(state, _RSE));
141 rgblight_set_layer_state(3, layer_state_cmp(state, _ADJ));
142
143#endif
144 return update_tri_layer_state(state, _LWR, _RSE, _ADJ);
145}
146
147#ifdef RGBLIGHT_ENABLE
148
149layer_state_t default_layer_state_set_user(layer_state_t state) {
150 rgblight_set_layer_state(0, layer_state_cmp(state, _QW));
151 return state;
152}
153
154void keyboard_post_init_user(void) {
155 // Enable the LED layers
156 rgblight_layers = my_rgb_layers;
157}
158#endif
159
160#ifdef ENCODER_ENABLE
161
162# define MEDIA_KEY_DELAY 10
163
164static inline void my_encoders(const uint8_t index, const bool clockwise) {
165 if (index == 0 || (index == 1)) { /* First encoder on each side*/
166 if (IS_LAYER_ON(_LWR)) {
167 if (clockwise) {
168 rgblight_decrease_val_noeeprom();
169 } else {
170 rgblight_increase_val_noeeprom();
171 }
172 } else if (IS_LAYER_ON(_RSE)) {
173 if (clockwise) {
174 rgblight_decrease_hue_noeeprom();
175 } else {
176 rgblight_increase_hue_noeeprom();
177 }
178
179 } else {
180 if (clockwise) {
181 tap_code_delay(KC_VOLD, MEDIA_KEY_DELAY);
182 } else {
183 tap_code_delay(KC_VOLU, MEDIA_KEY_DELAY);
184 }
185 }
186 }
187}
188
189bool encoder_update_user(uint8_t index, bool clockwise) {
190 my_encoders(index, clockwise);
191 return true;
192}
193#endif