caksoylar / keymap-drawer

Visualize keymaps that use advanced features like hold-taps and combos, with automatic parsing
https://caksoylar.github.io/keymap-drawer
MIT License
730 stars 62 forks source link

feature request: add support for overlaid devicetree node property values #66

Closed SethMilliken closed 8 months ago

SethMilliken commented 11 months ago

I have a shared .dtsi file that defines most of the ZMK behaviors I use across multiple boards. But some boards require different values for specific properties in some of these behaviors, predominantly key-positions in combos. I accomplish this for ZMK by using a second local #include of an .overlay file which uses node label references to override the necessary property values. But this does not currently work for keymap-drawer, which appears to use only the original node definitions. I would like to add support for this kind of devicetree overlay to keymap-drawer.

Example:

For boards that mostly have this layout:

0 1 2 3
4 5 6 7

here is a sample shared.dtsi:

/ {
    combos {
      compatible = "zmk,combos";

      combo_delete: combo_delete {
        timeout-ms: <75>;
        slow-release;
        key-positions: <0 4>;
        bindings = <&kp DELETE>;
        layers = <0>;
      };
    };
};

And for a board having more columns, with a layout like this:

0 1 2 3  4  5
6 7 8 9 10 11

here is a sample wider.overlay:

&combo_delete {
  key-positions: <0 6>;
};

So at the top of wider.keymap there would be:

...
#include "shared.dtsi"
#include "wider.overlay"
...

which would result in a modified combo_delete node with only the key-positions property value changed.

caksoylar commented 11 months ago

I think the crux of the issue is that the DTS parser doesn't do anything with node overrides like &node_ref {...};. That would certainly be implementable within keymap_drawer/parse/dts.py, if you want to give it a shot.

SethMilliken commented 11 months ago

Sounds good. That file is where I had been looking. I wrote this issue up as a way of forcing myself to clearly articulate exactly what it was I hoped to accomplish. And to make sure it still seemed reasonable after doing so. 😅

caksoylar commented 8 months ago

Hey @SethMilliken, have you done any work on this yet? If not, I can have a look pretty soon.

SethMilliken commented 8 months ago

Hey @SethMilliken, have you done any work on this yet? If not, I can have a look pretty soon.

I have not. Currently shaving yaks grazing in a completely different field.

SethMilliken commented 8 months ago

Thank you for doing this! Worked flawlessly with my Planck override setup that prompted my opening this issue in the first place.