Skip to content

Instantly share code, notes, and snippets.

@cognitom
Last active January 11, 2023 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cognitom/6d1555385473a733ce13f2a664dd8353 to your computer and use it in GitHub Desktop.
Save cognitom/6d1555385473a733ce13f2a664dd8353 to your computer and use it in GitHub Desktop.
Lock key indicator with RGB matrix on QMK
// keymap setting and etc...
// store the state
static bool _is_key_locked = false;
void keyboard_post_init_user(void) {
// need to stop effects and animations
rgb_matrix_mode(RGB_MATRIX_NONE);
rgb_matrix_sethsv(HSV_OFF);
}
void rgb_matrix_indicators_user(void) {
int key_index = 10; // set your key index here
if (_is_key_locked) {
rgb_matrix_set_color(key_index, RGB_WHITE);
} else {
rgb_matrix_set_color(key_index, RGB_BLACK);
}
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case KC_A: // set your keycode here
if (record->event.pressed) {
_is_key_locked = !_is_key_locked;
}
break;
}
return true;
}
@jhon-tonet
Copy link

Thank you so much for share this!
I spent one day trying to figure out how to implement a function to change the color of just one key when pressed.
I was missing this bool var to control the event, trying to set the color inside the process_record_user().
Now it's working!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment