Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

leaders #29

Open
Setkias opened this issue Jan 4, 2025 · 3 comments
Open

leaders #29

Setkias opened this issue Jan 4, 2025 · 3 comments

Comments

@Setkias
Copy link

Setkias commented Jan 4, 2025

I setup hrm using custom codes and SMTD_MT. But those keys that use sm_td, do not seem to work well when part of a leader sequence.
I've tried replacing the KC_... with my custom CKC_ codes in the leader_end_user callback but that did not work. Am I missing something? Is there a way to make it work?

@stasmarkin
Copy link
Owner

Could you please specify about what you are trying to accomplish? I'm not quite sure what you're talking about.

It would help me if you wrote in the format “I press this and this, and the OS receives such and such events from the keyboard”. And if you are able to share the code of your keymap, that would help me a lot too

@Setkias
Copy link
Author

Setkias commented Jan 4, 2025

Setup:

enum custom_keycodes { 
    SMTD_KEYCODES_BEGIN = SAFE_RANGE,
    S_A,
    S_S,
    S_D,
    S_K,
    S_L,
    S_SEMICOLON,
    SMTD_KEYCODES_END,
.....

void on_smtd_action(uint16_t keycode, smtd_action action, uint8_t tap_count) {
    switch (keycode) {
        SMTD_MT(S_D, KC_D, KC_LEFT_SHIFT) 
        SMTD_MT(S_K, KC_K, KC_RIGHT_SHIFT)

        SMTD_MT(S_S, KC_S, KC_LEFT_CTRL)
        SMTD_MT(S_L, KC_L, KC_RIGHT_CTRL)

        SMTD_MT(S_A, KC_A, KC_LEFT_ALT)
        SMTD_MT(S_SEMICOLON, KC_SEMICOLON, KC_RIGHT_ALT)
    }
}

In my keymap have a key set to QK_LEAD and S_A, S_S, S_F, .... etc. on the home row.

and define actions to happen on certain sequences in leader_end_user:

void leader_end_user(void) {
	if (leader_sequence_two_keys(S_A, KC_C)) {
        	// Send CTRL-A CTRL-C
        	SEND_STRING(SS_LCTL("ac"));
	} else if (leader_sequence_two_keys(S_A, KC_X)) {
        	// Send CTRL-A CTRL-X
        	SEND_STRING(SS_LCTL("ax"));
        } else if (leader_sequence_three_keys(KC_Q, KC_W, KC_E)) {
                SEND_STRING("LEADER TEST SUCCESS.");
        }
}

When I press sequence leader key qwe I get LEADER TEST SUCCESS.
When I type leader key ac and leader key ax I do not. The OS sees an 'a'.

@Setkias
Copy link
Author

Setkias commented Jan 4, 2025

Assuming like caps word, leader_sequence_active() is a state to take into account, I've modified the SMTD5 macro in sm_td.h to check for that and add it to the leader buffer if active.

#define SMTD_MT5(macro_key, tap_key, mod, threshold, use_cl) \
    case macro_key: {                                        \
        switch (action) {                                    \
            case SMTD_ACTION_TOUCH:                          \
                break;                                       \
            case SMTD_ACTION_TAP:                            \
                if (leader_sequence_active()) {              \
                    leader_sequence_add(tap_key);            \
                } else {                                     \
                    SMTD_TAP_16(use_cl, tap_key);            \
                }                                            \
                break;                                       \

and use KC_ codes in leader_end_user(void) instead of the custom ones.

void leader_end_user(void) {
    if (leader_sequence_two_keys(KC_A, KC_C)) { // Instead of (S_A, KC_C)

And it seems to work. I did not do any thorough testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants