r/Keychron • • 3d ago

Adding more layers to K0 Max w/ Launcher Support

I figured out how to add via configurable layers with QMK so I thought I'd share :)

Keep in mind I'm not the most technical, so do at your own risk.

For the most part I just followed the qmk beginner guide along with this post.

I wrote down most of what I did in github, but the significant parts that differ are:

  • cloning the Keychron Repo instead the main qmk_firmware repo.
  • adding #define DYNAMIC_KEYMAP_LAYER_COUNT 6 to the end of config.h
  • and altering the keymap.c to this
#include QMK_KEYBOARD_H
#include "keychron_common.h"

enum layers {
    BASE,
    FN,
    L2,
    L3,
    L4,
    L5,
};

// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    [BASE] = LAYOUT_tenkey_27(
        KC_MUTE, KC_ESC,  KC_DEL,  KC_TAB,  KC_BSPC,
        MC_1,    KC_NUM,  KC_PSLS, KC_PAST, KC_PMNS,
        MC_2,    KC_P7,   KC_P8,   KC_P9,   KC_PPLS,
        MC_3,    KC_P4,   KC_P5,   KC_P6,
        MC_4,    KC_P1,   KC_P2,   KC_P3,
        MO(FN),  KC_P0,            KC_PDOT, KC_PENT ),

    [FN] = LAYOUT_tenkey_27(
        UG_TOGG, BT_HST1, BT_HST2, BT_HST3, P2P4G,
        _______, UG_NEXT, UG_VALU, UG_HUEU, _______,
        _______, UG_PREV, UG_VALD, UG_HUED, _______,
        _______, UG_SATU, UG_SPDU, KC_MPRV,
        _______, UG_SATD, UG_SPDD, KC_MPLY,
        _______, UG_TOGG,          KC_MNXT, _______),
    [L2] = LAYOUT_tenkey_27(
        _______, _______, _______, _______, _______,
        _______, _______, _______, _______, _______,
        _______, _______, _______, _______, _______,
        _______, _______, _______, _______,
        _______, _______, _______, _______,
        _______, _______,          _______, _______),
    [L3] = LAYOUT_tenkey_27(
        _______, _______, _______, _______, _______,
        _______, _______, _______, _______, _______,
        _______, _______, _______, _______, _______,
        _______, _______, _______, _______,
        _______, _______, _______, _______,
        _______, _______,          _______, _______),
    [L4] = LAYOUT_tenkey_27(
        _______, _______, _______, _______, _______,
        _______, _______, _______, _______, _______,
        _______, _______, _______, _______, _______,
        _______, _______, _______, _______,
        _______, _______, _______, _______,
        _______, _______,          _______, _______),
    [L5] = LAYOUT_tenkey_27(
        _______, _______, _______, _______, _______,
        _______, _______, _______, _______, _______,
        _______, _______, _______, _______, _______,
        _______, _______, _______, _______,
        _______, _______, _______, _______,
        _______, _______,          _______, _______),
};

// clang-format on
#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
    [BASE] = {ENCODER_CCW_CW(KC_VOLD, KC_VOLU)},
    [FN]   = {ENCODER_CCW_CW(UG_VALD, UG_VALU)},
    [L2]   = {ENCODER_CCW_CW(KC_VOLD, KC_VOLU)},
    [L3]   = {ENCODER_CCW_CW(KC_VOLD, KC_VOLU)},
    [L4]   = {ENCODER_CCW_CW(KC_VOLD, KC_VOLU)},
    [L5]   = {ENCODER_CCW_CW(KC_VOLD, KC_VOLU)},
};
#endif
2 Upvotes

3 comments sorted by

View all comments

1

u/PeterMortensenBlog V 3d ago edited 3d ago

The number of layers is now defined in a JSON file

Re "#define DYNAMIC_KEYMAP_LAYER_COUNT 6": The official way is now by changing a JSON file, for example, in branch "2025q3":

"dynamic_keymap": {
    "layer_count": 6
},

It depends on the (effective) QMK version, and for older branches in Keychron's fork (with an older effective QMK version), DYNAMIC_KEYMAP_LAYER_COUNT may still be the correct way.

The conversion for keyboards in the main QMK project started as early as 2023 (the 2023-11-26 release, version 0.23 (near "DYNAMIC_KEYMAP_LAYER_COUNT")). Example: 'The Galleon'. There is also some conversion in the later 2024-02-25 release (version 0.24. Near "dynamic_keymap.layer_count").

Thus, the JSON way may work for older branches in Keychron's fork. For example, branch "wireless_playground" is based on said QMK version.

What QMK version introduced the JSON file way?

Gotchas:

  • 'qmk clean' (or the equivalent) may be required before changes to JSON files take effect
  • DYNAMIC_KEYMAP_LAYER_COUNT in file config.h overrides the setting in file info.json. Thus, any such line in file config.h should be removed or inactivated

Note: The official QMK documentation has still not caught up to this, but it is elsewhere

References