aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/ergodox_ez/keymaps/default/config.h30
-rw-r--r--keyboards/ergodox_ez/keymaps/default/keymap.c42
-rw-r--r--tmk_core/common/action_layer.c7
-rw-r--r--tmk_core/common/action_layer.h2
4 files changed, 72 insertions, 9 deletions
diff --git a/keyboards/ergodox_ez/keymaps/default/config.h b/keyboards/ergodox_ez/keymaps/default/config.h
new file mode 100644
index 000000000..850848c01
--- /dev/null
+++ b/keyboards/ergodox_ez/keymaps/default/config.h
@@ -0,0 +1,30 @@
1/*
2Copyright 2017 Jack Humbert <jack.humbgmail.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#ifndef ERGODOX_EZ_USER_CONFIG_H
19#define ERGODOX_EZ_USRE_CONFIG_H
20
21#include "config_common.h"
22
23#define RGBLIGHT_COLOR_LAYER_0 0x00, 0x00, 0xFF
24#define RGBLIGHT_COLOR_LAYER_1 0xFF, 0x00, 0x00
25#define RGBLIGHT_COLOR_LAYER_2 0x00, 0xFF, 0x00
26#define RGBLIGHT_COLOR_LAYER_3 0xFF, 0xFF, 0x00
27#define RGBLIGHT_COLOR_LAYER_4 0x00, 0xFF, 0xFF
28#define RGBLIGHT_COLOR_LAYER_5 0xFF, 0x00, 0xFF
29
30#endif \ No newline at end of file
diff --git a/keyboards/ergodox_ez/keymaps/default/keymap.c b/keyboards/ergodox_ez/keymaps/default/keymap.c
index 4f0136880..ccb4ae3ad 100644
--- a/keyboards/ergodox_ez/keymaps/default/keymap.c
+++ b/keyboards/ergodox_ez/keymaps/default/keymap.c
@@ -197,27 +197,53 @@ void matrix_init_user(void) {
197 197
198}; 198};
199 199
200
201// Runs constantly in the background, in a loop. 200// Runs constantly in the background, in a loop.
202void matrix_scan_user(void) { 201void matrix_scan_user(void) {
203 202
204 uint8_t layer = biton32(layer_state); 203};
205 204
205// Runs whenever there is a layer state change.
206uint32_t layer_state_set_user(uint32_t state) {
206 ergodox_board_led_off(); 207 ergodox_board_led_off();
207 ergodox_right_led_1_off(); 208 ergodox_right_led_1_off();
208 ergodox_right_led_2_off(); 209 ergodox_right_led_2_off();
209 ergodox_right_led_3_off(); 210 ergodox_right_led_3_off();
211
212 uint8_t layer = biton32(state);
210 switch (layer) { 213 switch (layer) {
211 // TODO: Make this relevant to the ErgoDox EZ. 214 case 0:
212 case SYMB: 215 #ifdef RGBLIGHT_COLOR_LAYER_0
216 rgblight_setrgb(RGBLIGHT_COLOR_LAYER_0);
217 #endif
218 break;
219 case 1:
213 ergodox_right_led_1_on(); 220 ergodox_right_led_1_on();
221 #ifdef RGBLIGHT_COLOR_LAYER_1
222 rgblight_setrgb(RGBLIGHT_COLOR_LAYER_1);
223 #endif
214 break; 224 break;
215 case MDIA: 225 case 2:
216 ergodox_right_led_2_on(); 226 ergodox_right_led_2_on();
227 #ifdef RGBLIGHT_COLOR_LAYER_2
228 rgblight_setrgb(RGBLIGHT_COLOR_LAYER_2);
229 #endif
230 break;
231 case 3:
232 #ifdef RGBLIGHT_COLOR_LAYER_3
233 rgblight_setrgb(RGBLIGHT_COLOR_LAYER_3);
234 #endif
217 break; 235 break;
218 default: 236 case 4:
219 // none 237 #ifdef RGBLIGHT_COLOR_LAYER_4
238 rgblight_setrgb(RGBLIGHT_COLOR_LAYER_4);
239 #endif
240 break;
241 case 5:
242 #ifdef RGBLIGHT_COLOR_LAYER_5
243 rgblight_setrgb(RGBLIGHT_COLOR_LAYER_5);
244 #endif
220 break; 245 break;
221 } 246 }
222 247
223}; 248 return state;
249}; \ No newline at end of file
diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c
index c6a166a82..277a8f5d9 100644
--- a/tmk_core/common/action_layer.c
+++ b/tmk_core/common/action_layer.c
@@ -64,10 +64,15 @@ void default_layer_xor(uint32_t state)
64uint32_t layer_state = 0; 64uint32_t layer_state = 0;
65 65
66__attribute__((weak)) 66__attribute__((weak))
67uint32_t layer_state_set_kb(uint32_t state) { 67uint32_t layer_state_set_user(uint32_t state) {
68 return state; 68 return state;
69} 69}
70 70
71__attribute__((weak))
72uint32_t layer_state_set_kb(uint32_t state) {
73 return layer_state_set_user(state);
74}
75
71static void layer_state_set(uint32_t state) 76static void layer_state_set(uint32_t state)
72{ 77{
73 state = layer_state_set_kb(state); 78 state = layer_state_set_kb(state);
diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h
index d89ed6e5c..e71604d87 100644
--- a/tmk_core/common/action_layer.h
+++ b/tmk_core/common/action_layer.h
@@ -73,6 +73,8 @@ void layer_xor(uint32_t state);
73#define layer_debug() 73#define layer_debug()
74 74
75__attribute__((weak)) 75__attribute__((weak))
76uint32_t layer_state_set_user(uint32_t state);
77__attribute__((weak))
76uint32_t layer_state_set_kb(uint32_t state); 78uint32_t layer_state_set_kb(uint32_t state);
77#endif 79#endif
78 80