]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - keyboards/ergodox_ez/keymaps/default/keymap.c
restore default mode/color if no 0 color
[qmk_firmware.git] / keyboards / ergodox_ez / keymaps / default / keymap.c
index 4f0136880ec3ae801f7dbe9fa404b3ea01a371e9..e0f6e21b29956c8efe555823bc3e9ee32f155fc8 100644 (file)
@@ -197,27 +197,55 @@ void matrix_init_user(void) {
 
 };
 
-
 // Runs constantly in the background, in a loop.
 void matrix_scan_user(void) {
 
-  uint8_t layer = biton32(layer_state);
+};
 
+// Runs whenever there is a layer state change.
+uint32_t layer_state_set_user(uint32_t state) {
   ergodox_board_led_off();
   ergodox_right_led_1_off();
   ergodox_right_led_2_off();
   ergodox_right_led_3_off();
+
+  uint8_t layer = biton32(state);
   switch (layer) {
-    // TODO: Make this relevant to the ErgoDox EZ.
-    case SYMB:
+    case 0:
+      #ifdef RGBLIGHT_COLOR_LAYER_0
+        rgblight_setrgb(RGBLIGHT_COLOR_LAYER_0);
+      #else
+        rgblight_init();
+      #endif
+      break;
+    case 1:
       ergodox_right_led_1_on();
+      #ifdef RGBLIGHT_COLOR_LAYER_1
+        rgblight_setrgb(RGBLIGHT_COLOR_LAYER_1);
+      #endif
       break;
-    case MDIA:
+    case 2:
       ergodox_right_led_2_on();
+      #ifdef RGBLIGHT_COLOR_LAYER_2
+        rgblight_setrgb(RGBLIGHT_COLOR_LAYER_2);
+      #endif
+      break;
+    case 3:
+      #ifdef RGBLIGHT_COLOR_LAYER_3
+        rgblight_setrgb(RGBLIGHT_COLOR_LAYER_3);
+      #endif
       break;
-    default:
-      // none
+    case 4:
+      #ifdef RGBLIGHT_COLOR_LAYER_4
+        rgblight_setrgb(RGBLIGHT_COLOR_LAYER_4);
+      #endif
+      break;
+    case 5:
+      #ifdef RGBLIGHT_COLOR_LAYER_5
+        rgblight_setrgb(RGBLIGHT_COLOR_LAYER_5);
+      #endif
       break;
   }
 
-};
+  return state;
+};
\ No newline at end of file