Funky behavior reusing NumPad plugin for layer coloring

I have a steno layer on my Model 100 that uses a subset of keys, and was hoping to have only those keys light up when the layer is activated, just like the NumPad plugin does. When I’m not on the steno layer, I want the keyboard to resume the LED effect it had before (so using the Color Map LED mode and mapping LED colors to individual keys in Chrysalis doesn’t do the trick).

Looking through the firmware code, I saw:

  // While we hope to improve this in the future, the NumPad plugin
  // needs to be explicitly told which keymap layer is your numpad layer
  NumPad.numPadLayer = NUMPAD;

So I tried changing NUMPAD to 3 (aka my steno layer). It…sort of worked?

I’ve read through the NumPad source code a few times and can’t for the life of me figure out why only those 3 keys are highlighted. Any ideas?

Here’s my Chrysalis configuration for the layer:

Here’s the relevant code:

    if ((k != layer_key) || (k == Key_NoKey) || (k.getFlags() != KEY_FLAGS)) {
    } else {
      ::LEDControl.setCrgbAt(KeyAddr(key_addr), color);

The relevant part is k.getFlags() != KEY_FLAGS. This is not very intuitive, but KEY_FLAGS is zero. What this condition means is “k is not a basic USB HID Keyboard Key”; which means that none of the Steno keys will get highlighted. The blue one, which should be “breathing”, is mapped to LockLayer(3) on an active layer below your Steno layer, so it’s being identified as the key that unlocks the “numpad layer”.

1 Like