Add a procedural macro for defining layouts #54
Merged
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.
Add a procedural macro to generate
keyberon::layout::Layersconst fns to createActions could be deprecated/removed, solving avoid relying on implicit promotion #41Possible future extensions
Issues
Action::MultipleKeyCodesandAction::MultipleActions, so the macro always usesMultipleActionswhich can increase binary size slightly (possible improvement in the future)Syntax
Items inside the macro are converted to Actions as such:
Action::KeyCode: Idents are automatically understood as keycodes:A,RCtrl,Spaceto KeyCodes as well:
,becomesKeyCode::Commma,2becomesKeyCode::Kb2,/becomesKeyCode::SlashAction::MultipleKeyCodes(&[LShift, <character>]):!becomesAction::MultipleKeyCodes(&[LShift, Kb1])etcleft alone cause parsing errors and as such have to be enclosed by apostrophes:
'['becomesKeyCode::LBracket,'\''becomesKeyCode::Quote,'\\'becomesKeyCode::BSlashAction::NoOp: LowercasenAction::Trans: LowercasetAction::Layer: A number in parentheses:(1),(4 - 2),(0x4u8 as usize)Action::MultipleActions: Actions in brackets:[LCtrl S],[LAlt LCtrl C],[(2) B {Action::NoOp}]Actions: anything in braces ({}) is copied unchanged to the final layout -{ Action::Custom(42) }simply becomes
Action::Custom(42)Important note: comma (
,) is a keycode on its own, and can't be used to separate keycodes as one would haveto do when not using a macro.
Usage example:
Example layout for a 4x12 split keyboard: