benblazak / ergodox-firmware

firmware for the ergoDOX keyboard
Other
595 stars 296 forks source link

Ergodox layout macros #72

Closed lotem closed 4 years ago

lotem commented 8 years ago

Hi there. I have a bit of code that might interest you.

I'm thankful of people who created and shared their Ergodox layout code that helps me get started and evolve my own. In the process of tweaking the keyboard, I find myself not only rearranging keys within the alphabet zone, but also frequently moving function keys and layer switching keys around. Having to carefully edit several places to get one key right truly annoys me. As a try to fix that, I created a set of helper macros to generate the arrays for key codes, press and release functions.

The philosophy of this PR is to keep any change to a key in one place, namely xxx-layout.h. This header file, with layout definition in ERGODOX_LAYOUT macro, is included three times into the C module, each given a different set of key-defining macros. The nice part is you can write the three values associated to a key all in one place, eg. S(_equal) for a + key; you never have to scroll down to know that it comes with a combined Shift. This I believe leads to shorter, more readable and less error-prone code.

I've created a sample layout with this feature, an incomplete rewrite of qwerty-kinesis-mod, just to give you a taste. If you do think it helpful to others as well, please give comments on how this PR can be improved for inclusion. Thanks.