Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] c2json add layer information #24570

Open
1 of 4 tasks
dawosch opened this issue Nov 6, 2024 · 0 comments
Open
1 of 4 tasks

[Feature Request] c2json add layer information #24570

dawosch opened this issue Nov 6, 2024 · 0 comments

Comments

@dawosch
Copy link

dawosch commented Nov 6, 2024

Feature Request Type

  • Core functionality
  • Add-on hardware support (eg. audio, RGB, OLED screen, etc.)
  • Alteration (enhancement/optimization) of existing feature(s)
  • New behavior

Description

I have a keymap.c file with a few layers.
For example:

...
enum sofle_layers {
    _COLMAK = 0,
    _SYMBOLS,
    _NUMPAD,
};

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    [_COLMAK] = LAYOUT(
        LT(_SETUP, KC_ESC), DE_1, DE_2, DE_3, DE_4, DE_5,                   DE_6, DE_7, DE_8, DE_9, DE_0, KC_BSPC,
        KC_TAB, DE_Q, DE_W, DE_F, DE_P, DE_B,                               DE_J, DE_L, DE_U, DE_Z, DE_SCLN, KC_DEL,
        KC_LSFT, DE_A, DE_R, DE_S, DE_T, DE_G,                              DE_M, DE_N, DE_E, DE_I, DE_O, DE_UDIA,
        KC_LCTL, DE_Y, DE_X, DE_C, DE_D, DE_V, KC_NO,               DF(_NOTED), DE_K, DE_H, DE_COMM, DE_DOT, DE_ODIA, DE_ADIA,
        MO(_FKEYS), MO(_NUMPAD), KC_LGUI, KC_LALT, LT(1,KC_SPC),    KC_ENT, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT),

    [_SYMBOLS] = LAYOUT(
        KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,                           KC_HOME, KC_PGUP, KC_PGDN, KC_END, KC_NO, KC_NO,
        KC_NO, DE_QUOT, KC_LT, KC_GT, DE_DQUO, DE_DOT,                      DE_AMPR, KC_NO, DE_LBRC, DE_RBRC, DE_PERC, KC_NO,
        KC_NO, DE_EXLM, KC_PMNS, KC_PPLS, DE_EQL, KC_NUHS,                  DE_PIPE, DE_COLN, DE_LPRN, DE_RPRN, DE_QUES, KC_NO,
        KC_NO, KC_CIRC, DE_SLSH, DE_ASTR, KC_BSLS, KC_NO, KC_NO,    KC_NO, DE_TILD, DE_DLR, DE_LCBR, DE_RCBR, KC_AT, KC_NO,
                      KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,            KC_NO, KC_NO, KC_NO, KC_NO, KC_NO),

    [_NUMPAD] = LAYOUT(
        KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,                           KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
        KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,                           KC_P7, KC_P8, KC_P9, KC_PMNS, KC_NO, KC_NO,
        KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,                           KC_P4, KC_P5, KC_P6, KC_PPLS, KC_NO, KC_NO,
        KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,            KC_NO, KC_NO, KC_P1, KC_P2, KC_P3, KC_NO, KC_NO,
                      KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,            KC_NO, KC_P0, KC_NO, KC_NO, KC_NO)
}
...

When i convert this file to a json file the result looks like this:

{
    "keyboard": "sofle/rev1",
    "keymap": "default",
    "layers": [
        [
            "LT(_SETUP, KC_ESC)",
            ...
            "MO(_NUMPAD)",
            ...
        ],
        [
            "KC_NO",
            "KC_NO",
            "KC_NO",
            ...
        ],
        [
            "KC_NO",
            "KC_NO",
            "KC_NO",
           ...
        ]
    ],
    "layout": "LAYOUT"
}

When you have a look at the first key definition "LT(_SETUP, KC_ESC)", there is a layer toggle command.
But with the json file only there is no way to detect which layer is behind _SETUP.

Maybe the layers should be an object rather then an array or convert the layer names to its index.

Solution 1:

...
"layers": {
        _COLMAK: [
            "LT(_SETUP, KC_ESC)",
            "KC_NO",
           "MO(_NUMPAD)",
            ...
        ],
       _SETUP: [
            "KC_NO",
            ...
        ],
        _NUMPAD: [
            "KC_NO",
            ...
        ]
    }
}

...

Solution 2:

"layers": [
        [
            "LT(2, KC_ESC)", // 2 = _SETUP
            "DE_1",
            "DE_2",
           "MO(1)", // _NUMPAD
            ...
        ]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant