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

Community modules #24848

Merged
merged 36 commits into from
Feb 26, 2025
Merged

Community modules #24848

merged 36 commits into from
Feb 26, 2025

Conversation

tzarc
Copy link
Member

@tzarc tzarc commented Jan 21, 2025

Description

Add support for community modules. Community modules are intended to be an area which provides common functionality to be easily imported into a keymap.

Additionally, community modules support placement inside userspace; module developers can thus create modules in separate repositories, and users can subsequently add them as userspace-local submodules to make them available for use in user keymaps.

  • keyboard.json, info.json, and keymap.json now accept a top-level array of strings called "modules"
  • Keyboard-imported modules precede keymap-imported modules.
  • Module implementations are able to hook an initial set of key APIs within QMK, now allowing for the sequence _modules => _kb => _user.
  • Each module has an equivalent hook API generated and invoked inside _modules, in the module order provided.
    • For a single API example, the hello_world module has the following overridable functions defined:
      • process_record_hello_world_user -- a no-op but allows user keymaps to hook the module
      • process_record_hello_world_kb -- invokes _user by default, follows the same callback ordering as the rest of QMK
      • process_record_hello_world -- the actual module implementation of process_record_xxxx, executed before process_record_kb or process_record_user.
  • The full list of hookable APIs will be present in the documentation when written.
  • An introspection.c file present in the module's directory will automatically be injected into the keymap.c during compilation, using the same mechanism as the rest of core's keymap_introspection.c. Same for introspection.h.

A couple of community modules I've used for testing can be found here.

Types of Changes

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

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

@github-actions github-actions bot added core python cli qmk cli command dd Data Driven Changes labels Jan 21, 2025
@tzarc tzarc changed the title [WIP] First stab at community modules. [WIP] Community modules Jan 21, 2025
@github-actions github-actions bot added the CI label Jan 24, 2025
@tzarc tzarc changed the title [WIP] Community modules Community modules Jan 24, 2025
@tzarc tzarc marked this pull request as ready for review January 24, 2025 10:51
@tzarc tzarc requested a review from a team January 24, 2025 10:51
@getreuer
Copy link
Contributor

Very cool! I'm excited to see ASSERT_COMMUNITY_MODULES_MIN_API_VERSION. With my userspace libs, I do a hacky preprocessor check to detect very old QMK versions:

#if !defined(IS_QK_MOD_TAP)
// Attempt to detect out-of-date QMK installation, which would fail with
// implicit-function-declaration errors in the code below.
#error "achordion: QMK version is too old to build. Please update QMK."
#else
// Achordion implementation...

ASSERT_COMMUNITY_MODULES_MIN_API_VERSION is way better =)

@tzarc tzarc force-pushed the community-modules branch from 8e3cec0 to e86d8d2 Compare February 6, 2025 05:49
@tzarc tzarc force-pushed the community-modules branch from 138b726 to 4758f6c Compare February 7, 2025 12:38
@tzarc tzarc force-pushed the community-modules branch from 519bd5a to 244a9cf Compare February 7, 2025 12:54
@tzarc tzarc added the breaking_change_2025q1 Targeting breaking changes Q1 2025 label Feb 16, 2025
@tzarc tzarc force-pushed the community-modules branch from 61b8e6f to ed36462 Compare February 25, 2025 03:18
@tzarc tzarc merged commit 1efc824 into develop Feb 26, 2025
8 checks passed
@tzarc tzarc deleted the community-modules branch February 26, 2025 11:25
@thomasbaart
Copy link
Contributor

This is a super cool development, and it's looking good!

A suggestion I'd like to make would be to have a community module be able to define their own part of the switch matrix, as a way to support hardware modules.

We added support for our splitkb.com Halcyon modules (which currently are a display, rotary encoder and cirque trackpad) through a QMK userspace, but I feel like the implementation of modules in this pull request could be far cleaner and easier to adapt and adopt for users.

A challenge we faced is that hardware modules (such as the encoder) can introduce additional inputs to the keyboard matrix, while the keyboard has no dedicated spots in its matrix for them. I think it would be nice if a module could introduce its own part of the matrix, so that keys can be mapped to it in software like VIA or Vial. VIA or Vial would be able to display an additional tab called "Modules" for example, in which each module could expose its matrix for easy remapping.

It's a long shot for sure! I hope this idea might provide inspiration for future development if it comes to that. Thank you very much!

@tzarc
Copy link
Member Author

tzarc commented Feb 26, 2025

There's definitely future improvements to be made, including stuff like dealing with data storage and persistence.
I'm sure there will be future discussions covering information like what you've proposed -- we'll see how we go.

johanbast pushed a commit to johanbast/qmk_firmware that referenced this pull request Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking_change_2025q1 Targeting breaking changes Q1 2025 CI cli qmk cli command community_module core dd Data Driven Changes documentation keymap python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants