Merge 12ce7feefdd8ca2cc241ad8f48889566c0924e4e into d5a042498770050a3d2f002540413ba14dfaf8d1

This commit is contained in:
Joel Challis
2025-01-01 15:40:42 +11:00
committed by GitHub
10 changed files with 109 additions and 2 deletions

View File

@ -0,0 +1,18 @@
{
"keycodes": {
"0x784D": {
"group": "rgb_matrix",
"key": "QK_RGB_MATRIX_FLAG_NEXT",
"aliases": [
"RM_FLGN"
]
},
"0x784E": {
"group": "rgb_matrix",
"key": "QK_RGB_MATRIX_FLAG_PREVIOUS",
"aliases": [
"RM_FLGP"
]
}
}
}

View File

@ -135,6 +135,7 @@
// RGB Matrix
"RGB_MATRIX_CENTER": {"info_key": "rgb_matrix.center_point", "value_type": "array.int"},
"RGB_MATRIX_FLAG_STEPS": {"info_key": "rgb_matrix.flag_steps", "value_type": "array.int"},
"RGB_MATRIX_HUE_STEP": {"info_key": "rgb_matrix.hue_steps", "value_type": "int"},
"RGB_MATRIX_KEYRELEASES": {"info_key": "rgb_matrix.react_on_keyup", "value_type": "flag"},
"RGB_MATRIX_LED_FLUSH_LIMIT": {"info_key": "rgb_matrix.led_flush_limit", "value_type": "int"},

View File

@ -608,6 +608,11 @@
"maxItems": 2,
"items": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
},
"flag_steps": {
"type": "array",
"minItems": 1,
"items": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}
},
"max_brightness": {"$ref": "qmk.definitions.v1#/unsigned_int_8"},
"timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"hue_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"},

View File

@ -795,6 +795,14 @@ def _extract_led_config(info_data, keyboard):
if info_data[feature].get('layout', None) and not info_data[feature].get('led_count', None):
info_data[feature]['led_count'] = len(info_data[feature]['layout'])
if info_data[feature].get('layout', None) and not info_data[feature].get('flag_steps', None):
flags = {0xFF, 0}
# if only a single flag is used, assume only all+none flags
unique_flags = set(x.get('flags', 0) for x in info_data[feature]['layout'])
if len(unique_flags) > 1:
flags.update(unique_flags)
info_data[feature]['flag_steps'] = sorted(list(flags), reverse=True)
return info_data

View File

