diff --git a/builddefs/build_keyboard.mk b/builddefs/build_keyboard.mk index ccd7e50b0517..afad67a76da7 100644 --- a/builddefs/build_keyboard.mk +++ b/builddefs/build_keyboard.mk @@ -186,7 +186,10 @@ endif # Have we found a keymap.json? ifneq ("$(wildcard $(KEYMAP_JSON))", "") ifneq ("$(wildcard $(KEYMAP_C))", "") - $(call WARNING_MESSAGE,Keymap is specified as both keymap.json and keymap.c -- keymap.json file wins.) + # Allow a separately-found keymap.c next to keymap.json -- the keymap.c + # generator will include the other keymap.c in the process, if supplied. + OTHER_KEYMAP_C := $(KEYMAP_C) + OPT_DEFS += -DOTHER_KEYMAP_C=\"$(OTHER_KEYMAP_C)\" endif KEYMAP_PATH := $(KEYMAP_JSON_PATH) diff --git a/data/schemas/keymap.jsonschema b/data/schemas/keymap.jsonschema index 7233e896e940..e967e45c53e4 100644 --- a/data/schemas/keymap.jsonschema +++ b/data/schemas/keymap.jsonschema @@ -72,10 +72,5 @@ "notes": { "type": "string" } - }, - "required": [ - "keyboard", - "layout", - "layers" - ] + } } diff --git a/keyboards/handwired/onekey/info.json b/keyboards/handwired/onekey/info.json index c952758265b1..5cf7c600ee66 100644 --- a/keyboards/handwired/onekey/info.json +++ b/keyboards/handwired/onekey/info.json @@ -7,9 +7,6 @@ "pid": "0x6465", "device_version": "0.0.1" }, - "tapping": { - "term": 500 - }, "diode_direction": "COL2ROW", "features": { "bootmagic": false, diff --git a/keyboards/handwired/onekey/kb2040/config.h b/keyboards/handwired/onekey/kb2040/config.h index e0bf180056ec..e9c4eef273c5 100644 --- a/keyboards/handwired/onekey/kb2040/config.h +++ b/keyboards/handwired/onekey/kb2040/config.h @@ -3,9 +3,6 @@ #pragma once - -#define DEBUG_MATRIX_SCAN_RATE - #define QMK_WAITING_TEST_BUSY_PIN GP8 #define QMK_WAITING_TEST_YIELD_PIN GP9 @@ -18,4 +15,4 @@ #define I2C_DRIVER I2CD0 #define I2C1_SDA_PIN GP12 #define I2C1_SCL_PIN GP13 - + diff --git a/keyboards/handwired/onekey/keymaps/adc/keymap.json b/keyboards/handwired/onekey/keymaps/adc/keymap.json new file mode 100644 index 000000000000..e051d1a30bc2 --- /dev/null +++ b/keyboards/handwired/onekey/keymaps/adc/keymap.json @@ -0,0 +1,10 @@ +{ + "config": { + "features": { + "console": true + }, + "tapping": { + "term": 500 + } + } +} diff --git a/keyboards/handwired/onekey/keymaps/adc/rules.mk b/keyboards/handwired/onekey/keymaps/adc/rules.mk index 8b36baccb0ff..cc588202788d 100644 --- a/keyboards/handwired/onekey/keymaps/adc/rules.mk +++ b/keyboards/handwired/onekey/keymaps/adc/rules.mk @@ -1,3 +1 @@ -CONSOLE_ENABLE = yes - ANALOG_DRIVER_REQUIRED = yes diff --git a/keyboards/handwired/onekey/keymaps/apa102/config.h b/keyboards/handwired/onekey/keymaps/apa102/config.h deleted file mode 100644 index bb618d77fbc3..000000000000 --- a/keyboards/handwired/onekey/keymaps/apa102/config.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#define RGBLIGHT_LED_COUNT 40 -#define APA102_DEFAULT_BRIGHTNESS 5 -#define RGBLIGHT_EFFECT_BREATHING -#define RGBLIGHT_EFFECT_RAINBOW_MOOD -#define RGBLIGHT_EFFECT_RAINBOW_SWIRL -#define RGBLIGHT_EFFECT_SNAKE -#define RGBLIGHT_EFFECT_KNIGHT -#define RGBLIGHT_EFFECT_CHRISTMAS -#define RGBLIGHT_EFFECT_STATIC_GRADIENT -#define RGBLIGHT_EFFECT_RGB_TEST -#define RGBLIGHT_EFFECT_ALTERNATING -#define RGBLIGHT_EFFECT_TWINKLE diff --git a/keyboards/handwired/onekey/keymaps/apa102/keymap.json b/keyboards/handwired/onekey/keymaps/apa102/keymap.json new file mode 100644 index 000000000000..917d39eb33c8 --- /dev/null +++ b/keyboards/handwired/onekey/keymaps/apa102/keymap.json @@ -0,0 +1,29 @@ +{ + "config": { + "features": { + "rgblight": true + }, + "tapping": { + "term": 500 + }, + "rgblight": { + "driver": "apa102", + "led_count": 40, + "default": { + "val": 5 + }, + "animations": { + "breathing": true, + "rainbow_mood": true, + "rainbow_swirl": true, + "snake": true, + "knight": true, + "christmas": true, + "static_gradient": true, + "rgb_test": true, + "alternating": true, + "twinkle": true + } + } + } +} diff --git a/keyboards/handwired/onekey/keymaps/apa102/rules.mk b/keyboards/handwired/onekey/keymaps/apa102/rules.mk deleted file mode 100644 index 5f15fa9e7080..000000000000 --- a/keyboards/handwired/onekey/keymaps/apa102/rules.mk +++ /dev/null @@ -1,2 +0,0 @@ -RGBLIGHT_ENABLE = yes -RGBLIGHT_DRIVER = apa102 diff --git a/keyboards/handwired/onekey/keymaps/backlight/config.h b/keyboards/handwired/onekey/keymaps/backlight/config.h deleted file mode 100644 index af01528b434d..000000000000 --- a/keyboards/handwired/onekey/keymaps/backlight/config.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#define BACKLIGHT_BREATHING diff --git a/keyboards/handwired/onekey/keymaps/backlight/keymap.json b/keyboards/handwired/onekey/keymaps/backlight/keymap.json new file mode 100644 index 000000000000..e8895520cd48 --- /dev/null +++ b/keyboards/handwired/onekey/keymaps/backlight/keymap.json @@ -0,0 +1,14 @@ +{ + "config": { + "features": { + "backlight": true, + "tap_dance": true + }, + "tapping": { + "term": 500 + }, + "backlight": { + "breathing": true + } + } +} diff --git a/keyboards/handwired/onekey/keymaps/backlight/rules.mk b/keyboards/handwired/onekey/keymaps/backlight/rules.mk deleted file mode 100644 index 176e099770cb..000000000000 --- a/keyboards/handwired/onekey/keymaps/backlight/rules.mk +++ /dev/null @@ -1,2 +0,0 @@ -BACKLIGHT_ENABLE = yes -TAP_DANCE_ENABLE = yes diff --git a/keyboards/handwired/onekey/keymaps/console/keymap.json b/keyboards/handwired/onekey/keymaps/console/keymap.json new file mode 100644 index 000000000000..f451f7df04c3 --- /dev/null +++ b/keyboards/handwired/onekey/keymaps/console/keymap.json @@ -0,0 +1,8 @@ +{ + "config": { + "features": { + "console": true, + "debug_matrix_scan_rate": true + } + } +} diff --git a/keyboards/handwired/onekey/keymaps/console/rules.mk b/keyboards/handwired/onekey/keymaps/console/rules.mk deleted file mode 100644 index 7c83606d2d72..000000000000 --- a/keyboards/handwired/onekey/keymaps/console/rules.mk +++ /dev/null @@ -1,2 +0,0 @@ -CONSOLE_ENABLE = yes -DEBUG_MATRIX_SCAN_RATE_ENABLE = yes diff --git a/keyboards/handwired/onekey/keymaps/default/keymap.json b/keyboards/handwired/onekey/keymaps/default/keymap.json new file mode 100644 index 000000000000..5cd219693a30 --- /dev/null +++ b/keyboards/handwired/onekey/keymaps/default/keymap.json @@ -0,0 +1,7 @@ +{ + "config": { + "tapping": { + "term": 500 + } + } +} diff --git a/keyboards/handwired/onekey/rp2040/config.h b/keyboards/handwired/onekey/rp2040/config.h index 0563ebfa5f1f..0030e97b0fe5 100644 --- a/keyboards/handwired/onekey/rp2040/config.h +++ b/keyboards/handwired/onekey/rp2040/config.h @@ -3,9 +3,6 @@ #pragma once - -#define DEBUG_MATRIX_SCAN_RATE - #define QMK_WAITING_TEST_BUSY_PIN GP8 #define QMK_WAITING_TEST_YIELD_PIN GP9 diff --git a/keyboards/handwired/pterodactyl/keymaps/default/keymap.c b/keyboards/handwired/pterodactyl/keymaps/default/keymap.c index 61d650c76b08..c53f6841cef9 100644 --- a/keyboards/handwired/pterodactyl/keymaps/default/keymap.c +++ b/keyboards/handwired/pterodactyl/keymaps/default/keymap.c @@ -54,7 +54,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |------+------+------+------+------+------| |------+------+------+------+------+------| * | | % | ^ | [ | ] | ~ | | & | 1 | 2 | 3 | \ | | * |------+------+------+------+------+------' `------+------+------+------+------+------| - * |QK_BOOT | | | | | | | . | 0 | = | | + * |BtLdr | | | | | | | . | 0 | = | | * `----------------------------------' `----------------------------------' * ,-------------. ,-------------. * | | | | | | diff --git a/keyboards/handwired/pterodactyl/keymaps/default/keymap.json b/keyboards/handwired/pterodactyl/keymaps/default/keymap.json deleted file mode 100644 index 181b32b8c3a3..000000000000 --- a/keyboards/handwired/pterodactyl/keymaps/default/keymap.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "version": 1, - "notes": "", - "author": "Marcus Young", - "keyboard": "handwired/pterodactyl", - "keymap": "default", - "layout": "LAYOUT", - "layers": [ - [ - "KC_EQL", "KC_1", "KC_2", "KC_3", "KC_4", "KC_5", "KC_6", "KC_7", "KC_8", "KC_9", "KC_0", "KC_MINS", - "KC_DEL", "KC_Q", "KC_W", "KC_E", "KC_R", "KC_T", "KC_Y", "KC_U", "KC_I", "KC_O", "KC_P", "KC_BSLS", - "KC_BSPC", "KC_A", "KC_S", "KC_D", "KC_F", "KC_G", "KC_H", "KC_J", "KC_K", "KC_L", "LT(2,KC_SCLN)", "LGUI_T(KC_QUOT)", - "KC_LSFT", "LCTL_T(KC_Z)", "KC_X", "KC_C", "KC_V", "KC_B", "KC_N", "KC_M", "KC_COMM", "KC_DOT", "LCTL_T(KC_SLSH)", "KC_RSFT", - "LT(1,KC_GRV)", "KC_QUOT", "LALT(KC_LSFT)", "KC_LEFT", "KC_RGHT", "KC_UP", "KC_DOWN", "KC_LBRC", "KC_RBRC", "TT(1)", - - "LALT_T(KC_APP)", "KC_LGUI", "KC_RALT", "LCTL_T(KC_ESC)", - "KC_HOME", "KC_PGUP", - "KC_SPC", "KC_BSPC", "KC_END", "KC_PGDN", "KC_TAB", "KC_ENT" - ], - [ - "KC_TRNS", "KC_F1", "KC_F2", "KC_F3", "KC_F4", "KC_F5", "KC_F6", "KC_F7", "KC_F8", "KC_F9", "KC_F10", "KC_F11", - "KC_TRNS", "KC_EXLM", "KC_AT", "KC_LCBR", "KC_RCBR", "KC_PIPE", "KC_UP", "KC_7", "KC_8", "KC_9", "KC_ASTR", "KC_F12", - "KC_TRNS", "KC_HASH", "KC_DLR", "KC_LPRN", "KC_RPRN", "KC_GRV", "KC_DOWN", "KC_4", "KC_5", "KC_6", "KC_PLUS", "KC_TRNS", - "KC_TRNS", "KC_PERC", "KC_CIRC", "KC_LBRC", "KC_RBRC", "KC_TILD", "KC_AMPR", "KC_1", "KC_2", "KC_3", "KC_BSLS", "KC_TRNS", - "QK_BOOT", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_DOT", "KC_0", "KC_EQL", "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_MS_U", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", - "KC_TRNS", "KC_TRNS", "KC_MS_L", "KC_MS_D", "KC_MS_R", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_MPLY", - "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_MPRV", "KC_MNXT", "KC_TRNS", "KC_TRNS", - "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_BTN1", "KC_BTN2", "KC_VOLU", "KC_VOLD", "KC_MUTE", "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_WBAK" - ] - ] -} diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py index 97d9c5032c8f..a05b3641b5ca 100644 --- a/lib/python/qmk/commands.py +++ b/lib/python/qmk/commands.py @@ -55,7 +55,7 @@ def parse_configurator_json(configurator_file): cli.log.error(f'Invalid JSON keymap: {configurator_file} : {e.message}') maybe_exit(1) - keyboard = user_keymap['keyboard'] + keyboard = user_keymap.get('keyboard', None) aliases = keyboard_alias_definitions() while keyboard in aliases: diff --git a/lib/python/qmk/keymap.py b/lib/python/qmk/keymap.py index 97c358788a5e..9dd043c4a898 100644 --- a/lib/python/qmk/keymap.py +++ b/lib/python/qmk/keymap.py @@ -29,38 +29,40 @@ * This file was generated by qmk json2c. You may or may not want to * edit it directly. */ -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { -__KEYMAP_GOES_HERE__ -}; -#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) -const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { +__KEYMAP_GOES_HERE__ __ENCODER_MAP_GOES_HERE__ -}; -#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) - __MACRO_OUTPUT_GOES_HERE__ + +#ifdef OTHER_KEYMAP_C +# include OTHER_KEYMAP_C +#endif // OTHER_KEYMAP_C """ def _generate_keymap_table(keymap_json): - lines = [] + lines = ['const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {'] for layer_num, layer in enumerate(keymap_json['layers']): if layer_num != 0: lines[-1] = lines[-1] + ',' layer = map(_strip_any, layer) layer_keys = ', '.join(layer) lines.append(' [%s] = %s(%s)' % (layer_num, keymap_json['layout'], layer_keys)) + lines.append('};') return lines def _generate_encodermap_table(keymap_json): - lines = [] + lines = [ + '#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)', + 'const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {', + ] for layer_num, layer in enumerate(keymap_json['encoders']): if layer_num != 0: lines[-1] = lines[-1] + ',' encoder_keycode_txt = ', '.join([f'ENCODER_CCW_CW({_strip_any(e["ccw"])}, {_strip_any(e["cw"])})' for e in layer]) lines.append(' [%s] = {%s}' % (layer_num, encoder_keycode_txt)) + lines.extend(['};', '#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)']) return lines @@ -271,8 +273,11 @@ def generate_c(keymap_json): A sequence of strings containing macros to implement for this keyboard. """ new_keymap = DEFAULT_KEYMAP_C - layer_txt = _generate_keymap_table(keymap_json) - keymap = '\n'.join(layer_txt) + + keymap = '' + if 'layers' in keymap_json and keymap_json['layers'] is not None: + layer_txt = _generate_keymap_table(keymap_json) + keymap = '\n'.join(layer_txt) new_keymap = new_keymap.replace('__KEYMAP_GOES_HERE__', keymap) encodermap = '' diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index b10fd8d19d50..dd659fe0f27e 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py @@ -152,17 +152,16 @@ def test_json2c(): * This file was generated by qmk json2c. You may or may not want to * edit it directly. */ + const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = LAYOUT_ortho_1x1(KC_A) }; -#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) -const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { - -}; -#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) +#ifdef OTHER_KEYMAP_C +# include OTHER_KEYMAP_C +#endif // OTHER_KEYMAP_C """ @@ -190,28 +189,21 @@ def test_json2c_stdin(): * This file was generated by qmk json2c. You may or may not want to * edit it directly. */ + const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = LAYOUT_ortho_1x1(KC_A) }; -#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) -const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { - -}; -#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) +#ifdef OTHER_KEYMAP_C +# include OTHER_KEYMAP_C +#endif // OTHER_KEYMAP_C """ -def test_json2c_wrong_json(): - result = check_subcommand('json2c', 'keyboards/handwired/pytest/info.json') - check_returncode(result, [1]) - assert 'Invalid JSON keymap' in result.stdout - - def test_json2c_no_json(): result = check_subcommand('json2c', 'keyboards/handwired/pytest/basic/keymaps/default/keymap.c') check_returncode(result, [1]) diff --git a/lib/python/qmk/tests/test_qmk_keymap.py b/lib/python/qmk/tests/test_qmk_keymap.py index 7482848eff10..80cc679b007c 100644 --- a/lib/python/qmk/tests/test_qmk_keymap.py +++ b/lib/python/qmk/tests/test_qmk_keymap.py @@ -20,17 +20,16 @@ def test_generate_c_pytest_basic(): * This file was generated by qmk json2c. You may or may not want to * edit it directly. */ + const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = LAYOUT(KC_A) }; -#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) -const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { - -}; -#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) +#ifdef OTHER_KEYMAP_C +# include OTHER_KEYMAP_C +#endif // OTHER_KEYMAP_C """