feat: Add keymap import and export#171
Conversation
Adds export (download) and import (upload) buttons to the app header toolbar, allowing users to save their keymap as a .keymap devicetree file and load one back onto the device. Export generates a formatted .keymap file with column-aligned bindings. Import parses .keymap files, resolves ZMK keycode names to HID usage codes, and applies bindings to the connected device via RPC.
✅ Deploy Preview for zmk-studio ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Hey mate! I was just testing you branch because I'm in dire need of this feature and found out that the icons are reversed. Currently the icon with the arrow going out is Import and the one with the arrow coming in is Export. It should be the other way around. Other than that THANK YOU for making import and export finally possible on ZMK. You're a lifesaver. |
Replace icon-only Download and Upload buttons with text labels for better clarity and accessibility in the keymap import/export toolbar. Co-Authored-By: Claude <noreply@anthropic.com>
8886fe0 to
8ffa859
Compare
I think it is tricky to represent with icons, as the Export Keymap was a keymap 'download' so it had the download icon, to reduce any confusion; changed to Download/Upload text buttons. |
…eady matches PR zmkfirmware#171's import unconditionally called setLayerBinding for every binding parsed out of the file. Even when the file value was identical to the device's current value (e.g. the user re-imported their own export with no edits), the firmware still flipped its "unsaved changes" flag because *some* setLayerBinding had been called. Save then appeared armed for a no-op flash write, which is both confusing and bad for flash longevity. Diff before calling: fetch keymap.layers once, then per position compare {behaviorId, param1, param2} against the parsed binding. Skip the RPC when they match and count it as `unchanged`. Reword the toast accordingly: - Everything matched: "<file> already matches the device. No changes needed." (info) - Some real updates: "Updated N binding(s) from <file> (M already matched)." with the persist reminder. - Partial / rejected: "Updated N (M already matched), skipped X, rejected Y. …" The `applied` counter is renamed `updated` to match the new semantics. preserved / skipped / failed handling is unchanged. Co-Authored-By: Claude <noreply@anthropic.com>
feat: Reliable keymap import/export (refines upstream PR zmkfirmware#171)
Summary
.keymapdevicetree file with column-aligned bindings.keymapfile, parses the devicetree syntax, resolves ZMK keycode names to HID usage codes, and applies bindings to the connected device via RPCkeymap-parser.tsutility for parsing.keymapfiles with support for standard ZMK keycodes, behavior names, and layer definitionsThis addresses the "Importing and exporting keymaps" item on the planned features list.
Test plan
.keymapfile.keymapfile and verify bindings are applied to the device