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

feat: Discover matching layout data in config/ #26

Closed nickcoutsos closed 1 year ago

nickcoutsos commented 1 year ago

I guess this is more of a proof of concept pending how configurable you want this to be. The idea is to support automatically detecting locally provided layout data. It follows the convention I'm using in keymap-editor, looking for <keyboard>.json instead of info.json (I switched to the former a while back to support multiple keymaps in one repo without requiring branching).

Couple of notes:

caksoylar commented 1 year ago

Thanks, I think it should help and not hurt in general so I am happy with the current PR. The only potential issue I see is it not being disable-able but I doubt that $keyboard.json will be problematic if it exists so I am not sure it is worth adding an option for that.

I haven't used keymap-drawer enough to be familiar with how alternate layouts are handled. In keymap-editor I have auto-generated layouts from parsed matrix transforms, and at runtime I look for a chosen node in the keymap. I know that some of the layouts here (corne, for example) follow QMK layout naming conventions but the yaml mapping is only keyed by keyboard name.

You can see the layout selection logic here: If the json file is not just an array but follows the QMK convention (has layouts.*) you can select one of them in the yaml layout.qmk_layout: LAYOUT_split_3x5_3 or command line -l/--qmk-layout LAYOUT_split_3x5_3 etc. Otherwise the first defined one will be used.

The parser currently doesn't use the chosen transform in the ZMK keymap, because I don't have a mapping layer from ZMK transform (five_column_transform) to QMK layout (LAYOUT_split_3x5_3). So in this case the user would have to provide it via draw_args like corne:'-l LAYOUT_split_3x5_3' (where LAYOUT_split_3x5_3 would be the layout name in the json). So don't worry about it, I guess :D

nickcoutsos commented 1 year ago

Ok, cool, that's pretty much my approach, and I guess such a case would need user intervention anyway.

caksoylar commented 1 year ago

Tested it here and works great, thanks! https://github.com/caksoylar/zmk-config/actions/runs/5360919865/jobs/9726368163