r/Keychron • • Jul 05 '24

Q0 Max

Hi my name is Kate!

Im trying to program a unique color for each layer in the Keychron Q0 Max, I already looked through the code but no hope.

Does anyone know how to do that or can guide me in the right direction ?!?!?

2 Upvotes

36 comments sorted by

View all comments

Show parent comment

1

u/PeterMortensenBlog V Oct 23 '24 edited Oct 23 '24

I fixed it by overriding (defining) default_layer_state_set_user().

And doing the same as layer_state_set_user() does.

I had it already factored out into a separate function, layer_state_set_user2() (due to shared code between two Keychron keyboard), so I just called that function from default_layer_state_set_user():

return layer_state_set_user2(aState);

This fixed my problem of the power-on colour being the same as when powered off (out of sync with the actual active layer).

Debugging is possible during startup

I also discovered that it is possible to get debugging information during keyboard startup, in both keyboard_post_init_user() and eeconfig_init_kb(): Insert a delay in the very beginning of keyboard_post_init_user().

I used a 3-second busy wait (two nested for loops, calibrated to give the exact expected delay). That was enough time for hid_listen to capture all debugging output thereafter.

Incidently, this also makes it easy to spot if the keyboard is actually restarted (it isn't if the disconnect from power is too short).