Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define LOWCLK_HOLD_LIMIT 400 //configure hold time for LOWER_CLICK. hold for less than 400ms to left click
- enum custom_keycodes {
- MACRO1 = SAFE_RANGE, //start of other macro keys
- MACRO2,
- MACRO3,
- LOWER_CLICK //custom macro keycode, name it what you want
- };
- uint16_t lowclk_hold_timer = 0; //lower_click timer variable
- bool process_record_user(uint16_t keycode, keyrecord_t *record) {
- switch (keycode) {
- //other macros
- case BACKLIT:
- //...
- break;
- case LOWER_CLICK:
- if (record->event.pressed) { //when LOWER_CLICK is pressed
- lowclk_hold_timer = timer_read(); // mark the time it was pressed
- layer_on(_LOWER); // go to _LOWER layer
- } else { //when LOWER_CLICK is released
- layer_off(_LOWER); // leave _LOWER layer
- if (timer_elapsed(lowclk_hold_timer) < LOWCLK_HOLD_LIMIT)
- tap_code16(KC_MS_BTN1); // left click if macro key was held for less than LOWCLK_HOLD_LIMIT ms
- }
- break;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement