WIP keycodes matching EC behavior

This commit is contained in:
Ian Douglas Scott 2021-02-25 13:28:30 -08:00 committed by Jeremy Soller
parent c399cbf7a0
commit 099cb74176
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
2 changed files with 49 additions and 0 deletions

View File

@ -3,6 +3,7 @@
#include "launch_1.h" #include "launch_1.h"
#include "usb_mux.h" #include "usb_mux.h"
#include "rgb_matrix.h"
#if RGB_MATRIX_ENABLE #if RGB_MATRIX_ENABLE
// LEDs by index // LEDs by index
@ -90,6 +91,8 @@ void bootmagic_lite(void) {
void system76_ec_rgb_eeprom(bool write); void system76_ec_rgb_eeprom(bool write);
void system76_ec_rgb_layer(layer_state_t layer_state); void system76_ec_rgb_layer(layer_state_t layer_state);
void system76_ec_unlock(void); void system76_ec_unlock(void);
bool system76_ec_is_unlocked(void);
rgb_config_t layer_rgb[DYNAMIC_KEYMAP_LAYER_COUNT];
void matrix_init_kb(void) { void matrix_init_kb(void) {
usb_mux_init(); usb_mux_init();
@ -113,6 +116,25 @@ void matrix_scan_kb(void) {
matrix_scan_user(); matrix_scan_user();
} }
static const uint8_t LEVELS[] = {
48,
72,
96,
144,
192,
255
};
static int LEVEL_I = 1;
void set_value_all_layers(uint8_t value) {
if (!system76_ec_is_unlocked()) {
for (int8_t layer = 0; layer < DYNAMIC_KEYMAP_LAYER_COUNT; layer++) {
layer_rgb[layer].hsv.v = value;
}
system76_ec_rgb_layer(layer_state);
}
}
bool process_record_kb(uint16_t keycode, keyrecord_t *record) { bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
switch(keycode) { switch(keycode) {
case RESET: case RESET:
@ -120,6 +142,29 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
system76_ec_unlock(); system76_ec_unlock();
} }
return false; return false;
case RGB_VAD:
if (record->event.pressed) {
if (LEVEL_I > 0)
LEVEL_I -= 1;
set_value_all_layers(LEVELS[LEVEL_I]);
}
return false;
case RGB_VAI:
if (record->event.pressed) {
if (LEVEL_I < sizeof(LEVELS) - 1)
LEVEL_I += 1;
set_value_all_layers(LEVELS[LEVEL_I]);
}
return false;
case RGB_TOG:
if (record->event.pressed) {
if (rgb_matrix_config.hsv.v == 0) {
set_value_all_layers(LEVELS[LEVEL_I]);
} else {
set_value_all_layers(0);
}
}
return false;
} }
return process_record_user(keycode, record); return process_record_user(keycode, record);

View File

@ -70,6 +70,10 @@ void system76_ec_unlock(void) {
bootloader_unlocked = true; bootloader_unlocked = true;
} }
bool system76_ec_is_unlocked(void) {
return bootloader_unlocked;
}
#if defined(RGB_MATRIX_CUSTOM_KB) #if defined(RGB_MATRIX_CUSTOM_KB)
enum Mode { enum Mode {
MODE_SOLID_COLOR = 0, MODE_SOLID_COLOR = 0,