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

Fix keycode parameter extraction to match the new DD keycodes #13

Closed
wants to merge 8 commits into from

Conversation

sigprof
Copy link
Owner

@sigprof sigprof commented Nov 6, 2022

Description

QMK has many keycodes with parameters, like TO(layer) or MT(mod, kc). Add macros for extracting the values of those parameters from the keycode, so that the bit allocation for those parameters can be performed in a single place where those macros are defined; then change various code that was extracting the parameters manually to use those macros.

Macro names are based on the full QK_xxx range name; e.g., for MO(layer) it is QK_MOMENTARY_GET_LAYER(kc).

This change actually fixes several regressions introduced by DD keycode changes (mainly due to bit masks for layer-related keycodes no longer being correct).

Tested mostly by make test:all (which unfortunately does not cover much of the affected code); the TT() bug was verified on some actual hardware. And probably not all problematic places have been found yet.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Implement both encoding and decoding for keycodes like TO(layer) or
LM(layer, mod) in one place, so that the decoding won't get out of sync
with the encoding.

While at it, fix some macros for creating keycode values that did not
apply the appropriate masks to parameters (and therefore could allow the
result to be out of range if a wrong parameter was passed).
(Also fix a minor bug - SH_TG was not handled properly)
(Technically the code is not 100% correct, because it always assumes
that the LT() or MT() action was a tap, but it's a separate issue that
already existed before the keycode changes.)
@github-actions github-actions bot added the core label Nov 6, 2022
@sigprof sigprof closed this Nov 6, 2022
@sigprof sigprof deleted the keycode-parameters-extraction branch February 18, 2023 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant