mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-15 04:11:30 +00:00
override the behavior of the keycodes to control RGB
This commit is contained in:
parent
5cc519d20b
commit
2201d10df0
@ -133,9 +133,6 @@
|
|||||||
//#define ENABLE_RGB_MATRIX_SOLID_SPLASH
|
//#define ENABLE_RGB_MATRIX_SOLID_SPLASH
|
||||||
//#define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
//#define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
||||||
|
|
||||||
#define RGB_MATRIX_HUE_STEP 62
|
#define RGB_MATRIX_DEFAULT_SPD UINT8_MAX/2
|
||||||
#define RGB_MATRIX_SAT_STEP 62
|
|
||||||
#define RGB_MATRIX_VAL_STEP 50
|
|
||||||
#define RGB_MATRIX_SPD_STEP 62
|
|
||||||
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 /* The maximum brightness level */
|
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 /* The maximum brightness level */
|
||||||
|
|
||||||
|
@ -284,11 +284,13 @@ static uint16_t current_time = 0;
|
|||||||
static uint8_t glint_cnt = 0;
|
static uint8_t glint_cnt = 0;
|
||||||
static uint16_t scancode = 0;
|
static uint16_t scancode = 0;
|
||||||
static uint8_t alarm_cnt = 0;
|
static uint8_t alarm_cnt = 0;
|
||||||
|
static uint8_t RGB_HSV_level;
|
||||||
|
|
||||||
HSV hsv;
|
HSV hsv;
|
||||||
|
|
||||||
void led_test(uint8_t color);
|
void led_test(uint8_t color);
|
||||||
void clear_eeprom(void);
|
void clear_eeprom(void);
|
||||||
|
void rgb_hsv_updata_user(void);
|
||||||
|
|
||||||
#ifdef RGB_MATRIX_ENABLE
|
#ifdef RGB_MATRIX_ENABLE
|
||||||
|
|
||||||
@ -394,6 +396,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
|||||||
rgb_matrix_toggle_noeeprom();
|
rgb_matrix_toggle_noeeprom();
|
||||||
current_time = timer_read();
|
current_time = timer_read();
|
||||||
keymap_config.no_gui = 0;
|
keymap_config.no_gui = 0;
|
||||||
|
eeconfig_update_keymap(keymap_config.raw);
|
||||||
// layer_state_set(MAC_B);
|
// layer_state_set(MAC_B);
|
||||||
set_single_persistent_default_layer(MAC_B);
|
set_single_persistent_default_layer(MAC_B);
|
||||||
return false;
|
return false;
|
||||||
@ -426,33 +429,84 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case RGB_VAI:
|
case RGB_VAI:
|
||||||
if ((fn_make_flag && record->event.pressed)&&(alarm_flag == 0)) {
|
if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
|
||||||
if(rgblight_get_val()<180){
|
if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_val() / (RGB_MATRIX_MAXIMUM_BRIGHTNESS / 4)) < 4) {
|
||||||
alarm_cnt = 2;
|
alarm_cnt = 2;
|
||||||
}
|
RGB_HSV_level++;
|
||||||
|
rgb_matrix_config.hsv.v = (uint8_t)(RGB_MATRIX_MAXIMUM_BRIGHTNESS / 4) * RGB_HSV_level;
|
||||||
}
|
}
|
||||||
return true;
|
rgb_hsv_updata_user();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
case RGB_VAD:
|
case RGB_VAD:
|
||||||
if ((fn_make_flag && record->event.pressed)&&(alarm_flag == 0)) {
|
if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
|
||||||
if(rgblight_get_val()>10){
|
if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_val() / (RGB_MATRIX_MAXIMUM_BRIGHTNESS / 4)) > 0) {
|
||||||
alarm_cnt = 2;
|
alarm_cnt = 2;
|
||||||
}
|
RGB_HSV_level--;
|
||||||
|
rgb_matrix_config.hsv.v = (uint8_t)(RGB_MATRIX_MAXIMUM_BRIGHTNESS / 4) * RGB_HSV_level;
|
||||||
}
|
}
|
||||||
return true;
|
rgb_hsv_updata_user();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
case RGB_SAI:
|
case RGB_SAI:
|
||||||
if ((fn_make_flag && record->event.pressed)&&(alarm_flag == 0)) {
|
if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
|
||||||
if(rgblight_get_sat()<240){
|
if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_sat() / (UINT8_MAX / 4)) < 4) {
|
||||||
alarm_cnt = 2;
|
alarm_cnt = 2;
|
||||||
}
|
RGB_HSV_level++;
|
||||||
|
rgb_matrix_config.hsv.s = (uint8_t)(UINT8_MAX / 4) * RGB_HSV_level;
|
||||||
}
|
}
|
||||||
return true;
|
rgb_hsv_updata_user();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
case RGB_SAD:
|
case RGB_SAD:
|
||||||
if ((fn_make_flag && record->event.pressed)&&(alarm_flag == 0)) {
|
if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
|
||||||
if(rgblight_get_sat()>10){
|
if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_sat() / (UINT8_MAX / 4)) > 0) {
|
||||||
alarm_cnt = 2;
|
alarm_cnt = 2;
|
||||||
}
|
RGB_HSV_level--;
|
||||||
|
rgb_matrix_config.hsv.s = (uint8_t)(UINT8_MAX / 4) * RGB_HSV_level;
|
||||||
}
|
}
|
||||||
return true;
|
rgb_hsv_updata_user();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case RGB_HUI:
|
||||||
|
if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
|
||||||
|
if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_hue() / (UINT8_MAX / 6)) < 6) {
|
||||||
|
alarm_cnt = 2;
|
||||||
|
RGB_HSV_level++;
|
||||||
|
rgb_matrix_config.hsv.h = (uint8_t)(UINT8_MAX / 6) * RGB_HSV_level;
|
||||||
|
}
|
||||||
|
rgb_hsv_updata_user();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case RGB_HUD:
|
||||||
|
if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
|
||||||
|
if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_hue() / (UINT8_MAX / 6)) > 0) {
|
||||||
|
alarm_cnt = 2;
|
||||||
|
RGB_HSV_level--;
|
||||||
|
rgb_matrix_config.hsv.h = (uint8_t)(UINT8_MAX / 6) * RGB_HSV_level;
|
||||||
|
}
|
||||||
|
rgb_hsv_updata_user();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case RGB_SPI:
|
||||||
|
if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
|
||||||
|
if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_speed() / (UINT8_MAX / 4)) < 4) {
|
||||||
|
alarm_cnt = 2;
|
||||||
|
RGB_HSV_level++;
|
||||||
|
rgb_matrix_set_speed((uint8_t)(UINT8_MAX / 4) * RGB_HSV_level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case RGB_SPD:
|
||||||
|
if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
|
||||||
|
if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_speed() / (UINT8_MAX / 4)) > 0) {
|
||||||
|
alarm_cnt = 2;
|
||||||
|
RGB_HSV_level--;
|
||||||
|
rgb_matrix_set_speed((uint8_t)(UINT8_MAX / 4) * RGB_HSV_level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return process_record_user(keycode, record);
|
return process_record_user(keycode, record);
|
||||||
}
|
}
|
||||||
@ -568,7 +622,7 @@ void clear_eeprom(void) {
|
|||||||
layer_state_set(default_layer_temp);
|
layer_state_set(default_layer_temp);
|
||||||
default_layer_set(default_layer_temp);
|
default_layer_set(default_layer_temp);
|
||||||
keymap_config.no_gui = 0;
|
keymap_config.no_gui = 0;
|
||||||
|
eeconfig_update_keymap(keymap_config.raw);
|
||||||
#ifdef VIA_ENABLE
|
#ifdef VIA_ENABLE
|
||||||
// This resets the layout options
|
// This resets the layout options
|
||||||
via_set_layout_options(VIA_EEPROM_LAYOUT_OPTIONS_DEFAULT);
|
via_set_layout_options(VIA_EEPROM_LAYOUT_OPTIONS_DEFAULT);
|
||||||
@ -580,3 +634,8 @@ void clear_eeprom(void) {
|
|||||||
|
|
||||||
rgb_matrix_enable_noeeprom();
|
rgb_matrix_enable_noeeprom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rgb_hsv_updata_user(void)
|
||||||
|
{
|
||||||
|
rgb_matrix_sethsv(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user