Files
keyboard/keymaps/custom/os_detect.c
2026-03-15 16:14:14 -07:00

32 lines
955 B
C

#include "os_detection.h"
#include "timer.h"
#include "rgb_matrix.h"
#include "mac_mode.h"
bool mac_mode = false;
bool mac_mode_manual = false;
static bool os_detected = false;
static uint32_t flash_start = 0;
// 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 && !mac_mode_manual && timer_elapsed32(0) > 2000) {
os_detected = true;
os_variant_t os = detected_host_os();
mac_mode = (os == OS_MACOS || os == OS_IOS);
rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR);
if (mac_mode) {
rgb_matrix_sethsv_noeeprom(HSV_GREEN);
} else {
rgb_matrix_sethsv_noeeprom(HSV_BLUE);
}
flash_start = timer_read32();
}
if (flash_start && timer_elapsed32(flash_start) > 500) {
flash_start = 0;
rgb_matrix_reload_from_eeprom();
}
}