Added support for custom keymaps, added support for yaml configuration and refactored parts to modern C++23#7
Conversation
Refactorings: - Update syntax to modern C++23 - Use typealiases - Use modern trailing return type function definition syntax - Reduce pointer usages - Eliminate `push_backs` by using constructors - Eliminate `using namespace std` littering - Eliminate duplication of typenames using auto - Eliminate deletes at end of main - Eliminate unnecessary heap allocations - Eliminate unbraced if statements
Added support for custom keymappings
maricn
left a comment
There was a problem hiding this comment.
overall, i'm very thankful for your contribution - looks great! just a couple of minor comments..
| // special chars | ||
| {KEY_E, KEY_ESC}, | ||
| {KEY_D, KEY_DELETE}, | ||
| {KEY_B, KEY_BACKSPACE}, | ||
|
|
||
| // vim home row | ||
| {KEY_H, KEY_LEFT}, | ||
| {KEY_J, KEY_DOWN}, | ||
| {KEY_K, KEY_UP}, | ||
| {KEY_L, KEY_RIGHT}, | ||
|
|
||
| // vim above home row | ||
| {KEY_Y, KEY_HOME}, | ||
| {KEY_U, KEY_PAGEDOWN}, | ||
| {KEY_I, KEY_PAGEUP}, | ||
| {KEY_O, KEY_END}, | ||
|
|
||
| // number row to F keys | ||
| {KEY_1, KEY_F1}, | ||
| {KEY_2, KEY_F2}, | ||
| {KEY_3, KEY_F3}, | ||
| {KEY_4, KEY_F4}, | ||
| {KEY_5, KEY_F5}, | ||
| {KEY_6, KEY_F6}, | ||
| {KEY_7, KEY_F7}, | ||
| {KEY_8, KEY_F8}, | ||
| {KEY_9, KEY_F9}, | ||
| {KEY_0, KEY_F10}, | ||
| {KEY_MINUS, KEY_F11}, | ||
| {KEY_EQUAL, KEY_F12}, | ||
|
|
||
| // xf86 audio | ||
| {KEY_M, KEY_MUTE}, | ||
| {KEY_COMMA, KEY_VOLUMEDOWN}, | ||
| {KEY_DOT, KEY_VOLUMEUP}, | ||
|
|
||
| // mouse navigation | ||
| {BTN_LEFT, BTN_BACK}, | ||
| {BTN_RIGHT, BTN_FORWARD}, |
There was a problem hiding this comment.
True, they were in the original source.They don't affect the behaviour though, since existent keys get overridden.
Will remove them in a moment.
|
I moved to the meson build system for portably including |
| - {from: KEY_D, to: KEY_DELETE} | ||
|
|
||
| # possibly even | ||
| - layer: KEY_SPACE |
There was a problem hiding this comment.
i know this is a future suggestion only, but just a small comment that it would mean a lot of repetition compared to nested approach..
| # special chars | ||
| - from: KEY_E | ||
| to: KEY_ESC | ||
|
|
||
| - from: KEY_D | ||
| to: KEY_DELETE | ||
|
|
||
| - from: KEY_B | ||
| to: KEY_BACKSPACE | ||
|
|
||
| # vim home row | ||
| - from: KEY_H | ||
| to: KEY_LEFT | ||
|
|
||
| - from: KEY_J | ||
| to: KEY_DOWN | ||
|
|
||
| - from: KEY_K | ||
| to: KEY_UP | ||
|
|
||
| - from: KEY_L | ||
| to: KEY_RIGHT | ||
|
|
||
| # vim above home row | ||
| - from: KEY_Y | ||
| to: KEY_HOME | ||
|
|
||
| - from: KEY_U | ||
| to: KEY_PAGEDOWN | ||
|
|
||
| - from: KEY_I | ||
| to: KEY_PAGEUP | ||
|
|
||
| - from: KEY_O | ||
| to: KEY_END | ||
|
|
||
|
|
||
| # number row to F keys | ||
| - from: KEY_1 | ||
| to: KEY_F1 | ||
|
|
||
| - from: KEY_2 | ||
| to: KEY_F2 | ||
|
|
||
| - from: KEY_3 | ||
| to: KEY_F3 | ||
|
|
||
| - from: KEY_4 | ||
| to: KEY_F4 | ||
|
|
||
| - from: KEY_5 | ||
| to: KEY_F5 | ||
|
|
||
| - from: KEY_6 | ||
| to: KEY_F6 | ||
|
|
||
| - from: KEY_7 | ||
| to: KEY_F7 | ||
|
|
||
| - from: KEY_8 | ||
| to: KEY_F8 | ||
|
|
||
| - from: KEY_9 | ||
| to: KEY_F9 | ||
|
|
||
| - from: KEY_0 | ||
| to: KEY_F10 | ||
|
|
||
| - from: KEY_MINUS | ||
| to: KEY_F11 | ||
|
|
||
| - from: KEY_EQUAL | ||
| to: KEY_F12 | ||
|
|
||
|
|
||
| # xf86 audio | ||
| - from: KEY_M | ||
| to: KEY_MUTE | ||
|
|
||
| - from: KEY_COMMA | ||
| to: KEY_VOLUMEDOWN | ||
|
|
||
| - from: KEY_DOT | ||
| to: KEY_VOLUMEUP | ||
|
|
||
|
|
||
| # mouse navigation | ||
| - from: BTN_LEFT | ||
| to: BTN_BACK | ||
|
|
||
| - from: BTN_RIGHT | ||
| to: BTN_FORWARD | ||
|
|
I think reading config in runtime with fallback to hardcoded/compiled defaults is perfect, as you did. |
maricn
left a comment
There was a problem hiding this comment.
I think this looks great. If you feel this is ready, I'm approving it.
(at cost of breaking compatibility with future config.yaml structural changes, but i'm sure if we do break them, the changes will be minimal)
Refactorings:
push_backsby using constructorsusing namespace stdlitteringFeature(custom keymaps):