Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define RGB_HOLD_LIMIT 400 //hold for less than 400ms to toggle RGB
- enum custom_keycodes {
- RGB_MACRO = SAFE_RANGE, //custom keycode, name it what you want
- }
- uint16_t rgb_hold_timer = 0; //timer variable
- bool process_record_user(uint16_t keycode, keyrecord_t *record) {
- switch (keycode) {
- case RGB_MACRO:
- if (record->event.pressed) { //when RGB_MACRO is pressed
- rgb_hold_timer = timer_read(); // mark the time it was pressed
- layer_on(layer); // go to (layer)
- } else { //when RGB_MACRO is released
- layer_off(layer); // leave (layer)
- if (timer_elapsed(rgb_hold_timer) < RGB_HOLD_LIMIT)
- tap_code16(RGB_TOG); // toggle RGB if held less than RGB_HOLD_LIMIT ms
- }
- break;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement