Repository navigation
Conversation
Read, back up, diff and write the per-layer keymap of NuPhy's own-firmware boards (GetUseKeys/SetUseKeys/RestoreUseLayers), with named keycodes and Air75 V3 key positions. keymap apply takes a declarative TOML file, writes only the keys that change, and verifies every write by reading it back.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds
nuphyctl keymap, for reading and remapping the keymap on boards that run NuPhy's own firmware (the data NuPhy IO edits), so a keymap can live in a dotfiles TOML file and be applied from the command line.What's in it
keymap info: firmware version, current mode and keymap geometry.keymap dump: the whole keymap, one layer or one mode, with named keycodes and positions.--defaultsreads the factory keymap,--changedshows only keys that differ from it,--raw-outsaves a full binary backup.keymap set --layer L <pos> <code>: set one key.keymap apply <file.toml>: declarative remap. Prints the diff, writes only keys that change, and is idempotent.keymap exportproduces such a file from the keyboard's current changes.keymap restore-backup <file.bin>andkeymap reset --mode windows|mac|all --yes.keymap keycodes/keymap positionslist the names. Every command takes--json.Every write first saves a backup of the whole keymap under
$XDG_STATE_HOME/nuphyctl/, then reads the keymap back and fails unless it matches exactly.Protocol
It uses the existing framing and session key. The new commands are
0xA0GetBase,0xA1GetFirmwareInfo,0xB1GetDefaultKeys,0xB2GetUseKeys,0xB3SetUseKeys and0xB4RestoreUseLayers. Each layer is 196 bytes: 6x16 matrix keys plus 2 knob entries, 2 bytes each, big-endian, QMK-style keycodes, with NuPhy's own functions at0x7Exx. Layers 0-3 are Mac mode and 4-7 Windows mode. The details are indocs/reverse-engineering.md.Testing
cargo fmt --check,cargo clippy --all-targets --all-features -- -D warningsandcargo test --all-features(27 new unit tests) pass.keymap reset(0xB4) is implemented from the NuPhy IO web app's code but hasn't been run on hardware yet.Named positions follow the Air75 V3 layout. Other boards with this firmware should work with
row,color#indexpositions, but I've only tried the Air75 V3.