]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - users/drashna/rgb_stuff.c
Update to drashna keymaps (#4365)
[qmk_firmware.git] / users / drashna / rgb_stuff.c
index 9ad94c0c3d2603f8497214a49961acef46a1d333..b6de4d39e53af4e804fbe2a444e4d3bce941b0cd 100644 (file)
@@ -12,14 +12,6 @@ void rgblight_sethsv_default_helper(uint8_t index) {
 #endif // RGBLIGHT_ENABLE
 
 #ifdef INDICATOR_LIGHTS
-uint8_t last_mod;
-uint8_t last_led;
-uint8_t last_osm;
-uint8_t current_mod;
-uint8_t current_led;
-uint8_t current_osm;
-
-
 void set_rgb_indicators(uint8_t this_mod, uint8_t this_led, uint8_t this_osm) {
   if (userspace_config.rgb_layer_change && biton32(layer_state) == 0) {
     if (this_mod & MODS_SHIFT_MASK || this_led & (1<<USB_LED_CAPS_LOCK) || this_osm & MODS_SHIFT_MASK) {
@@ -86,16 +78,7 @@ void set_rgb_indicators(uint8_t this_mod, uint8_t this_led, uint8_t this_osm) {
 }
 
 void matrix_scan_indicator(void) {
-  current_mod = get_mods();
-  current_led = host_keyboard_leds();
-  current_osm = get_oneshot_mods();
-
-  set_rgb_indicators(current_mod, current_led, current_osm);
-
-  last_mod = current_mod;
-  last_led = current_led;
-  last_osm = current_osm;
-
+  set_rgb_indicators(get_mods(), host_keyboard_leds(), get_oneshot_mods());
 }
 #endif //INDICATOR_LIGHTS
 
@@ -255,13 +238,9 @@ bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) {
 
 
 void matrix_init_rgb(void) {
-#ifdef INDICATOR_LIGHTS
-  current_mod = last_mod = get_mods();
-  current_led = last_led = host_keyboard_leds();
-  current_osm = last_osm = get_oneshot_mods();
-#endif
 
   if (userspace_config.rgb_layer_change) {
+    rgblight_init();
     rgblight_enable_noeeprom();
     switch (biton32(eeconfig_read_default_layer())) {
       case _COLEMAK:
@@ -291,6 +270,7 @@ void matrix_scan_rgb(void) {
 
 uint32_t layer_state_set_rgb(uint32_t state) {
 #ifdef RGBLIGHT_ENABLE
+  static bool has_ran;
   if (userspace_config.rgb_layer_change) {
     switch (biton32(state)) {
     case _MACROS:
@@ -332,7 +312,12 @@ uint32_t layer_state_set_rgb(uint32_t state) {
         default:
           rgblight_sethsv_noeeprom_cyan(); break;
       }
-      biton32(state) == _MODS ? rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING) : rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); // if _MODS layer is on, then breath to denote it
+      if (has_ran) {
+        biton32(state) == _MODS ? rgblight_mode(RGBLIGHT_MODE_BREATHING) : rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); // if _MODS layer is on, then breath to denote it
+      } else {
+        biton32(state) == _MODS ? rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING) : rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); // if _MODS layer is on, then breath to denote it
+        has_ran = true;
+      }
       break;
     }
 //    layer_state_set_indicator(); // Runs every scan, so need to call this here .... since I can't get it working "right" anyhow
@@ -341,5 +326,3 @@ uint32_t layer_state_set_rgb(uint32_t state) {
 
   return state;
 }
-
-