-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Feature: Add physical layout support #2283
Feature: Add physical layout support #2283
Conversation
2b94480
to
d79162f
Compare
e6fb8c2
to
60e5c30
Compare
Ok, I've pushed some minor cleanups and fixes, as well as an implementation of this for ZMK Uno to show how this works. Tested working for the ZMK Uno split as well. |
60e5c30
to
e05784f
Compare
In case anyone wants to test the physical layout, here is a helper script to convert from QMK-style info.json files or ortho-like specs to a devicetree snippet for ❯ python physical_layout_to_dt.py -k corne_rotated -l LAYOUT_split_3x5_3
keys // w h x y rot rx ry
= <&key_physical_attrs 100 100 0 37 0 0 0>
, <&key_physical_attrs 100 100 100 12 0 0 0>
, <&key_physical_attrs 100 100 200 0 0 0 0>
, <&key_physical_attrs 100 100 300 12 0 0 0>
, <&key_physical_attrs 100 100 400 25 0 0 0>
, <&key_physical_attrs 100 100 800 25 0 0 0>
, <&key_physical_attrs 100 100 900 12 0 0 0>
, <&key_physical_attrs 100 100 1000 0 0 0 0>
, <&key_physical_attrs 100 100 1100 12 0 0 0>
, <&key_physical_attrs 100 100 1200 37 0 0 0>
, <&key_physical_attrs 100 100 0 137 0 0 0>
, <&key_physical_attrs 100 100 100 112 0 0 0>
, <&key_physical_attrs 100 100 200 100 0 0 0>
, <&key_physical_attrs 100 100 300 112 0 0 0>
, <&key_physical_attrs 100 100 400 125 0 0 0>
, <&key_physical_attrs 100 100 800 125 0 0 0>
, <&key_physical_attrs 100 100 900 112 0 0 0>
, <&key_physical_attrs 100 100 1000 100 0 0 0>
, <&key_physical_attrs 100 100 1100 112 0 0 0>
, <&key_physical_attrs 100 100 1200 137 0 0 0>
, <&key_physical_attrs 100 100 0 237 0 0 0>
, <&key_physical_attrs 100 100 100 212 0 0 0>
, <&key_physical_attrs 100 100 200 200 0 0 0>
, <&key_physical_attrs 100 100 300 212 0 0 0>
, <&key_physical_attrs 100 100 400 225 0 0 0>
, <&key_physical_attrs 100 100 800 225 0 0 0>
, <&key_physical_attrs 100 100 900 212 0 0 0>
, <&key_physical_attrs 100 100 1000 200 0 0 0>
, <&key_physical_attrs 100 100 1100 212 0 0 0>
, <&key_physical_attrs 100 100 1200 237 0 0 0>
, <&key_physical_attrs 100 100 250 315 0 0 0>
, <&key_physical_attrs 100 100 360 330 1500 409 380>
, <&key_physical_attrs 100 150 476 325 3000 527 400>
, <&key_physical_attrs 100 150 723 325 (-3000) 773 400>
, <&key_physical_attrs 100 100 840 330 (-1500) 890 380>
, <&key_physical_attrs 100 100 950 315 0 0 0>
; |
e05784f
to
f218060
Compare
f218060
to
03dbb65
Compare
2eda9f8
to
0045d63
Compare
a8bb7b4
to
2231048
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments, but the changes look good to me in general.
Any plans to add docs for this, or any thoughts on it? (We can discuss that on Discord.)
7957208
to
f210e89
Compare
311a6a2
to
13c2317
Compare
afc0e84
to
2adbd65
Compare
edfbe98
to
3637391
Compare
* Add bindings to allow creating multiple physical layouts that specify their key's physical attributes, and the matching matrix transform and dependant kscan to use. * Synthesize a basic physical layout if none specified, for backwards compatibility. * Update matrix transform API to explicitly pass in the selected transform to the API instead of using a fixed chosen transform. * Move kscan subscription and handling into the physical layout code, so that selecting a different physical layout at runtime can also use the correct kscan instance. * Add `physical_layouts.dtsi` file to include so you can use the pre-configured `&key_physical_attrs` for adding you layout keys.
* Update our GPIO kscan drivers to more completely support PM device, by doing proper hardare init/deinit in the PM action hook.
* Add physical layout definitions for uno and split uno shields.
* Document how to define one or more physical layouts and assign the chosen one. Co-authored-by: Cem Aksoylar <[email protected]>
3637391
to
fa4fb12
Compare
This feature enhancement adds support for "physical layouts" that describe a given keyboard layout. Example uses cases for multiple physical layouts include:
To make avoid code duplication, under the hood we are still using a "synthetic physical layout" when none are explicitly specified, using the
chosen
matrix transform and kscan nodes to set up a single physical layout that is then used.A Physical Layout includes:
Selecting a physical layout will do the necessary setup for the layout's kscan instance, and when processing kscan events, use the associated matrix transform to map that kscan event to a key position.
The code here also has some tweaks to calculate the
ZMK_KEYMAP_LEN
, aka the maximum key position index, based on the longest transform available from all the physical layouts defined, which we will use down the road in the ZMK Studio work to ensure we have enough pre-allocated locations for keymaps the user sets up after picking a layout.Not yet implemented, to come as follow up work: