#define IS_SYSCTL B00000001
#define IS_INTERNAL B00000010
#define SWITCH_TO_KEYMAP B00000100
#define IS_CONSUMER B00001000
/* HID types we need to encode in the key flags for system and consumer control hid controls
Each key can only have one, so we don't need to use a bit vector.
We need to keep the top two bits clear for defining the keys as synthetic
We need to keep the bottom two bits clear for defining the keys as sysctl / consumerctl
*/
However the line:
We need to keep the bottom two bits clear for defining the keys as sysctl / consumerctl
seems erroneous because the second lowest bit is used for “internal” and not “consumer”? As per the first line of the comment:
/* HID types we need to encode in the key flags for system and consumer control hid controls
… the part about consumer control seems important, but this means that the following additional HID type markers conflict with the existing marker for consumer control B00001000:
Technically, you could use it for a lot of things. But stuff that does not have the RESERVED flag are by convention off-limits to anything non-core (excluding stuff like LEDControl, which used to be part of the core firmware).
This appears to be a bug, indeed. IS_CONSUMER and IS_INTERNAL were swapped as part of Kaleidoscope#242. Looks like the comments weren’t updated at the time.
Historical reasons. In the very beginning, keymaps were defined in a text file, and a Perl script processed them into a C++ header file. skip and NoKey was used there to convey two slightly different things (skip being “don’t care about this now, maybe later”, NoKey being “this is definitely not going to do a thing”), that happened to map to the same action: nothing.
That was me.
We support 32 layers, so to distinguish between momentary and toggled layers, we made momentary layers have a higher number, well above our 32-layer limit. I chose 42, because obviously, that’s the right answer to the question. (Just don’t ask me about the question, ok?)
I could have chosen 32 too, would have worked just as well. But since we had plenty of numbers available, I went for the funny one.
Looks like @merlinalready flagged (pun intended) this problem but there seems to be no reply to his comment other than his own which says that those type markers don’t seem to be used anywhere.
I am not whether he means they aren’t used anywhere in the Kaleidoscope code or anywhere in the outside world? If they aren’t used in the outside world then what were they added for in the first place?
Since the reversal of the internal vs consumer codes which you point out effectively render the type markers useless (as they conflict with them) shall we create a PR to totally eradicate them if they aren’t used?
Historical artifacts. Before we had LockLayer and ShiftToLayer, Key_KeymapN and Key_KeymapN_Momentary could be used instead. Key_Keymap0 is exactly the same as LockLayer(0). They are (were?) there to be a friendlier way to switch to a particular layer (then called keymap).) An interesting tidbit is that at that time, we did not have transparency, so you could only have one keymap active at a time, and it completely replaced whatever was active previously.
That’s something I’d love to know as well. A lot of these keycodes were copied out from the USB spec, which sometimes fails to give a meaningful description.