Keyboard Layout Manager Cleanup/Improvements
There are several issues I have with the Keyboard Layout Manager as-is that I want to improve with this MR.
-
Instead of using a starting map that includes an entire full key layout and then removing sections to get smaller layouts, I think it makes more sense to assemble the layout from logical keyboard layout blocks. These blocks include the "main" key block, the Esc/Function row, the "extras" block (print screen row, insert block, arrow keys), and the number pad block. By making a bitfield to represent these blocks, they can be combined to create the desired layouts and we can additionally add a "75%" layout which is main+function row.
-
Code cleanup surrounding the insert, swap, and remove functions. I want to use indexed accesses to the vectors to make the code easier to read, add comments, and simplify the behavior. Insert should now always shift all keys in the inserted row to the right, starting at the key after the newly inserted key, regardless of whether there are holes in that row. Swap keys should not perform any shifting. Remove should shift the row right after the removed key.
-
Move KeyboardLayoutManager to its own folder, as I don't think it really belongs in RGBController. It would be nice if all controllers utilized it, but I don't see that happening, so I think it makes sense as its own separate component.
Things not yet implemented up for discussion:
- I think it would be preferable to create a sequence-driven approach to modifying KLM layouts, rather than always performing inserts first, then swaps, then removals. I think using an "opcode" approach would make sense. Define an enum of "opcodes" like insert, swap, remove, and potentially others (maybe insert row?). Then, a KLM overlay would be a list of "instructions", same as they are now but with an opcode field to specify what operation to perform. This way you can mix instruction order, such as removing some keys before performing a replace.