@ -689,6 +689,8 @@ enum qk_keycode_defines {
QK_RGB_MATRIX_VALUE_DOWN = 0x784A,
QK_RGB_MATRIX_SPEED_UP = 0x784B,
QK_RGB_MATRIX_SPEED_DOWN = 0x784C,
QK_RGB_MATRIX_FLAG_NEXT = 0x784D,
QK_RGB_MATRIX_FLAG_PREVIOUS = 0x784E,
QK_BOOTLOADER = 0x7C00,
QK_REBOOT = 0x7C01,
QK_DEBUG_TOGGLE = 0x7C02,
@ -1378,6 +1380,8 @@ enum qk_keycode_defines {
RM_VALD = QK_RGB_MATRIX_VALUE_DOWN,
RM_SPDU = QK_RGB_MATRIX_SPEED_UP,
RM_SPDD = QK_RGB_MATRIX_SPEED_DOWN,
RM_FLGN = QK_RGB_MATRIX_FLAG_NEXT,
RM_FLGP = QK_RGB_MATRIX_FLAG_PREVIOUS,
QK_BOOT = QK_BOOTLOADER,
QK_RBT = QK_REBOOT,
DB_TOGG = QK_DEBUG_TOGGLE,
@ -1505,7 +1509,7 @@ enum qk_keycode_defines {
#define IS_LED_MATRIX_KEYCODE(code) ((code) >= QK_LED_MATRIX_ON && (code) <= QK_LED_MATRIX_SPEED_DOWN)
#define IS_UNDERGLOW_KEYCODE(code) ((code) >= QK_UNDERGLOW_TOGGLE && (code) <= QK_UNDERGLOW_SPEED_DOWN)
#define IS_RGB_KEYCODE(code) ((code) >= RGB_MODE_PLAIN && (code) <= RGB_MODE_TWINKLE)
#define IS_RGB_MATRIX_KEYCODE(code) ((code) >= QK_RGB_MATRIX_ON && (code) <= QK_RGB_MATRIX_SPEED_DOWN)
#define IS_RGB_MATRIX_KEYCODE(code) ((code) >= QK_RGB_MATRIX_ON && (code) <= QK_RGB_MATRIX_FLAG_PREVIOUS)
#define IS_QUANTUM_KEYCODE(code) ((code) >= QK_BOOTLOADER && (code) <= QK_LAYER_LOCK)
#define IS_KB_KEYCODE(code) ((code) >= QK_KB_0 && (code) <= QK_KB_31)
#define IS_USER_KEYCODE(code) ((code) >= QK_USER_0 && (code) <= QK_USER_31)
@ -1531,7 +1535,7 @@ enum qk_keycode_defines {
#define LED_MATRIX_KEYCODE_RANGE QK_LED_MATRIX_ON ... QK_LED_MATRIX_SPEED_DOWN
#define UNDERGLOW_KEYCODE_RANGE QK_UNDERGLOW_TOGGLE ... QK_UNDERGLOW_SPEED_DOWN
#define RGB_KEYCODE_RANGE RGB_MODE_PLAIN ... RGB_MODE_TWINKLE
#define RGB_MATRIX_KEYCODE_RANGE QK_RGB_MATRIX_ON ... QK_RGB_MATRIX_SPEED_DOWN
#define RGB_MATRIX_KEYCODE_RANGE QK_RGB_MATRIX_ON ... QK_RGB_MATRIX_FLAG_PREVIOUS
#define QUANTUM_KEYCODE_RANGE QK_BOOTLOADER ... QK_LAYER_LOCK
#define KB_KEYCODE_RANGE QK_KB_0 ... QK_KB_31
#define USER_KEYCODE_RANGE QK_USER_0 ... QK_USER_31

View File

@ -94,6 +94,20 @@ bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
rgb_matrix_decrease_speed();
}
return false;
case QK_RGB_MATRIX_FLAG_NEXT:
if (shifted) {
rgb_matrix_flags_step_reverse();
} else {
rgb_matrix_flags_step();
}
return false;
case QK_RGB_MATRIX_FLAG_PREVIOUS:
if (shifted) {
rgb_matrix_flags_step();
} else {
rgb_matrix_flags_step_reverse();
}
return false;
}
}

View File

@ -70,6 +70,13 @@ uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}};
last_hit_t g_last_hit_tracker;
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
#ifndef RGB_MATRIX_FLAG_STEPS
# define RGB_MATRIX_FLAG_STEPS \
{ LED_FLAG_ALL, LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER, LED_FLAG_UNDERGLOW, LED_FLAG_NONE }
#endif
static const uint8_t rgb_matrix_flag_steps[] = RGB_MATRIX_FLAG_STEPS;
#define rgb_matrix_flag_steps_count ARRAY_SIZE(rgb_matrix_flag_steps)
// internals
static bool suspend_state = false;
static uint8_t rgb_last_enable = UINT8_MAX;
@ -717,3 +724,47 @@ void rgb_matrix_set_flags(led_flags_t flags) {
void rgb_matrix_set_flags_noeeprom(led_flags_t flags) {
rgb_matrix_set_flags_eeprom_helper(flags, false);
}
void rgb_matrix_flags_step_helper(bool write_to_eeprom) {
led_flags_t flags = rgb_matrix_get_flags();
uint8_t next = 0;
for (uint8_t i = 0; i < rgb_matrix_flag_steps_count; i++) {
if (rgb_matrix_flag_steps[i] == flags) {
next = i == rgb_matrix_flag_steps_count - 1 ? 0 : i + 1;
break;
}
}
rgb_matrix_set_flags_eeprom_helper(rgb_matrix_flag_steps[next], write_to_eeprom);
}
void rgb_matrix_flags_step_noeeprom(void) {
rgb_matrix_flags_step_helper(false);
}
void rgb_matrix_flags_step(void) {
rgb_matrix_flags_step_helper(true);
}
void rgb_matrix_flags_step_reverse_helper(bool write_to_eeprom) {
led_flags_t flags = rgb_matrix_get_flags();
uint8_t next = 0;
for (uint8_t i = 0; i < rgb_matrix_flag_steps_count; i++) {
if (rgb_matrix_flag_steps[i] == flags) {
next = i == 0 ? rgb_matrix_flag_steps_count - 1 : i - 1;
break;
}
}
rgb_matrix_set_flags_eeprom_helper(rgb_matrix_flag_steps[next], write_to_eeprom);
}
void rgb_matrix_flags_step_reverse_noeeprom(void) {
rgb_matrix_flags_step_reverse_helper(false);
}
void rgb_matrix_flags_step_reverse(void) {
rgb_matrix_flags_step_reverse_helper(true);
}

View File

@ -212,6 +212,10 @@ void rgb_matrix_decrease_speed_noeeprom(void);
led_flags_t rgb_matrix_get_flags(void);
void rgb_matrix_set_flags(led_flags_t flags);
void rgb_matrix_set_flags_noeeprom(led_flags_t flags);
void rgb_matrix_flags_step_noeeprom(void);
void rgb_matrix_flags_step(void);
void rgb_matrix_flags_step_reverse_noeeprom(void);
void rgb_matrix_flags_step_reverse(void);
void rgb_matrix_update_pwm_buffers(void);
#ifndef RGBLIGHT_ENABLE

View File

@ -627,6 +627,8 @@ std::map<uint16_t, std::string> KEYCODE_ID_TABLE = {
{QK_RGB_MATRIX_VALUE_DOWN, "QK_RGB_MATRIX_VALUE_DOWN"},
{QK_RGB_MATRIX_SPEED_UP, "QK_RGB_MATRIX_SPEED_UP"},
{QK_RGB_MATRIX_SPEED_DOWN, "QK_RGB_MATRIX_SPEED_DOWN"},
{QK_RGB_MATRIX_FLAG_NEXT, "QK_RGB_MATRIX_FLAG_NEXT"},
{QK_RGB_MATRIX_FLAG_PREVIOUS, "QK_RGB_MATRIX_FLAG_PREVIOUS"},
{QK_BOOTLOADER, "QK_BOOTLOADER"},
{QK_REBOOT, "QK_REBOOT"},
{QK_DEBUG_TOGGLE, "QK_DEBUG_TOGGLE"},