ferris icon indicating copy to clipboard operation
ferris copied to clipboard

About the qmk config: how does the layout macro work?

Open x4Cx58x54 opened this issue 2 years ago • 3 comments

Hi! I found this project very interesting and I am trying to understand your qmk configuration code. You see, the keymap array has size num_layerxMATRIX_ROWSxMATRIX_COLS, that is, n x 8 x 10 in this project. However, the LAYOUT macro seems to disagree, as it has a different size. I doubt this definition will map the second row on the left side to the first row of the right side. Would you be so kind to explain why it works?

x4Cx58x54 avatar May 05 '22 18:05 x4Cx58x54

As far as qmk is concerned, the keyboard has 8 rows of 5 columns: 4 per keyboard half.

The layout macro describes how to map one list of keys which are layed out like the physical keys on the keyboard (could be seen as 3 rows of 10 + 1 row of 4) into the firmware's view of the keyboard.

Does that make more sense?

pierrechevalier83 avatar May 05 '22 18:05 pierrechevalier83

And that is to say, although 8x10 space is allocated for keymap array, half of it is used and the other half remains empty. I think I got it. Thanks!

x4Cx58x54 avatar May 06 '22 01:05 x4Cx58x54

Oh. I see. The surprising lines of code are this one: https://github.com/qmk/qmk_firmware/blob/8f660ca1e652b3b53580442d321642165adbc7d0/keyboards/ferris/0_2/config.h#L29 which defines MATRIX_COLS at 10 and this one: https://github.com/qmk/qmk_firmware/blob/8f660ca1e652b3b53580442d321642165adbc7d0/keyboards/ferris/0_2/config.h#L54 which allocates A1 to the 5 rightmost pins.

This does feel like an oversight now we've discussed it. As well as the one where A1 is alloca

pierrechevalier83 avatar May 06 '22 08:05 pierrechevalier83