feat(hid) Basic support for generic desktop usage page #2473
+352
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ofSYSTEM_POWER_DOWN
andSYSTEM_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)
toSystem Microphone Mute (0xA9)
,System Display Invert (0xB0)
toSystem 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
ZMK_HID_GENERIC_DESKTOP_USAGES_BASIC
enabled, with key map that uses the system keys aboveevtest
to verify that system events are coming in)