161 lines
3.3 KiB
C
161 lines
3.3 KiB
C
//#include "extra_mappings.h"
|
|
#define LAYER_INCLUDE_FILE "definitions/layers.inc"
|
|
|
|
|
|
/*
|
|
Setup
|
|
*/
|
|
|
|
|
|
// Generate layer ids
|
|
#define BETA_LAYER_KEYS
|
|
#define BETA_LAYER(name) LAYER_##name,
|
|
enum layer_indices {
|
|
#include LAYER_INCLUDE_FILE
|
|
X_LAYER_MAX
|
|
};
|
|
#undef BETA_LAYER
|
|
#undef BETA_LAYER_KEYS
|
|
|
|
|
|
// Generate RGBMatrix ids
|
|
// We don't use the same id for layers and layer colors
|
|
// to save memory. Not every layer has colors!
|
|
#define BETA_LAYER_LEDS
|
|
#define BETA_LAYER(name) LAYER_##name##_LEDS,
|
|
enum led_indices {
|
|
#include LAYER_INCLUDE_FILE
|
|
X_LAYER_LEDS_MAX
|
|
};
|
|
#undef BETA_LAYER
|
|
#undef BETA_LAYER_LEDS
|
|
|
|
|
|
/*
|
|
Load layers
|
|
*/
|
|
|
|
|
|
// Create keymap array
|
|
#define BETA_LAYER_KEYS
|
|
#define BETA_LAYER(name) [LAYER_##name] = BETA_LAYER_CONTEXT_DATA,
|
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|
#include LAYER_INCLUDE_FILE
|
|
};
|
|
#undef BETA_LAYER
|
|
#undef BETA_LAYER_KEYS
|
|
|
|
|
|
// Create led map array
|
|
#define BETA_LAYER_LEDS
|
|
#define BETA_LAYER(name) [LAYER_##name##_LEDS] = BETA_LAYER_CONTEXT_DATA,
|
|
const uint8_t PROGMEM ledmaps[][RGB_MATRIX_LED_COUNT][3] = {
|
|
#include LAYER_INCLUDE_FILE
|
|
};
|
|
#undef BETA_LAYER
|
|
#undef BETA_LAYER_LEDS
|
|
|
|
|
|
/*
|
|
// Create os layout array
|
|
#define BETA_LAYER_LAYOUTS
|
|
#define BETA_LAYER(name) [LAYER_##name] = BETA_LAYER_CONTEXT_DATA,
|
|
uint8_t layer_layouts[] = {
|
|
#include LAYER_INCLUDE_FILE
|
|
};
|
|
#undef BETA_LAYER
|
|
#undef BETA_LAYER_LAYOUTS
|
|
*/
|
|
|
|
void set_layer_color(int layer) {
|
|
for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
|
|
HSV hsv = {
|
|
.h = pgm_read_byte(&ledmaps[layer][i][0]),
|
|
.s = pgm_read_byte(&ledmaps[layer][i][1]),
|
|
.v = pgm_read_byte(&ledmaps[layer][i][2]),
|
|
};
|
|
if (!hsv.h && !hsv.s && !hsv.v) {
|
|
rgb_matrix_set_color( i, 0, 0, 0 );
|
|
} else {
|
|
RGB rgb = hsv_to_rgb( hsv );
|
|
float f = (float)rgb_matrix_config.hsv.v / UINT8_MAX;
|
|
rgb_matrix_set_color( i, f * rgb.r, f * rgb.g, f * rgb.b );
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
extern bool beta_leading;
|
|
|
|
bool rgb_matrix_indicators_user(void) {
|
|
if (keyboard_config.disable_layer_led) {
|
|
return true;
|
|
}
|
|
|
|
switch (biton32(layer_state)) {
|
|
|
|
// Load layer RGBMatrix colors
|
|
#define BETA_LAYER_LEDS
|
|
#define BETA_LAYER(name)\
|
|
case LAYER_##name:\
|
|
set_layer_color(LAYER_##name##_LEDS);\
|
|
break;
|
|
|
|
#include LAYER_INCLUDE_FILE
|
|
|
|
#undef BETA_LAYER
|
|
#undef BETA_LAYER_LEDS
|
|
|
|
default:
|
|
if (rgb_matrix_get_flags() == LED_FLAG_NONE) {
|
|
rgb_matrix_set_color_all(0, 0, 0);
|
|
}
|
|
break;
|
|
}
|
|
|
|
if (beta_leading) {
|
|
rgb_matrix_set_color(43, 0x00, 0x00, 0xFF);
|
|
}
|
|
|
|
if (biton32(layer_state) == LAYER_KEYBOARD) {
|
|
rgb_matrix_set_color(0, 0xFF, 0x00, 0x00);
|
|
rgb_matrix_set_color(18, 0x95, 0xFF, 0x00);
|
|
rgb_matrix_set_color(19, 0x95, 0xFF, 0x00);
|
|
|
|
rgb_matrix_set_color(14, 0x00, 0xFF, 0x8C);
|
|
rgb_matrix_set_color(13, 0x00, 0xFF, 0x8C);
|
|
rgb_matrix_set_color(8, 0x00, 0xFF, 0x8C);
|
|
rgb_matrix_set_color(7, 0x00, 0xFF, 0x8C);
|
|
rgb_matrix_set_color(2, 0x00, 0xFF, 0x8C);
|
|
rgb_matrix_set_color(1, 0x00, 0xFF, 0x8C);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
layer_state_t layer_state_set_user(layer_state_t state) {
|
|
uint8_t layer = biton32(state);
|
|
|
|
STATUS_LED_1(false);
|
|
STATUS_LED_2(false);
|
|
STATUS_LED_3(false);
|
|
STATUS_LED_4(false);
|
|
|
|
switch (layer) {
|
|
|
|
// Load indicator LED cases
|
|
#define BETA_LAYER_INDICATORS
|
|
#define BETA_LAYER(name) LAYER_##name
|
|
#include LAYER_INCLUDE_FILE
|
|
#undef BETA_LAYER
|
|
#undef BETA_LAYER_INDICATORS
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return state;
|
|
};
|
|
|