#include "os_detection.h" #include "timer.h" #include "rgb_matrix.h" #include "os_mode.h" os_mode_t os_mode = OS_MODE_NONE; bool os_mode_manual = false; static bool os_detected = false; static uint32_t flash_start = 0; static void flash_mode_color(void) { rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR); switch (os_mode) { case OS_MODE_NONE: rgb_matrix_sethsv_noeeprom(HSV_RED); break; case OS_MODE_LINUX: rgb_matrix_sethsv_noeeprom(HSV_GREEN); break; case OS_MODE_MAC: rgb_matrix_sethsv_noeeprom(HSV_YELLOW); break; case OS_MODE_WINDOWS: rgb_matrix_sethsv_noeeprom(HSV_BLUE); break; } flash_start = timer_read32(); } // Poll OS detection after USB enumeration settles (~2s) // Flash indicator color for 500ms then restore default animation void matrix_scan_user(void) { if (!os_detected && !os_mode_manual && timer_elapsed32(0) > 2000) { os_detected = true; os_variant_t os = detected_host_os(); // OS detection often misidentifies linux as windows, so treat both as linux for now switch (os) { case OS_MACOS: case OS_IOS: os_mode = OS_MODE_MAC; break; case OS_LINUX: case OS_WINDOWS: os_mode = OS_MODE_LINUX; break; default: os_mode = OS_MODE_NONE; break; } flash_mode_color(); } // Restore default RGB animation after 500ms indicator flash if (flash_start && timer_elapsed32(flash_start) > 500) { flash_start = 0; rgb_matrix_reload_from_eeprom(); } }