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] Media keycode(and some others) doesn't work well with Oneshot layer #14658

Closed
3 tasks
ForsakenRei opened this issue Sep 30, 2021 · 2 comments
Closed
3 tasks

Comments

@ForsakenRei
Copy link
Contributor

ForsakenRei commented Sep 30, 2021

OSL didn't work on some of the keycode avaiable but works for custom keycode.

Describe the Bug

I use Fn as a Oneshot layer key with some media keys like KC_MPLY, KC_VOLU and some other keycode like KC_CALC and KC_LOCK on that layer. I also put a custom keycode C(S(KC_ESC)) for test purpose.

If I tap Fn, the one shot layer was activated(LED indicator for that layer lights up) but KC_MPLY or KC_CALC won't work, while my custom keycode C(S(ESC)) and KC_LOCK works fine. KC_VOLU worked once but acted as stuck to turn my volume all the way down to mute.

If I hold Fn, everything just works fine. And switch to that layer everything works fine, too.

The issue was found originally when I use a tap dance on my Fn to activate the one shot layer, after that I tried OSL(1) but it doesn't work either.

System Information

  • Keyboard: GMMK Pro ANSI(STM32)

  • Operating system: Windows 10

  • AVR GCC version: 8.4.0

  • ARM GCC version: 10.1.0
  • QMK Firmware version: 0.13.23
    tested on both master and dev branch
  • Any keyboard related software installed?
    • AutoHotKey
    • Karabiner
    • Other:

Additional Context

@sigprof
Copy link
Contributor

sigprof commented Sep 30, 2021

This might be a combination of two problems:

  1. The code which handles turning the one shot layer off fakes a key release event immediately after processing the key press event. Because those events are separate, the release event bypasses TAP_CODE_DELAY (which is the usual solution for the media keys not registering properly), and therefore can trigger the problem 2 below.
    #ifndef NO_ACTION_ONESHOT
    /* Because we switch layers after a oneshot event, we need to release the
    * key before we leave the layer or no key up event will be generated.
    */
    if (do_release_oneshot && !(get_oneshot_layer_state() & ONESHOT_PRESSED)) {
    record->event.pressed = false;
    layer_on(get_oneshot_layer());
    process_record(record);
    layer_off(get_oneshot_layer());
    }
    #endif

    I'm not sure whether that piece of code is really needed (or maybe it should be inside #ifdef STRICT_LAYER_RELEASE) — usually the source layer cache ensures that the key release event would be handled using the same keycode that was used for the matching key press event, and therefore just turning off the one shot layer should be enough.
  1. The ChibiOS implementation of the code which actually sends the events for media keys to the host may misbehave if it is invoked before the previous event has been read by the host. PR [Bugfix] Check USB transmit status in ChibiOS send_extra()  #14643 attempts to fix that, but it is still not decided which way to fix the problem would be the most correct one.

@ForsakenRei
Copy link
Contributor Author

ForsakenRei commented Oct 1, 2021

@sigprof Thanks for the heads up. Actually @daskygit discussed his issue with me earlier in discord server, though the symptoms are different but it seems they are quite related. I will keep an eye on that pull request.

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