More os modes
This commit is contained in:
@@ -2,28 +2,48 @@
|
||||
#include "timer.h"
|
||||
#include "rgb_matrix.h"
|
||||
|
||||
#include "mac_mode.h"
|
||||
#include "os_mode.h"
|
||||
|
||||
bool mac_mode = false;
|
||||
bool mac_mode_manual = false;
|
||||
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 && !mac_mode_manual && timer_elapsed32(0) > 2000) {
|
||||
if (!os_detected && !os_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);
|
||||
switch (os) {
|
||||
case OS_MACOS:
|
||||
case OS_IOS:
|
||||
os_mode = OS_MODE_MAC;
|
||||
break;
|
||||
case OS_LINUX:
|
||||
os_mode = OS_MODE_LINUX;
|
||||
break;
|
||||
case OS_WINDOWS:
|
||||
os_mode = OS_MODE_WINDOWS;
|
||||
break;
|
||||
default:
|
||||
os_mode = OS_MODE_NONE;
|
||||
break;
|
||||
}
|
||||
flash_start = timer_read32();
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user