From 699fde6b738a45b4b831bdfd6ba757d8f671509d Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Fri, 2 Dec 2022 15:57:46 -0800 Subject: [PATCH 1/6] [Bug] Prevent dynamic keymaps from processing layers that don't exist --- quantum/action_layer.h | 1 + 1 file changed, 1 insertion(+) diff --git a/quantum/action_layer.h b/quantum/action_layer.h index bd1085a70fcc..3fe272652999 100644 --- a/quantum/action_layer.h +++ b/quantum/action_layer.h @@ -25,6 +25,7 @@ along with this program. If not, see . # ifndef DYNAMIC_KEYMAP_LAYER_COUNT # define DYNAMIC_KEYMAP_LAYER_COUNT 4 # endif +# define MAX_LAYER DYNAMIC_KEYMAP_LAYER_COUNT # if DYNAMIC_KEYMAP_LAYER_COUNT <= 8 # ifndef LAYER_STATE_8BIT # define LAYER_STATE_8BIT From 42b5ad5cc44f89c79a3936f896d4350ea39bee0e Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Fri, 2 Dec 2022 18:36:06 -0800 Subject: [PATCH 2/6] fix orthocode via layout --- keyboards/orthocode/keymaps/via/keymap.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/keyboards/orthocode/keymaps/via/keymap.c b/keyboards/orthocode/keymaps/via/keymap.c index 177f5ad1902b..1666fbc7e96a 100644 --- a/keyboards/orthocode/keymaps/via/keymap.c +++ b/keyboards/orthocode/keymaps/via/keymap.c @@ -73,20 +73,5 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* ctrl win alt fn th1 th2 th3 th4 fn alt ctrl left down right */ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS - ), - [4] = LAYOUT( - /* Rotary */ - KC_TRNS, - /* esc 1 2 3 4 5 6 7 8 9 0 - = home */ - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - /* tab Q W E R T Y U I O P \ delete end */ - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - /* caps A S D F G H J K L ; ' enter */ - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_RBRC, KC_TRNS, KC_TRNS, KC_TRNS, - /* shift Z X C V B N M , . / up */ - KC_LSFT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - /* ctrl win alt fn th1 th2 th3 th4 fn alt ctrl left down right */ - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS - ) }; From 61d0314cbe7eeab9c284216a734f131a518f8f9d Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Sat, 3 Dec 2022 11:35:08 -0800 Subject: [PATCH 3/6] Fix via keymaps that were unknonwingly broken --- keyboards/boardsource/4x12/keymaps/via/keymap.c | 6 ------ .../canary/canary60rgb/keymaps/via/config.h | 1 + .../dm9records/tartan/keymaps/via/keymap.c | 8 -------- keyboards/dztech/dz60rgb/keymaps/via/keymap.c | 7 ------- keyboards/edc40/keymaps/via/keymap.c | 14 ++++---------- keyboards/gray_studio/hb85/keymaps/via/keymap.c | 11 +---------- keyboards/keebio/sinc/keymaps/via/keymap.c | 17 ++++------------- .../rebound/rev4/keymaps/via/config.h | 6 ++++++ 8 files changed, 16 insertions(+), 54 deletions(-) create mode 100644 keyboards/montsinger/rebound/rev4/keymaps/via/config.h diff --git a/keyboards/boardsource/4x12/keymaps/via/keymap.c b/keyboards/boardsource/4x12/keymaps/via/keymap.c index b6e26fbeca12..6a9621e50831 100644 --- a/keyboards/boardsource/4x12/keymaps/via/keymap.c +++ b/keyboards/boardsource/4x12/keymaps/via/keymap.c @@ -29,11 +29,5 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, KC_PGUP, KC_PGDN, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY - ), - [4] = LAYOUT_ortho_4x12( - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ) }; diff --git a/keyboards/canary/canary60rgb/keymaps/via/config.h b/keyboards/canary/canary60rgb/keymaps/via/config.h index 452510f79b12..d3256bff33da 100644 --- a/keyboards/canary/canary60rgb/keymaps/via/config.h +++ b/keyboards/canary/canary60rgb/keymaps/via/config.h @@ -17,3 +17,4 @@ #pragma once #define DISABLE_RGB_MATRIX_PIXEL_FLOW +#define DYNAMIC_KEYMAP_LAYER_COUNT 5 diff --git a/keyboards/dm9records/tartan/keymaps/via/keymap.c b/keyboards/dm9records/tartan/keymaps/via/keymap.c index e98b8385c9a8..6ea5c328a0ba 100644 --- a/keyboards/dm9records/tartan/keymaps/via/keymap.c +++ b/keyboards/dm9records/tartan/keymaps/via/keymap.c @@ -19,7 +19,6 @@ enum tartan_via_layers { _QWERTY, _FN, - _L2, _L3, _L4, _L5, @@ -42,13 +41,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, _______, _______, _______, _______, _______, KC_END, KC_PGDN, KC_DOWN, _______, _______, _______, _______, _______, _______, _______, _______, _______ ), - [_L2] = LAYOUT_60_ansi( - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______ - ), [_L3] = LAYOUT_60_ansi( _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, diff --git a/keyboards/dztech/dz60rgb/keymaps/via/keymap.c b/keyboards/dztech/dz60rgb/keymaps/via/keymap.c index da128eec4f26..b00f4094f1d8 100644 --- a/keyboards/dztech/dz60rgb/keymaps/via/keymap.c +++ b/keyboards/dztech/dz60rgb/keymaps/via/keymap.c @@ -28,12 +28,5 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, KC_P4, KC_P5, KC_P6, _______, _______, _______, _______, KC_P4, KC_P5, KC_P6, _______, KC_PENT, _______, KC_P1, KC_P2, KC_P3, _______, _______, _______, _______, KC_P1, KC_P2, KC_P3, _______, _______, _______, KC_P0, KC_PDOT, KC_PENT, KC_P0, KC_PDOT, _______, _______, _______ - ), - [4] = LAYOUT( - QK_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, - KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, - CTL_T(KC_CAPS), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, - KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, RSFT_T(KC_SLSH), KC_UP, LT(2, KC_DEL), - KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RALT, TO(0), KC_LEFT, KC_DOWN, KC_RGHT ) }; diff --git a/keyboards/edc40/keymaps/via/keymap.c b/keyboards/edc40/keymaps/via/keymap.c index 022970cd0c83..a5f6bc5b3656 100644 --- a/keyboards/edc40/keymaps/via/keymap.c +++ b/keyboards/edc40/keymaps/via/keymap.c @@ -16,7 +16,7 @@ #include QMK_KEYBOARD_H const uint16_t PROGMEM keymaps [][MATRIX_ROWS][MATRIX_COLS] = { - + /* Default Layer*/ [0] = LAYOUT( KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, @@ -25,7 +25,7 @@ KC_LCTL, KC_LGUI, KC_SPC, KC_RALT, KC_RCTL ), /* Num Layer */ - [1] = LAYOUT( + [1] = LAYOUT( KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, @@ -44,12 +44,6 @@ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS - ), - /* Random Layer */ - [4] = LAYOUT( - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ) -}; \ No newline at end of file +}; + diff --git a/keyboards/gray_studio/hb85/keymaps/via/keymap.c b/keyboards/gray_studio/hb85/keymaps/via/keymap.c index 5e1693a5166c..d64157719943 100644 --- a/keyboards/gray_studio/hb85/keymaps/via/keymap.c +++ b/keyboards/gray_studio/hb85/keymaps/via/keymap.c @@ -43,14 +43,5 @@ _______, _______, _______, _______, _______, _______, _______, _______, ____ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ - ), - - [3] = LAYOUT_all( - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, -_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, -_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, -_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, -_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ - ), + ) }; diff --git a/keyboards/keebio/sinc/keymaps/via/keymap.c b/keyboards/keebio/sinc/keymaps/via/keymap.c index 8101c82bfb5c..fe44ef04f2ef 100644 --- a/keyboards/keebio/sinc/keymaps/via/keymap.c +++ b/keyboards/keebio/sinc/keymaps/via/keymap.c @@ -26,23 +26,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ - ), - - [3] = LAYOUT_all( - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ) + }; #ifdef ENCODER_MAP_ENABLE const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = { - [0] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD), ENCODER_CCW_CW(KC_PGUP, KC_PGDN) }, - [1] = { ENCODER_CCW_CW(RGB_MOD, RGB_RMOD), ENCODER_CCW_CW(KC_MNXT, KC_MPRV) }, - [2] = { ENCODER_CCW_CW(_______, _______), ENCODER_CCW_CW(_______, _______) }, - [3] = { ENCODER_CCW_CW(_______, _______), ENCODER_CCW_CW(_______, _______) }, + [0] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD), ENCODER_CCW_CW(KC_PGUP, KC_PGDN) }, + [1] = { ENCODER_CCW_CW(RGB_MOD, RGB_RMOD), ENCODER_CCW_CW(KC_MNXT, KC_MPRV) }, + [2] = { ENCODER_CCW_CW(_______, _______), ENCODER_CCW_CW(_______, _______) }, }; #endif diff --git a/keyboards/montsinger/rebound/rev4/keymaps/via/config.h b/keyboards/montsinger/rebound/rev4/keymaps/via/config.h new file mode 100644 index 000000000000..7460bef8406e --- /dev/null +++ b/keyboards/montsinger/rebound/rev4/keymaps/via/config.h @@ -0,0 +1,6 @@ +// Copyright 2020 Ross Montsinger +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#define DYNAMIC_KEYMAP_LAYER_COUNT 6 From bb373c8d7d0323b88b9a7ebd18c4cf65cb72b12d Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Sat, 3 Dec 2022 11:41:06 -0800 Subject: [PATCH 4/6] Max keymap_introspection's assert more accurate when via/xap is enabled --- quantum/keymap_introspection.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/quantum/keymap_introspection.c b/quantum/keymap_introspection.c index 93aab82fcccf..29f73d9354ad 100644 --- a/quantum/keymap_introspection.c +++ b/quantum/keymap_introspection.c @@ -17,7 +17,12 @@ uint8_t keymap_layer_count(void) { return NUM_KEYMAP_LAYERS; } +#ifdef DYNAMIC_KEYMAP_ENABLE +_Static_assert(NUM_KEYMAP_LAYERS <= MAX_LAYER, "Number of keymap layers exceeds maximum set by MAX_LAYER, check the configured DYNAMIC_KEYMAP_LAYER_COUNT"); +#else _Static_assert(NUM_KEYMAP_LAYERS <= MAX_LAYER, "Number of keymap layers exceeds maximum set by LAYER_STATE_(8|16|32)BIT"); +#endif + uint16_t keycode_at_keymap_location_raw(uint8_t layer_num, uint8_t row, uint8_t column) { if (layer_num < NUM_KEYMAP_LAYERS && row < MATRIX_ROWS && column < MATRIX_COLS) { From c4243105e3a126a308c9b70ad335c1680191eb1c Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Sat, 3 Dec 2022 12:02:58 -0800 Subject: [PATCH 5/6] Appease lint --- quantum/keymap_introspection.c | 1 - 1 file changed, 1 deletion(-) diff --git a/quantum/keymap_introspection.c b/quantum/keymap_introspection.c index 29f73d9354ad..ba55efaac306 100644 --- a/quantum/keymap_introspection.c +++ b/quantum/keymap_introspection.c @@ -23,7 +23,6 @@ _Static_assert(NUM_KEYMAP_LAYERS <= MAX_LAYER, "Number of keymap layers exceeds _Static_assert(NUM_KEYMAP_LAYERS <= MAX_LAYER, "Number of keymap layers exceeds maximum set by LAYER_STATE_(8|16|32)BIT"); #endif - uint16_t keycode_at_keymap_location_raw(uint8_t layer_num, uint8_t row, uint8_t column) { if (layer_num < NUM_KEYMAP_LAYERS && row < MATRIX_ROWS && column < MATRIX_COLS) { return pgm_read_word(&keymaps[layer_num][row][column]); From 89da6669a1bcb9be83f692c4f38a431d99340168 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Sat, 3 Dec 2022 13:53:25 -0800 Subject: [PATCH 6/6] simplify dynamic keymap error --- quantum/keymap_introspection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/keymap_introspection.c b/quantum/keymap_introspection.c index ba55efaac306..1529ab9fe2d7 100644 --- a/quantum/keymap_introspection.c +++ b/quantum/keymap_introspection.c @@ -18,7 +18,7 @@ uint8_t keymap_layer_count(void) { } #ifdef DYNAMIC_KEYMAP_ENABLE -_Static_assert(NUM_KEYMAP_LAYERS <= MAX_LAYER, "Number of keymap layers exceeds maximum set by MAX_LAYER, check the configured DYNAMIC_KEYMAP_LAYER_COUNT"); +_Static_assert(NUM_KEYMAP_LAYERS <= MAX_LAYER, "Number of keymap layers exceeds maximum set by DYNAMIC_KEYMAP_LAYER_COUNT"); #else _Static_assert(NUM_KEYMAP_LAYERS <= MAX_LAYER, "Number of keymap layers exceeds maximum set by LAYER_STATE_(8|16|32)BIT"); #endif