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

feat: Parameterised Mod Morph and Tap Dance #2724

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Nick-Munnich
Copy link
Contributor

@Nick-Munnich Nick-Munnich commented Dec 19, 2024

General idea is to have a binding-params array property which maps parameters input to the behavior to the behaviors found in the bindings array. Bit flags and some macros to tidy it all up.

Docs are included, I decided to substitute the references to the non-parameterised version with the parameterised one in the interest of "one way to do it". Current one was moved to a footnote.

In general I think the approach and user experience side of things is good. May add more tests. Unsure whether documentation needs further reworking or if the non-parameterised version should remain prominent.

PR check-list

  • Branch has a clean commit history
  • Additional tests are included, if changing behaviors/core code that is testable.
  • Proper Copyright + License headers added to applicable files (Generally, we stick to "The ZMK Contributors" for copyrights to help avoid churn when files get edited)
  • Pre-commit used to check formatting of files, commit messages, etc.

TODO:

  • Identify a solution to the hold-tap issue.
  • Add behavior metadata for Studio.

@Nick-Munnich Nick-Munnich requested review from a team as code owners December 19, 2024 00:27
@Nick-Munnich Nick-Munnich marked this pull request as draft December 19, 2024 00:27
@Nick-Munnich Nick-Munnich marked this pull request as ready for review December 19, 2024 09:55
Copy link
Contributor

@caksoylar caksoylar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is pretty nice. A few things worth discussing:

  • Forcing mod-morphs and tap-dances to always have two parameters prevents them from being used in hold-taps, or inside parametrized mod-morph/tap-dances. This is a big limitation, so it might be worth keeping around zero-param versions as the main variants.
  • These are a bit inconsistent w.r.t. parametrized macros, they are more flexible so we can't easily unify them. One thing we can do is switch to PLACEHOLDER instead of MACRO_PLACEHOLDER in the macro docs.

app/src/behaviors/behavior_tap_dance.c Outdated Show resolved Hide resolved
app/src/behaviors/behavior_mod_morph.c Outdated Show resolved Hide resolved
docs/docs/keymaps/behaviors/mod-morph.md Show resolved Hide resolved
docs/docs/keymaps/behaviors/mod-morph.md Outdated Show resolved Hide resolved
docs/docs/keymaps/behaviors/tap-dance.mdx Outdated Show resolved Hide resolved
docs/docs/keymaps/behaviors/tap-dance.mdx Outdated Show resolved Hide resolved

The `binding-params` property determines how the parameters passed to the tap-dance behavior are passed on to the behaviors listed in `bindings`.
It is an array of `BINDING_PARAM(arg1,arg2)` elements, one for each behavior in `bindings`.
The Nth `BINDING_PARAM(arg1,arg2)` corresponds to the Nth behavior listed in `bindings`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is worded slightly differently compared to mod morph, it is probably worth keeping them same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The slightly different wording is due to one of them being of fixed length 2, while the other can vary. If this was extended to hold-tap and macros I'd use the mm wording for hold-tap and the td wording for macros.

app/src/behaviors/behavior_mod_morph.c Outdated Show resolved Hide resolved
@Nick-Munnich
Copy link
Contributor Author

Nick-Munnich commented Jan 2, 2025

* Forcing mod-morphs and tap-dances to always have two parameters prevents them from being used in hold-taps, or inside parametrized mod-morph/tap-dances. This is a big limitation, so it might be worth keeping around zero-param versions as the main variants.

You should be able to use them inside the others with appropriate 0s being passed in the right places. I'll add some more tests to be sure.

EDIT: parameterised nesting works fine, hold-tap is an issue that needs to be discussed to find the right resolution.

* These are a bit inconsistent w.r.t. parametrized macros, they are more flexible so we can't easily unify them. One thing we can do is switch to `PLACEHOLDER` instead of `MACRO_PLACEHOLDER` in the macro docs.

I think that both hold-tap and parameterised macros could be adjusted to use a binding-params, I just wanted to get the ones which aren't yet parameterised done before working on (understanding and) adjusting macro and hold-tap. Definitely agree on switching away from MACRO_PLACEHOLDER.

@Nick-Munnich Nick-Munnich force-pushed the mod-morph-param branch 2 times, most recently from 0b5f4d3 to 2825669 Compare January 3, 2025 14:23
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.

2 participants