Last active
January 11, 2023 02:36
-
-
Save cognitom/6d1555385473a733ce13f2a664dd8353 to your computer and use it in GitHub Desktop.
Lock key indicator with RGB matrix on QMK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!!