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

[Bug] layer_state_set_user not called when dynamic macro restore the layer_state #16208

Closed
jmdesprez opened this issue Feb 4, 2022 · 1 comment

Comments

@jmdesprez
Copy link

Describe the Bug

I've defined this method to have autoshift on the layer 0 only:

uint32_t layer_state_set_user(layer_state_t state) {
    switch (biton32(state)) {
        case 0:
            autoshift_enable();
            break;
        default:
            autoshift_disable();
            break;
    }
    return state;
}

If I switch to a layer other than 0, autoshift is disabled (which is fine). But if I play a dynamic macro (even empty), the autoshift is now enabled.

My understanding is that https://github.com/qmk/qmk_firmware/blob/master/quantum/process_keycode/process_dynamic_macro.c#L76 reset the layer to 0 and properly call layer_state_set_user but restoring the saved state using layer_state = saved_layer_state; (https://github.com/qmk/qmk_firmware/blob/master/quantum/process_keycode/process_dynamic_macro.c#L85) doesn't call layer_state_set_user.

For now, I've solved the issue by replacing L85 with: layer_state_set(saved_layer_state);
It fix the problem (and also fix the led indicator on the Moonlander) but I'm not sure it's the proper solution.

@drashna
Copy link
Member

drashna commented Feb 5, 2022

For now, I've solved the issue by replacing L85 with: layer_state_set(saved_layer_state);

That would be the correct way to restore it.

If you wouldn't mind PRing the fix? Otherwise, I can see about doing so

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

No branches or pull requests

2 participants