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(hid) Basic support for generic desktop usage page #2473

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

Conversation

angweekiat
Copy link
Contributor

@angweekiat angweekiat commented Sep 10, 2024

Add basic support for "Generic Desktop" page, behind a ZMK_HID_GENERIC_DESKTOP_USAGES_BASIC KConfig, that works over USB and BLE, in particular for only 15 keys:

SYSTEM_POWER_DOWN SYSTEM_SLEEP SYSTEM_WAKE_UP SYSTEM_CONTEXT_MENU SYSTEM_MAIN_MENU
SYSTEM_APP_MENU SYSTEM_MENU_HELP SYSTEM_MENU_EXIT SYSTEM_MENU_SELECT SYSTEM_MENU_RIGHT
SYSTEM_MENU_LEFT SYSTEM_MENU_UP SYSTEM_MENU_DOWN SYSTEM_COLD_RESTART SYSTEM_WARM_RESTART

See Section 4 of https://www.usb.org/sites/default/files/hut1_5.pdf for the full list of possible usages. Verified that system keys are intercepted by the host machine using evtest, even though the machine doesn't do anything in response to most buttons, outside of SYSTEM_POWER_DOWN and SYSTEM_SLEEP.

Note

Upon coming across #1535 where the mute button was mentioned, I initially extended the work to additionally include up to 32 keys in total:

  • System Dock (0xA0) to System Microphone Mute (0xA9),
  • System Display Invert (0xB0) to System Display Swap Primary/Secondary (0xB6).

However, the linux machine that I'm testing on doesn't support the additional keys (uname -r -> 5.15.0-72-generic). If there's interest in these keys, and testing that it works, I'm happy to update the PR to include them. (I won't be able to test the keys myself)

Note 2

There's quite a bit of similar looking code between how the different keyboard, consumer, hid indicator, generic desktop pages are handled, across the relevant files. It may be possible to clean up some of the duplication if that's wanted, probably in a follow up PR.

Also, given that SYS_PWR and the other 2 system keys are already defined, maybe it's better if the config is set to true by default, or removed?

Test steps

  • Flash central device with ZMK_HID_GENERIC_DESKTOP_USAGES_BASICenabled, with key map that uses the system keys above
  • Re-pair the keyboard's Bluetooth connection, due to new attributes being added
  • Try out the system keys! (Use evtest to verify that system events are coming in)

@angweekiat angweekiat requested a review from a team as a code owner September 10, 2024 11:02
@petejohanson
Copy link
Contributor

@angweekiat It would definitely be nice to try to add the system microphone mute for testing on this PR.

On the duplication side of things, there's some great work on that in #2363 that will hopefully progress soon. Timing wise we'll see which is further first and merge/rebase/fixup as needed.

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.

3 participants