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

Add leader_add_user callback #24266

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

Add leader_add_user callback #24266

wants to merge 4 commits into from

Conversation

willbsp
Copy link

@willbsp willbsp commented Aug 11, 2024

Description

Added a user callback bool leader_add_user() for when keys are added to the leader key sequence. This callback can then be used in the user configuration to check keys as soon as they are added to the leader sequence. When true is returned, it will cause the leader sequence to end immediately, and false will continue the sequence as usual.

This opens a couple of new possibilities for user configuration, including auto-terminating leader sequences - where when a valid sequence is checked the leader sequence will end immediately, removing the delay at the end of the sequence. Additionally, for keyboards with OLED screens, it can allow for a which-key style menu to appear during the leader sequence. Both of these features are implemented in my personal userspace.

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

None, additional functionallity.

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

quantum/leader.c Outdated
@@ -61,6 +63,9 @@ bool leader_sequence_add(uint16_t keycode) {
leader_sequence[leader_sequence_size] = keycode;
leader_sequence_size++;

if (leader_add_user()) {
Copy link
Member

Choose a reason for hiding this comment

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

It might make sens to pass the keycode to the user function here.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the response. I have added the keycode as a parameter to the leader_add_user callback and updated the documentation accordingly.

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