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 #18977

Merged
merged 8 commits into from
Nov 6, 2022

Conversation

sigprof
Copy link
Contributor

@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
@zvecr zvecr merged commit a7b2f42 into qmk:develop Nov 6, 2022
@tzarc tzarc added the bug label Nov 6, 2022
ramonimbao pushed a commit to ramonimbao/qmk_firmware that referenced this pull request Nov 28, 2022
)

* Add macros to extract parameters from keycode values

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).

* keymap_common: Use extraction macros for keycodes

* pointing_device_auto_mouse: Use extraction macros for keycodes

Fixes qmk#18970.

* process_autocorrect: Use extraction macros for keycodes

* process_caps_word: Use extraction macros for keycodes

(Also fix a minor bug - SH_TG was not handled properly)

* process_leader: Use extraction macros for keycodes

(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.)

* process_unicode: Use extraction macros for keycodes

* process_unicodemap: Use extraction macros for keycodes
elpekenin pushed a commit to elpekenin/qmk_firmware that referenced this pull request Dec 7, 2022
)

* Add macros to extract parameters from keycode values

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).

* keymap_common: Use extraction macros for keycodes

* pointing_device_auto_mouse: Use extraction macros for keycodes

Fixes qmk#18970.

* process_autocorrect: Use extraction macros for keycodes

* process_caps_word: Use extraction macros for keycodes

(Also fix a minor bug - SH_TG was not handled properly)

* process_leader: Use extraction macros for keycodes

(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.)

* process_unicode: Use extraction macros for keycodes

* process_unicodemap: Use extraction macros for keycodes
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants