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
2
u/PeterMortensenBlog V Jul 05 '24 edited Dec 03 '25
The key is layer_state_set_user() and layer_state_set_kb().
I think I have seen an example with setting layer-dependent colours in the official documentation, but I couldn't find it.
However, here is a working example, a starting point (paste it into file 'keymap.c'):
It may not be the 100% correct way to do it, but it is a start. For instance, I am not sure if file keymap.c is the official correct location of layer_state_set_user().
Note: The values in the 'case' statements are supposed to be symbolic, like "BASE", "FN", "L2", and "L3", but I am not sure if there is a one-to-one correspondence (should they be 1, 2, 4, 8, 16, etc. instead?). It is somewhat illogical with get_highest_layer(), bitmasks, etc. Or in other words, I do not fully understand it...
Some shortcuts
Other examples
You can also look for/search for examples in other keyboards. Note that most have been left out of the Keychron fork, so do it in the official QMK repository.
References
1
u/PeterMortensenBlog V Jul 05 '24 edited Jul 05 '24
Note: Some changes to the source code do not take effect until the temporary build files are cleared.
That is especially true for changes to the info.json file, but it may also be important for other changes.
For example, from the command line, with the current directory being somewhere inside the (active) QMK folder, do:
It will not delete anything important. The only ill effect is that the compilation takes some time longer.
On my system (with rotating rust), after 'qmk clean',
took 27 seconds. Though it may already had been 'trained' by the previous 'find'/'xargs' action.
2
u/TGPSKI Jul 13 '24
If anyone is following along on this thread, here's my fork + branch with customization for the q0 max:
https://github.com/TGPSKI/qmk_firmware/blob/tgpski-custom-keychron/keyboards/keychron/q0_max/encoder/keymaps/TGPSKI/keymap.c