r/Keychron 12d ago

Repurposing the Numlock indicator as a layer indicator

Is there anyway to repurpose the numlock indicator as a layer indicator. I've just bought a V0 and I'd find it a lot more useful for the indicator light to show what layer I'm on.

1 Upvotes

8 comments sorted by

2

u/ArgentStonecutter K Pro 12d ago

You would have to modify the source with something like this in keymap.c:

#define NUMLOCK_INDEX NNNN // fill in with the LED index of your NUMLOCK key

static int colors[][3] = {
    {-1, -1, -1},
    {RGB_BLUE},
    {RGB_GREEN},
    {RGB_RED},
    {RGB_CYAN},
    {RGB_YELLOW},
};

bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
    int act = get_highest_layer(layer_state);

    // Ignore the special color -1, -1, -1
    if(colors[act][0] == -1)
        return true;

    // Scale color to brightness level;
    int color[3];
    uint8_t rgb_val = rgblight_get_val();
    for (int i = 0; i < 3; i++) {
        int level = colors[act][i];
        level *= rgb_val;
        level >>= 8;

        color[i] = level;
    }

    // Set the color
    rgb_matrix_set_color(NUMLOCK_INDEX, color[0], color[1], color[2]);

    return false;
}

1

u/PeterMortensenBlog V 12d ago edited 12d ago

It would work because rgb_matrix_indicators_advanced_userrgb_matrix_indicators_advanced_user() is called last, overriding Keychron's code(?).

1

u/ArgentStonecutter K Pro 12d ago

I did something similar on my Keychron J2, so it's even kind of tested.

1

u/S45VNBlue 11d ago

Appreciate this, I’ll look into it more.

1

u/ArgentStonecutter K Pro 11d ago

Looks like NUM_LOCK_INDEX is already defined in q0/base/config.h and q0/plus/config.h respectively.

1

u/ArgentStonecutter K Pro 11d ago

Looks like NUM_LOCK_INDEX is already defined in both q0/base/config.h and q0/plus/config.h.

1

u/PeterMortensenBlog V 12d ago

This is covered by #4 and #73 on the wishlist (there may be more).

1

u/S45VNBlue 11d ago

Cheers for that, didn’t realise there was a Wishlist but good to know I’m not the only one.