Formatting

master
Mark 2022-02-06 12:16:11 -08:00
parent 85b356d4a1
commit c746af211f
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
1 changed files with 237 additions and 198 deletions

View File

@ -45,15 +45,15 @@
enum custom_keycodes { enum custom_keycodes {
RGB_SLD = EZ_SAFE_RANGE, RGB_SLD = EZ_SAFE_RANGE,
HSV_136_138_245, HSV_136_138_245,
HSV_24_210_255, HSV_24_210_255,
HSV_0_0_255, HSV_0_0_255,
ST_MACRO_0, ST_MACRO_0,
ST_MACRO_1, ST_MACRO_1,
RU_LAYER, RU_LAYER,
EN_LAYER, EN_LAYER,
RU_SYMBOL, RU_SYMBOL,
}; };
enum tap_dance_codes { enum tap_dance_codes {
@ -178,198 +178,217 @@ extern bool g_suspend_state;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
void keyboard_post_init_user(void) { void keyboard_post_init_user(void) {
rgb_matrix_enable(); rgb_matrix_enable();
} }
const uint8_t PROGMEM ledmap[][DRIVER_LED_TOTAL][3] = { const uint8_t PROGMEM ledmap[][DRIVER_LED_TOTAL][3] = {
[1] = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} }, [1] = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} },
[2] = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {32,176,255}, {85,203,158}, {85,203,158}, {85,203,158}, {0,0,0}, {85,203,158}, {85,203,158}, {85,203,158}, {85,203,158}, {32,176,255}, {32,176,255}, {85,203,158}, {85,203,158}, {85,203,158}, {32,176,255}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} }, [2] = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {32,176,255}, {85,203,158}, {85,203,158}, {85,203,158}, {0,0,0}, {85,203,158}, {85,203,158}, {85,203,158}, {85,203,158}, {32,176,255}, {32,176,255}, {85,203,158}, {85,203,158}, {85,203,158}, {32,176,255}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} },
[3] = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {85,203,158}, {134,255,213}, {0,0,0}, {134,255,213}, {134,255,213}, {85,203,158}, {243,222,234}, {10,225,255}, {134,255,213}, {85,203,158}, {85,203,158}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {134,255,213}, {243,222,234}, {134,255,213}, {134,255,213}, {10,225,255}, {243,222,234}, {243,222,234}, {243,222,234}, {243,222,234}, {10,225,255}, {134,255,213}, {243,222,234}, {134,255,213}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} }, [3] = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {85,203,158}, {134,255,213}, {0,0,0}, {134,255,213}, {134,255,213}, {85,203,158}, {243,222,234}, {10,225,255}, {134,255,213}, {85,203,158}, {85,203,158}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {134,255,213}, {243,222,234}, {134,255,213}, {134,255,213}, {10,225,255}, {243,222,234}, {243,222,234}, {243,222,234}, {243,222,234}, {10,225,255}, {134,255,213}, {243,222,234}, {134,255,213}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} },
[4] = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {32,176,255}, {32,176,255}, {0,0,0}, {85,203,158}, {85,203,158}, {85,203,158}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0} }, [4] = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {32,176,255}, {32,176,255}, {0,0,0}, {85,203,158}, {85,203,158}, {85,203,158}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0} },
[5] = { {134,255,213}, {134,255,213}, {134,255,213}, {134,255,213}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {134,255,213}, {134,255,213}, {134,255,213}, {134,255,213}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} }, [5] = { {134,255,213}, {134,255,213}, {134,255,213}, {134,255,213}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {134,255,213}, {134,255,213}, {134,255,213}, {134,255,213}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} },
[6] = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {243,222,234}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0} }, [6] = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {243,222,234}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0} },
[7] = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {0,0,0}, {14,255,255}, {0,0,0}, {85,203,158}, {85,203,158}, {85,203,158}, {0,0,0}, {0,0,0}, {134,255,213}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {134,255,213}, {134,255,213}, {0,0,0}, {85,203,158}, {0,0,0}, {134,255,213}, {134,255,213}, {85,203,158}, {85,203,158}, {85,203,158}, {0,0,0}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} }, [7] = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {0,0,0}, {14,255,255}, {0,0,0}, {85,203,158}, {85,203,158}, {85,203,158}, {0,0,0}, {0,0,0}, {134,255,213}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {134,255,213}, {134,255,213}, {0,0,0}, {85,203,158}, {0,0,0}, {134,255,213}, {134,255,213}, {85,203,158}, {85,203,158}, {85,203,158}, {0,0,0}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} },
[9] = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,165}, {0,0,165}, {0,0,165}, {0,0,165}, {0,0,165}, {153,255,153}, {153,255,153}, {153,255,153}, {153,255,153}, {153,255,153}, {0,255,145}, {0,255,145}, {0,255,145}, {0,255,145}, {0,255,145}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,165}, {0,0,165}, {0,0,165}, {0,0,165}, {0,0,165}, {153,255,153}, {153,255,153}, {153,255,153}, {153,255,153}, {153,255,153}, {0,255,145}, {0,255,145}, {0,255,145}, {0,255,145}, {0,255,145}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} }, [9] = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,165}, {0,0,165}, {0,0,165}, {0,0,165}, {0,0,165}, {153,255,153}, {153,255,153}, {153,255,153}, {153,255,153}, {153,255,153}, {0,255,145}, {0,255,145}, {0,255,145}, {0,255,145}, {0,255,145}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,165}, {0,0,165}, {0,0,165}, {0,0,165}, {0,0,165}, {153,255,153}, {153,255,153}, {153,255,153}, {153,255,153}, {153,255,153}, {0,255,145}, {0,255,145}, {0,255,145}, {0,255,145}, {0,255,145}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} },
[10] = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {85,203,158}, {134,255,213}, {0,0,0}, {134,255,213}, {134,255,213}, {85,203,158}, {243,222,234}, {10,225,255}, {134,255,213}, {85,203,158}, {85,203,158}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {134,255,213}, {243,222,234}, {134,255,213}, {134,255,213}, {10,225,255}, {243,222,234}, {243,222,234}, {243,222,234}, {243,222,234}, {10,225,255}, {134,255,213}, {243,222,234}, {134,255,213}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} }, [10] = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {85,203,158}, {85,203,158}, {134,255,213}, {0,0,0}, {134,255,213}, {134,255,213}, {85,203,158}, {243,222,234}, {10,225,255}, {134,255,213}, {85,203,158}, {85,203,158}, {243,222,234}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {134,255,213}, {243,222,234}, {134,255,213}, {134,255,213}, {10,225,255}, {243,222,234}, {243,222,234}, {243,222,234}, {243,222,234}, {10,225,255}, {134,255,213}, {243,222,234}, {134,255,213}, {134,255,213}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} },
}; };
void set_layer_color(int layer) { void set_layer_color(int layer) {
for (int i = 0; i < DRIVER_LED_TOTAL; i++) { for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
HSV hsv = { HSV hsv = {
.h = pgm_read_byte(&ledmap[layer][i][0]), .h = pgm_read_byte(&ledmap[layer][i][0]),
.s = pgm_read_byte(&ledmap[layer][i][1]), .s = pgm_read_byte(&ledmap[layer][i][1]),
.v = pgm_read_byte(&ledmap[layer][i][2]), .v = pgm_read_byte(&ledmap[layer][i][2]),
}; };
if (!hsv.h && !hsv.s && !hsv.v) { if (!hsv.h && !hsv.s && !hsv.v) {
rgb_matrix_set_color( i, 0, 0, 0 ); rgb_matrix_set_color( i, 0, 0, 0 );
} else { } else {
RGB rgb = hsv_to_rgb( hsv ); RGB rgb = hsv_to_rgb( hsv );
float f = (float)rgb_matrix_config.hsv.v / UINT8_MAX; float f = (float)rgb_matrix_config.hsv.v / UINT8_MAX;
rgb_matrix_set_color( i, f * rgb.r, f * rgb.g, f * rgb.b ); rgb_matrix_set_color( i, f * rgb.r, f * rgb.g, f * rgb.b );
} }
} }
} }
void rgb_matrix_indicators_user(void) { void rgb_matrix_indicators_user(void) {
if (g_suspend_state || keyboard_config.disable_layer_led) { return; } if (g_suspend_state || keyboard_config.disable_layer_led) {
switch (biton32(layer_state)) { return;
case 1: }
set_layer_color(1);
break; switch (biton32(layer_state)) {
case 2: case 1:
set_layer_color(2); set_layer_color(1);
break; break;
case 3: case 2:
set_layer_color(3); set_layer_color(2);
break; break;
case 4: case 3:
set_layer_color(4); set_layer_color(3);
break; break;
case 5: case 4:
set_layer_color(5); set_layer_color(4);
break; break;
case 6: case 5:
set_layer_color(6); set_layer_color(5);
break; break;
case 7: case 6:
set_layer_color(7); set_layer_color(6);
break; break;
case 9: case 7:
set_layer_color(9); set_layer_color(7);
break; break;
case 10: case 9:
set_layer_color(10); set_layer_color(9);
break; break;
default: case 10:
if (rgb_matrix_get_flags() == LED_FLAG_NONE) set_layer_color(10);
rgb_matrix_set_color_all(0, 0, 0); break;
break; default:
} if (rgb_matrix_get_flags() == LED_FLAG_NONE) {
rgb_matrix_set_color_all(0, 0, 0);
}
break;
}
} }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) { switch (keycode) {
case ST_MACRO_0: case ST_MACRO_0:
if (record->event.pressed) { if (record->event.pressed) {
SEND_STRING(SS_LCTL(SS_LGUI(SS_LSFT(SS_TAP(X_R))))); SEND_STRING(SS_LCTL(SS_LGUI(SS_LSFT(SS_TAP(X_R)))));
}
break;
} case ST_MACRO_1:
break; if (record->event.pressed) {
case ST_MACRO_1: SEND_STRING(SS_LGUI(SS_TAP(X_P)) SS_DELAY(100) SS_TAP(X_Y) SS_DELAY(100) SS_TAP(X_ENTER));
if (record->event.pressed) {
SEND_STRING(SS_LGUI(SS_TAP(X_P)) SS_DELAY(100) SS_TAP(X_Y) SS_DELAY(100) SS_TAP(X_ENTER));
} }
break; break;
case RU_LAYER:
if (record->event.pressed) { case RU_LAYER:
SEND_STRING(SS_LGUI(SS_LSFT(SS_LCTL(SS_TAP(X_9))))); if (record->event.pressed) {
layer_move(9); SEND_STRING(SS_LGUI(SS_LSFT(SS_LCTL(SS_TAP(X_9)))));
} layer_move(9);
break; }
case EN_LAYER: break;
if (record->event.pressed) {
SEND_STRING(SS_LGUI(SS_LSFT(SS_LCTL(SS_TAP(X_0))))); case EN_LAYER:
layer_move(0); if (record->event.pressed) {
} SEND_STRING(SS_LGUI(SS_LSFT(SS_LCTL(SS_TAP(X_0)))));
break; layer_move(0);
case RU_SYMBOL: }
if (record->event.pressed) { break;
SEND_STRING(SS_LGUI(SS_LSFT(SS_LCTL(SS_TAP(X_0)))));
layer_move(10); case RU_SYMBOL:
} else { if (record->event.pressed) {
SEND_STRING(SS_LGUI(SS_LSFT(SS_LCTL(SS_TAP(X_9))))); SEND_STRING(SS_LGUI(SS_LSFT(SS_LCTL(SS_TAP(X_0)))));
layer_move(9); layer_move(10);
} } else {
break; SEND_STRING(SS_LGUI(SS_LSFT(SS_LCTL(SS_TAP(X_9)))));
case RGB_SLD: layer_move(9);
if (record->event.pressed) { }
rgblight_mode(1); break;
}
return false; case RGB_SLD:
case HSV_136_138_245: if (record->event.pressed) {
if (record->event.pressed) { rgblight_mode(1);
rgblight_mode(1); }
rgblight_sethsv(136,138,245); return false;
}
return false; case HSV_136_138_245:
case HSV_24_210_255: if (record->event.pressed) {
if (record->event.pressed) { rgblight_mode(1);
rgblight_mode(1); rgblight_sethsv(136,138,245);
rgblight_sethsv(24,210,255); }
} return false;
return false;
case HSV_0_0_255: case HSV_24_210_255:
if (record->event.pressed) { if (record->event.pressed) {
rgblight_mode(1); rgblight_mode(1);
rgblight_sethsv(0,0,255); rgblight_sethsv(24,210,255);
} }
return false; return false;
}
return true; case HSV_0_0_255:
if (record->event.pressed) {
rgblight_mode(1);
rgblight_sethsv(0,0,255);
}
return false;
}
return true;
} }
uint32_t layer_state_set_user(uint32_t state) { uint32_t layer_state_set_user(uint32_t state) {
uint8_t layer = biton32(state); uint8_t layer = biton32(state);
ergodox_board_led_off(); ergodox_board_led_off();
ergodox_right_led_1_off(); ergodox_right_led_1_off();
ergodox_right_led_2_off(); ergodox_right_led_2_off();
ergodox_right_led_3_off(); ergodox_right_led_3_off();
switch (layer) { switch (layer) {
case 1: case 1:
ergodox_right_led_1_on(); ergodox_right_led_1_on();
break; break;
case 2:
ergodox_right_led_2_on(); case 2:
break; ergodox_right_led_2_on();
case 3: break;
ergodox_right_led_3_on();
break; case 3:
case 4: ergodox_right_led_3_on();
ergodox_right_led_1_on(); break;
ergodox_right_led_2_on();
break; case 4:
case 5: ergodox_right_led_1_on();
ergodox_right_led_1_on(); ergodox_right_led_2_on();
ergodox_right_led_3_on(); break;
break;
case 6: case 5:
ergodox_right_led_2_on(); ergodox_right_led_1_on();
ergodox_right_led_3_on(); ergodox_right_led_3_on();
break; break;
case 7:
ergodox_right_led_1_on(); case 6:
ergodox_right_led_2_on(); ergodox_right_led_2_on();
ergodox_right_led_3_on(); ergodox_right_led_3_on();
break; break;
default:
break; case 7:
} ergodox_right_led_1_on();
return state; ergodox_right_led_2_on();
ergodox_right_led_3_on();
break;
default:
break;
}
return state;
}; };
typedef struct { typedef struct {
bool is_press_action; bool is_press_action;
uint8_t step; uint8_t step;
} tap; } tap;
enum { enum {
SINGLE_TAP = 1, SINGLE_TAP = 1,
SINGLE_HOLD, SINGLE_HOLD,
DOUBLE_TAP, DOUBLE_TAP,
DOUBLE_HOLD, DOUBLE_HOLD,
DOUBLE_SINGLE_TAP, DOUBLE_SINGLE_TAP,
MORE_TAPS MORE_TAPS
}; };
static tap dance_state[1]; static tap dance_state[1];
@ -377,15 +396,22 @@ static tap dance_state[1];
uint8_t dance_step(qk_tap_dance_state_t *state); uint8_t dance_step(qk_tap_dance_state_t *state);
uint8_t dance_step(qk_tap_dance_state_t *state) { uint8_t dance_step(qk_tap_dance_state_t *state) {
if (state->count == 1) { if (state->count == 1) {
if (state->interrupted || !state->pressed) return SINGLE_TAP; if (state->interrupted || !state->pressed) {
else return SINGLE_HOLD; return SINGLE_TAP;
} else if (state->count == 2) { } else {
if (state->interrupted) return DOUBLE_SINGLE_TAP; return SINGLE_HOLD;
else if (state->pressed) return DOUBLE_HOLD; }
else return DOUBLE_TAP; } else if (state->count == 2) {
} if (state->interrupted) {
return MORE_TAPS; return DOUBLE_SINGLE_TAP;
} else if (state->pressed) {
return DOUBLE_HOLD;
} else {
return DOUBLE_TAP;
}
}
return MORE_TAPS;
} }
@ -394,35 +420,48 @@ void dance_0_finished(qk_tap_dance_state_t *state, void *user_data);
void dance_0_reset(qk_tap_dance_state_t *state, void *user_data); void dance_0_reset(qk_tap_dance_state_t *state, void *user_data);
void on_dance_0(qk_tap_dance_state_t *state, void *user_data) { void on_dance_0(qk_tap_dance_state_t *state, void *user_data) {
if(state->count == 3) { if(state->count == 3) {
tap_code16(LGUI(KC_L)); tap_code16(LGUI(KC_L));
tap_code16(LGUI(KC_L)); tap_code16(LGUI(KC_L));
tap_code16(LGUI(KC_L)); tap_code16(LGUI(KC_L));
} }
if(state->count > 3) { if(state->count > 3) {
tap_code16(LGUI(KC_L)); tap_code16(LGUI(KC_L));
} }
} }
void dance_0_finished(qk_tap_dance_state_t *state, void *user_data) { void dance_0_finished(qk_tap_dance_state_t *state, void *user_data) {
dance_state[0].step = dance_step(state); dance_state[0].step = dance_step(state);
switch (dance_state[0].step) { switch (dance_state[0].step) {
case SINGLE_TAP: register_code16(LGUI(KC_L)); break; case SINGLE_TAP:
case DOUBLE_TAP: register_code16(LGUI(KC_K)); break; register_code16(LGUI(KC_L));
case DOUBLE_SINGLE_TAP: tap_code16(LGUI(KC_L)); register_code16(LGUI(KC_L)); break;
} case DOUBLE_TAP:
register_code16(LGUI(KC_K));
break;
case DOUBLE_SINGLE_TAP:
tap_code16(LGUI(KC_L));
register_code16(LGUI(KC_L));
break;
}
} }
void dance_0_reset(qk_tap_dance_state_t *state, void *user_data) { void dance_0_reset(qk_tap_dance_state_t *state, void *user_data) {
wait_ms(10); wait_ms(10);
switch (dance_state[0].step) { switch (dance_state[0].step) {
case SINGLE_TAP: unregister_code16(LGUI(KC_L)); break; case SINGLE_TAP:
case DOUBLE_TAP: unregister_code16(LGUI(KC_K)); break; unregister_code16(LGUI(KC_L));
case DOUBLE_SINGLE_TAP: unregister_code16(LGUI(KC_L)); break; break;
} case DOUBLE_TAP:
dance_state[0].step = 0; unregister_code16(LGUI(KC_K));
break;
case DOUBLE_SINGLE_TAP:
unregister_code16(LGUI(KC_L));
break;
}
dance_state[0].step = 0;
} }
qk_tap_dance_action_t tap_dance_actions[] = { qk_tap_dance_action_t tap_dance_actions[] = {
[DANCE_0] = ACTION_TAP_DANCE_FN_ADVANCED(on_dance_0, dance_0_finished, dance_0_reset), [DANCE_0] = ACTION_TAP_DANCE_FN_ADVANCED(on_dance_0, dance_0_finished, dance_0_reset),
}; };