]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - quantum/split_common/split_util.c
Small fix to allow board to override split keyboard master check
[qmk_firmware.git] / quantum / split_common / split_util.c
index 5095cb8fdce18a72cbfae1411dc2b62aa03c7bce..d7ed6989f63f6c356e5b7cebd2748064d6293d5f 100644 (file)
@@ -3,7 +3,6 @@
 #include "keyboard.h"
 #include "config.h"
 #include "timer.h"
-#include "split_flags.h"
 #include "transport.h"
 #include "quantum.h"
 
 #   include "eeconfig.h"
 #endif
 
+#if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
+#include "rgblight.h"
+#endif
+
 volatile bool isLeftHand = true;
 
 __attribute__((weak))
 bool is_keyboard_left(void) {
-  #ifdef SPLIT_HAND_PIN
+  #if defined(SPLIT_HAND_PIN)
     // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand
     setPinInput(SPLIT_HAND_PIN);
     return readPin(SPLIT_HAND_PIN);
-  #else
-    #ifdef EE_HANDS
-      return eeprom_read_byte(EECONFIG_HANDEDNESS);
-    #else
-      #ifdef MASTER_RIGHT
-        return !is_keyboard_master();
-      #else
-        return is_keyboard_master();
-      #endif
-    #endif
+  #elif defined(EE_HANDS)
+    return eeprom_read_byte(EECONFIG_HANDEDNESS);
+  #elif defined(MASTER_RIGHT)
+    return !is_keyboard_master();
   #endif
+
+  return is_keyboard_master();
 }
 
+__attribute__((weak))
 bool is_keyboard_master(void)
 {
 #ifdef __AVR__
@@ -60,10 +60,6 @@ static void keyboard_master_setup(void) {
   #endif
 #endif
   transport_master_init();
-
-  // For master the Backlight info needs to be sent on startup
-  // Otherwise the salve won't start with the proper info until an update
-  BACKLIT_DIRTY = true;
 }
 
 static void keyboard_slave_setup(void)
@@ -76,6 +72,16 @@ void matrix_setup(void)
 {
   isLeftHand = is_keyboard_left();
 
+#if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
+  uint8_t num_rgb_leds_split[2] = RGBLED_SPLIT;
+  if (isLeftHand) {
+    rgblight_set_clipping_range(0, num_rgb_leds_split[0]);
+  }
+  else {
+    rgblight_set_clipping_range(num_rgb_leds_split[0], num_rgb_leds_split[1]);
+  }
+#endif
+
   if (is_keyboard_master())
   {
     keyboard_master_setup();