From c15431b80ae985eba9eb17169cf86e8b26e854a8 Mon Sep 17 00:00:00 2001 From: Zach White Date: Thu, 24 Jun 2021 21:43:17 -0700 Subject: [PATCH 01/37] add some split data to info.json --- data/mappings/info_config.json | 12 +++++++++--- data/mappings/info_rules.json | 4 +++- data/schemas/keyboard.jsonschema | 22 ++++++++++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/data/mappings/info_config.json b/data/mappings/info_config.json index b949b13320d3..143408a31101 100644 --- a/data/mappings/info_config.json +++ b/data/mappings/info_config.json @@ -3,14 +3,15 @@ { # Format: # : {"info_key": , ["value_type": ], ["to_json": ], ["to_c": ]} - # value_type: one of "array", "array.int", "int", "hex", "list", "mapping" + # value_type: one of "array", "array.int", "bool", "int", "hex", "list", "mapping" # to_json: Default `true`. Set to `false` to exclude this mapping from info.json # to_c: Default `true`. Set to `false` to exclude this mapping from config.h # warn_duplicate: Default `true`. Set to `false` to turn off warning when a value exists in both places - "DEBOUNCE": {"info_key": "debounce", "value_type": "int"} + "DEBOUNCE": {"info_key": "debounce", "value_type": "int"}, "DEVICE_VER": {"info_key": "usb.device_ver", "value_type": "hex"}, "DESCRIPTION": {"info_key": "keyboard_folder", "to_json": false}, "DIODE_DIRECTION": {"info_key": "diode_direction"}, + "EE_HANDS": {"info_key": "split.ee_hands"}, "LAYOUTS": {"info_key": "layout_aliases", "value_type": "mapping"}, "LED_CAPS_LOCK_PIN": {"info_key": "indicators.caps_lock"}, "LED_NUM_LOCK_PIN": {"info_key": "indicators.num_lock"}, @@ -42,5 +43,10 @@ "QMK_ESC_OUTPUT": {"info_key": "qmk_lufa_bootloader.esc_output"}, "QMK_ESC_INPUT": {"info_key": "qmk_lufa_bootloader.esc_input"}, "QMK_LED": {"info_key": "qmk_lufa_bootloader.led"}, - "QMK_SPEAKER": {"info_key": "qmk_lufa_bootloader.speaker"} + "QMK_SPEAKER": {"info_key": "qmk_lufa_bootloader.speaker"}, + "SPLIT_HAND_PIN": {"info_key": "split.hand_pin"}, + "SPLIT_HAND_MATRIX_GRID": {"info_key": "split.hand_matrix_grid", "value_type": "array"}, + "SPLIT_TRANSPORT_MIRROR": {"info_key": "split.mirror", "value_type": "bool"}, + "SOFT_SERIAL_PIN": {"info_key": "split.soft_serial_pin"}, + "SOFT_SERIAL_SPEED": {"info_key": "split.soft_serial_speed"} } diff --git a/data/mappings/info_rules.json b/data/mappings/info_rules.json index 97f772c4d5b5..1838e80137a1 100644 --- a/data/mappings/info_rules.json +++ b/data/mappings/info_rules.json @@ -3,7 +3,7 @@ { # Format: # : {"info_key": , ["value_type": ], ["to_json": ], ["to_c": ]} - # value_type: one of "array", "array.int", "int", "list", "hex", "mapping" + # value_type: one of "array", "array.int", "bool", "int", "list", "hex", "mapping" # to_json: Default `true`. Set to `false` to exclude this mapping from info.json # to_c: Default `true`. Set to `false` to exclude this mapping from rules.mk # warn_duplicate: Default `true`. Set to `false` to turn off warning when a value exists in both places @@ -12,4 +12,6 @@ "LAYOUTS": {"info_key": "community_layouts", "value_type": "list"}, "LED_MATRIX_DRIVER": {"info_key": "led_matrix.driver"}, "MCU": {"info_key": "processor", "warn_duplicate": false}, + "SPLIT_KEYBOARD": {"info_key": "split.enabled", "value_type": "bool"}, + "SPLIT_TRANSPORT": {"info_key": "split.transport", "value_type": "str"} } diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 3a3fa4b7385f..581ffd0a3224 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -128,6 +128,28 @@ } } }, + "split": { + "type": "object", + "additionalProperties": false, + "properties": { + "ee_hands": {"type": "boolean"}, + "enabled": {"type": "boolean"}, + "hand_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, + "hand_matrix_grid": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, + "mirror": {"type": "boolean"}, + "transport": { + "type": "string", + "enum": ["custom", "mirror", "serial", "I2C"] + }, + "soft_serial_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, + "soft_serial_speed": { + "type": "number", + "min": 0, + "max": 5, + "multipleOf": 1 + } + } + }, "usb": { "type": "object", "additionalProperties": false, From 06bbd0749e1a8f95be24cebb27175c6c3b50455e Mon Sep 17 00:00:00 2001 From: Zach White Date: Thu, 24 Jun 2021 21:46:40 -0700 Subject: [PATCH 02/37] add tags --- data/schemas/keyboard.jsonschema | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 581ffd0a3224..47fd22b8707a 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -150,6 +150,10 @@ } } }, + "tags": { + "type": "array", + "items": {"type": "string"} + }, "usb": { "type": "object", "additionalProperties": false, From e6ae9834797e8aa545a54705dec9e09a88ea08d2 Mon Sep 17 00:00:00 2001 From: Zach White Date: Thu, 24 Jun 2021 23:27:56 -0700 Subject: [PATCH 03/37] add half of config_options.md to info.json --- data/mappings/info_config.json | 33 +++++++++- data/schemas/keyboard.jsonschema | 82 +++++++++++++++++++++++- lib/python/qmk/cli/generate/info_json.py | 2 +- lib/python/qmk/info.py | 19 ++++++ lib/python/qmk/json_schema.py | 3 + 5 files changed, 134 insertions(+), 5 deletions(-) diff --git a/data/mappings/info_config.json b/data/mappings/info_config.json index 143408a31101..cfb952dd18cc 100644 --- a/data/mappings/info_config.json +++ b/data/mappings/info_config.json @@ -7,16 +7,36 @@ # to_json: Default `true`. Set to `false` to exclude this mapping from info.json # to_c: Default `true`. Set to `false` to exclude this mapping from config.h # warn_duplicate: Default `true`. Set to `false` to turn off warning when a value exists in both places + "AUDIO_VOICES": {"info_key": "matrix_pins.ghost", "value_type": "bool"}, + "BACKLIGHT_BREATHING": {"info_key": "backlight.breathing", "value_type": "bool"}, + "BREATHING_PERIOD": {"info_key": "backlight.breathing_period", "value_type": "int"}, + "BACKLIGHT_PIN": {"info_key": "backlight.pin"}, + "COMBO_COUNT": {"info_key": "combo.count", "value_type": "int"}, + "COMBO_TERM": {"info_key": "combo.term", "value_type": "int"}, "DEBOUNCE": {"info_key": "debounce", "value_type": "int"}, "DEVICE_VER": {"info_key": "usb.device_ver", "value_type": "hex"}, "DESCRIPTION": {"info_key": "keyboard_folder", "to_json": false}, "DIODE_DIRECTION": {"info_key": "diode_direction"}, "EE_HANDS": {"info_key": "split.ee_hands"}, + "FORCE_NKRO": {"info_key": "features.force_nkro", "value_type": "bool"}, + "IGNORE_MOD_TAP_INTERRUPT": {"info_key": "tapping.ignore_mod_tap_interrupt", "value_type": "bool"}, + "IGNORE_MOD_TAP_INTERRUPT_PER_KEY": {"info_key": "tapping.ignore_mod_tap_interrupt_per_key", "value_type": "bool"}, "LAYOUTS": {"info_key": "layout_aliases", "value_type": "mapping"}, + "LEADER_PER_KEY_TIMING": {"info_key": "leader_key.timing", "value_type": "bool"}, + "LEADER_KEY_STRICT_KEY_PROCESSING": {"info_key": "leader_key.strict_processing", "value_type": "bool"}, + "LEADER_TIMEOUT": {"info_key": "leader_key.timeout", "value_type": "int"}, "LED_CAPS_LOCK_PIN": {"info_key": "indicators.caps_lock"}, "LED_NUM_LOCK_PIN": {"info_key": "indicators.num_lock"}, "LED_SCROLL_LOCK_PIN": {"info_key": "indicators.scroll_lock"}, "MANUFACTURER": {"info_key": "manufacturer"}, + "MATRIX_HAS_GHOST": {"info_key": "matrix_pins.ghost", "value_type": "bool"}, + "MATRIX_IO_DELAY": {"info_key": "matrix_pins.io_delay", "value_type": "int"}, + "ONESHOT_TIMEOUT": {"info_key": "oneshot.timeout", "value_type": "int"}, + "ONESHOT_TAP_TOGGLE": {"info_key": "oneshot.tap_toggle", "value_type": "int"}, + "PERMISSIVE_HOLD": {"info_key": "tapping.permissive_hold", "value_type": "bool"}, + "PERMISSIVE_HOLD_PER_KEY": {"info_key": "tapping.permissive_hold_per_key", "value_type": "bool"}, + "RETRO_TAPPING": {"info_key": "tapping.retro", "value_type": "bool"}, + "RETRO_TAPPING_PER_KEY": {"info_key": "tapping.retro_per_key", "value_type": "bool"}, "RGB_DI_PIN": {"info_key": "rgblight.pin"}, "RGBLED_NUM": {"info_key": "rgblight.led_count", "value_type": "int"}, "RGBLED_SPLIT": {"info_key": "rgblight.split_count", "value_type": "array.int"}, @@ -42,11 +62,22 @@ "VENDOR_ID": {"info_key": "usb.vid", "value_type": "hex"}, "QMK_ESC_OUTPUT": {"info_key": "qmk_lufa_bootloader.esc_output"}, "QMK_ESC_INPUT": {"info_key": "qmk_lufa_bootloader.esc_input"}, + "QMK_KEYS_PER_SCAN": {"info_key": "qmk.keys_per_scan", "value_type": "int"}, "QMK_LED": {"info_key": "qmk_lufa_bootloader.led"}, "QMK_SPEAKER": {"info_key": "qmk_lufa_bootloader.speaker"}, "SPLIT_HAND_PIN": {"info_key": "split.hand_pin"}, "SPLIT_HAND_MATRIX_GRID": {"info_key": "split.hand_matrix_grid", "value_type": "array"}, "SPLIT_TRANSPORT_MIRROR": {"info_key": "split.mirror", "value_type": "bool"}, "SOFT_SERIAL_PIN": {"info_key": "split.soft_serial_pin"}, - "SOFT_SERIAL_SPEED": {"info_key": "split.soft_serial_speed"} + "SOFT_SERIAL_SPEED": {"info_key": "split.soft_serial_speed"}, + "TAP_CODE_DELAY": {"info_key": "qmk.tap_keycode_delay", "value_type": "int"}, + "TAP_HOLD_CAPS_DELAY": {"info_key": "qmk.tap_capslock_delay", "value_type": "int"}, + "TAPPING_FORCE_HOLD": {"info_key": "tapping.force_hold", "value_type": "bool"}, + "TAPPING_FORCE_HOLD_PER_KEY": {"info_key": "tapping.force_hold_per_key", "value_type": "bool"}, + "TAPPING_TERM": {"info_key": "tapping.term", "value_type": "int"}, + "TAPPING_TERM_PER_KEY": {"info_key": "tapping.term_per_key", "value_type": "bool"}, + "TAPPING_TOGGLE": {"info_key": "tapping.toggle", "value_type": "int"}, + "USB_MAX_POWER_CONSUMPTION": {"info_key": "usb.max_power", "value_type": "int"}, + "USB_POLLING_INTERVAL_MS": {"info_key": "usb.polling_interval", "value_type": "int"}, + "USB_SUSPEND_WAKEUP_DELAY": {"info_key": "usb.suspend_wakeup_delay", "value_type": "int"}, } diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 47fd22b8707a..baa6705600d1 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -15,6 +15,29 @@ "type": "string", "enum": ["cortex-m0", "cortex-m0plus", "cortex-m3", "cortex-m4", "MKL26Z64", "MK20DX128", "MK20DX256", "MK66F18", "STM32F042", "STM32F072", "STM32F103", "STM32F303", "STM32F401", "STM32F407", "STM32F411", "STM32F446", "STM32G431", "STM32G474", "STM32L412", "STM32L422", "STM32L433", "STM32L443", "atmega16u2", "atmega32u2", "atmega16u4", "atmega32u4", "at90usb162", "at90usb646", "at90usb647", "at90usb1286", "at90usb1287", "atmega32a", "atmega328p", "atmega328", "attiny85", "unknown"] }, + "audio": { + "type": "object", + "additionalProperties": false, + "properties": { + "pins": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, + "voices": {"type": "boolean"} + } + }, + "backlight": { + "type": "object", + "additionalProperties": false, + "properties": { + "breathing": {"type": "boolean"}, + "breathing_period": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, + "levels": { + "type": "number", + "min": 1, + "max": 31, + "multipleOf": 1 + }, + "pin": {"$ref": "qmk.definitions.v1#/mcu_pin"} + } + }, "board": { "type": "string", "minLength": 2, @@ -29,6 +52,13 @@ "enum": ["COL2ROW", "ROW2COL"] }, "debounce": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "combo": { + "type": "object", + "properties": { + "count": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "term": {"$ref": "qmk.definitions.v1#/unsigned_int"} + } + }, "community_layouts": { "type": "array", "items": {"$ref": "qmk.definitions.v1#/filename"} @@ -90,16 +120,34 @@ } } }, + "leader_key": { + "type": "object", + "properties": { + "timing": {"type": "boolean"}, + "strict_processing": {"type": "boolean"}, + "timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"} + } + }, "matrix_pins": { "type": "object", "additionalProperties": false, "properties": { + "ghost": {"type": "boolean"}, + "io_delay": {"$ref": "qmk.definitions.v1#/unsigned_int"}, "direct": { "type": "array", - "items": {$ref": "qmk.definitions.v1#/mcu_pin_array"} + "items": {"$ref": "qmk.definitions.v1#/mcu_pin_array"} }, "cols": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, - "rows": {"$ref": "qmk.definitions.v1#/mcu_pin_array"} + "rows": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, + "unused": {"$ref": "qmk.definitions.v1#/mcu_pin_array"} + } + }, + "oneshot": { + "type": "object", + "properties": { + "tap_toggle": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"} } }, "rgblight": { @@ -154,13 +202,41 @@ "type": "array", "items": {"type": "string"} }, + "tapping": { + "type": "object", + "properties": { + "force_hold": {"type": "boolean"}, + "force_hold_per_key": {"type": "boolean"}, + "ignore_mod_tap_interrupt": {"type": "boolean"}, + "ignore_mod_tap_interrupt_per_key": {"type": "boolean"}, + "permissive_hold": {"type": "boolean"}, + "permissive_hold_per_key": {"type": "boolean"}, + "retro": {"type": "boolean"}, + "retro_per_key": {"type": "boolean"}, + "term": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "term_per_key": {"type": "boolean"}, + "toggle": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + } + }, "usb": { "type": "object", "additionalProperties": false, "properties": { "device_ver": {"$ref": "qmk.definitions.v1#/hex_number_4d"}, "pid": {"$ref": "qmk.definitions.v1#/hex_number_4d"}, - "vid": {"$ref": "qmk.definitions.v1#/hex_number_4d"} + "vid": {"$ref": "qmk.definitions.v1#/hex_number_4d"}, + "max_power": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, + "polling_interval": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, + "suspend_wakeup_delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"} + } + }, + "qmk": { + "type": "object", + "additionalProperties": false, + "properties": { + "keys_per_scan": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, + "tap_keycode_delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, + "tap_capslock_delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, } }, "qmk_lufa_bootloader": { diff --git a/lib/python/qmk/cli/generate/info_json.py b/lib/python/qmk/cli/generate/info_json.py index 8931b68b6ff4..30bb9b6ae44b 100755 --- a/lib/python/qmk/cli/generate/info_json.py +++ b/lib/python/qmk/cli/generate/info_json.py @@ -35,7 +35,7 @@ def strip_info_json(kb_info_json): """Remove the API-only properties from the info.json. """ pruning_draft_7_validator = pruning_validator(Draft7Validator) - schema = load_jsonschema('keyboard') + schema = load_jsonschema('qmk.keyboard.v1') validator = pruning_draft_7_validator(schema).validate return validator(kb_info_json) diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 858fbab33587..6e2f360c3c95 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -188,11 +188,26 @@ def _extract_direct_matrix(info_data, direct_pins): return direct_pin_array +def _extract_audio(info_data, config_c): + """Populate the matrix information. + """ + audio_pins = [] + + for pin in 'B5', 'B6', 'B7', 'C4', 'C5', 'C6': + if config_c.get(f'{pin}_AUDIO'): + audio_pins.append(pin) + + if audio_pins: + info_data['audio'] = {'pins': audio_pins} + + def _extract_matrix_info(info_data, config_c): """Populate the matrix information. """ row_pins = config_c.get('MATRIX_ROW_PINS', '').replace('{', '').replace('}', '').strip() col_pins = config_c.get('MATRIX_COL_PINS', '').replace('{', '').replace('}', '').strip() + unused_pin_text = config_c.get('UNUSED_PINS') + unused_pins = unused_pin_text.replace('{', '').replace('}', '').strip() if isinstance(unused_pin_text, str) else None direct_pins = config_c.get('DIRECT_PINS', '').replace(' ', '')[1:-1] if 'MATRIX_ROWS' in config_c and 'MATRIX_COLS' in config_c: @@ -219,6 +234,9 @@ def _extract_matrix_info(info_data, config_c): info_data['matrix_pins']['direct'] = _extract_direct_matrix(info_data, direct_pins) + if unused_pins and 'matirx_pins' in info_data: + info_data['matrix_pins']['unused'] = _extract_pins(unused_pins) + return info_data @@ -275,6 +293,7 @@ def _extract_config_h(info_data): # Pull data that easily can't be mapped in json _extract_matrix_info(info_data, config_c) + _extract_audio(info_data, config_c) return info_data diff --git a/lib/python/qmk/json_schema.py b/lib/python/qmk/json_schema.py index cbc5bff51885..f73303f86fa0 100644 --- a/lib/python/qmk/json_schema.py +++ b/lib/python/qmk/json_schema.py @@ -2,6 +2,7 @@ """ import json from collections.abc import Mapping +from functools import lru_cache from pathlib import Path import hjson @@ -25,6 +26,7 @@ def json_load(json_file): exit(1) +@lru_cache(maxsize=0) def load_jsonschema(schema_name): """Read a jsonschema file from disk. """ @@ -39,6 +41,7 @@ def load_jsonschema(schema_name): return json_load(schema_path) +@lru_cache(maxsize=0) def create_validator(schema): """Creates a validator for the given schema id. """ From 021fa6985f638be45d03f784887c207a24267d81 Mon Sep 17 00:00:00 2001 From: Zach White Date: Fri, 25 Jun 2021 08:56:25 -0700 Subject: [PATCH 04/37] add support for designating master split --- data/schemas/keyboard.jsonschema | 4 ++++ lib/python/qmk/cli/generate/config_h.py | 12 ++++++++++ lib/python/qmk/info.py | 29 +++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index baa6705600d1..d3ed2418b741 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -185,6 +185,10 @@ "hand_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, "hand_matrix_grid": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, "mirror": {"type": "boolean"}, + "primary": { + "type": "string", + "enum": ["left", "right"] + }, "transport": { "type": "string", "enum": ["custom", "mirror", "serial", "I2C"] diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py index 54cd5b96a87f..ccf0fbd62a4e 100755 --- a/lib/python/qmk/cli/generate/config_h.py +++ b/lib/python/qmk/cli/generate/config_h.py @@ -138,6 +138,18 @@ def generate_config_h(cli): if 'matrix_pins' in kb_info_json: config_h_lines.append(matrix_pins(kb_info_json['matrix_pins'])) + if 'split' in kb_info_json: + if 'primary' in kb_info_json['split']: + config_h_lines.append('') + config_h_lines.append('#ifndef MASTER_LEFT') + config_h_lines.append('# ifndef MASTER_RIGHT') + if kb_info_json['split']['primary'] == 'left': + config_h_lines.append('# define MASTER_LEFT') + elif kb_info_json['split']['primary'] == 'right': + config_h_lines.append('# define MASTER_RIGHT') + config_h_lines.append('# endif // MASTER_RIGHT') + config_h_lines.append('#endif // MASTER_LEFT') + # Show the results config_h = '\n'.join(config_h_lines) diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 6e2f360c3c95..e9965aa3ea58 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -189,7 +189,7 @@ def _extract_direct_matrix(info_data, direct_pins): def _extract_audio(info_data, config_c): - """Populate the matrix information. + """Populate data about the audio configuration """ audio_pins = [] @@ -201,6 +201,28 @@ def _extract_audio(info_data, config_c): info_data['audio'] = {'pins': audio_pins} +def _extract_split(info_data, config_c): + """Populate data about the split configuration + """ + if config_c.get('MASTER_RIGHT') is True: + if 'split' not in info_data: + info_data['split'] = {} + + if 'primary' in info_data['split']: + _log_warning(info_data, 'Split primary hand is specified in both config.h (MASTER_RIGHT) and split.primary (%s), the config.h value wins.') + + info_data['split']['primary'] = 'right' + + if config_c.get('MASTER_LEFT') is True: + if 'split' not in info_data: + info_data['split'] = {} + + if 'primary' in info_data['split']: + _log_warning(info_data, 'Split primary hand is specified in both config.h (MASTER_RIGHT) and split.primary (%s), the config.h value wins.') + + info_data['split']['primary'] = 'left' + + def _extract_matrix_info(info_data, config_c): """Populate the matrix information. """ @@ -234,7 +256,10 @@ def _extract_matrix_info(info_data, config_c): info_data['matrix_pins']['direct'] = _extract_direct_matrix(info_data, direct_pins) - if unused_pins and 'matirx_pins' in info_data: + if unused_pins: + if 'matrix_pins' not in info_data: + info_data['matrix_pins'] = {} + info_data['matrix_pins']['unused'] = _extract_pins(unused_pins) return info_data From d6e152b54a2c882f4dd9fc4dd7565663ff7b9f72 Mon Sep 17 00:00:00 2001 From: Zach White Date: Fri, 25 Jun 2021 17:26:59 -0700 Subject: [PATCH 05/37] sort out split transport and primary --- data/mappings/info_config.json | 6 +-- data/mappings/info_rules.json | 2 +- data/schemas/keyboard.jsonschema | 21 ++++++---- lib/python/qmk/cli/generate/config_h.py | 34 +++++++++++---- lib/python/qmk/info.py | 55 +++++++++++++++++++++++-- 5 files changed, 93 insertions(+), 25 deletions(-) diff --git a/data/mappings/info_config.json b/data/mappings/info_config.json index cfb952dd18cc..90f7a17ff0c8 100644 --- a/data/mappings/info_config.json +++ b/data/mappings/info_config.json @@ -17,7 +17,6 @@ "DEVICE_VER": {"info_key": "usb.device_ver", "value_type": "hex"}, "DESCRIPTION": {"info_key": "keyboard_folder", "to_json": false}, "DIODE_DIRECTION": {"info_key": "diode_direction"}, - "EE_HANDS": {"info_key": "split.ee_hands"}, "FORCE_NKRO": {"info_key": "features.force_nkro", "value_type": "bool"}, "IGNORE_MOD_TAP_INTERRUPT": {"info_key": "tapping.ignore_mod_tap_interrupt", "value_type": "bool"}, "IGNORE_MOD_TAP_INTERRUPT_PER_KEY": {"info_key": "tapping.ignore_mod_tap_interrupt_per_key", "value_type": "bool"}, @@ -65,9 +64,8 @@ "QMK_KEYS_PER_SCAN": {"info_key": "qmk.keys_per_scan", "value_type": "int"}, "QMK_LED": {"info_key": "qmk_lufa_bootloader.led"}, "QMK_SPEAKER": {"info_key": "qmk_lufa_bootloader.speaker"}, - "SPLIT_HAND_PIN": {"info_key": "split.hand_pin"}, - "SPLIT_HAND_MATRIX_GRID": {"info_key": "split.hand_matrix_grid", "value_type": "array"}, - "SPLIT_TRANSPORT_MIRROR": {"info_key": "split.mirror", "value_type": "bool"}, + "SPLIT_MODS_ENABLE": {"info_key": "split.transport.mods", "value_type": "bool"}, + "SPLIT_TRANSPORT_MIRROR": {"info_key": "split.transport.mirror", "value_type": "bool"}, "SOFT_SERIAL_PIN": {"info_key": "split.soft_serial_pin"}, "SOFT_SERIAL_SPEED": {"info_key": "split.soft_serial_speed"}, "TAP_CODE_DELAY": {"info_key": "qmk.tap_keycode_delay", "value_type": "int"}, diff --git a/data/mappings/info_rules.json b/data/mappings/info_rules.json index 1838e80137a1..bfa71812a643 100644 --- a/data/mappings/info_rules.json +++ b/data/mappings/info_rules.json @@ -13,5 +13,5 @@ "LED_MATRIX_DRIVER": {"info_key": "led_matrix.driver"}, "MCU": {"info_key": "processor", "warn_duplicate": false}, "SPLIT_KEYBOARD": {"info_key": "split.enabled", "value_type": "bool"}, - "SPLIT_TRANSPORT": {"info_key": "split.transport", "value_type": "str"} + "SPLIT_TRANSPORT": {"info_key": "split.transport.protocol", "value_type": "str"} } diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index d3ed2418b741..1a21c05a6da7 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -180,19 +180,24 @@ "type": "object", "additionalProperties": false, "properties": { - "ee_hands": {"type": "boolean"}, "enabled": {"type": "boolean"}, - "hand_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, - "hand_matrix_grid": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, - "mirror": {"type": "boolean"}, "primary": { "type": "string", - "enum": ["left", "right"] + "enum": ["eeprom", "left", "matrix_grid", "pin", "right"] }, "transport": { - "type": "string", - "enum": ["custom", "mirror", "serial", "I2C"] - }, + "type": "object", + "additionalProperties": false, + "properties": { + "protocol": { + "type": "string", + "enum": ["custom", "i2c", "serial"] + }, + "mirror": {"type": "boolean"}, + "mods": {"type": "boolean"}, + + } + } "soft_serial_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, "soft_serial_speed": { "type": "number", diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py index ccf0fbd62a4e..05fd7856f416 100755 --- a/lib/python/qmk/cli/generate/config_h.py +++ b/lib/python/qmk/cli/generate/config_h.py @@ -140,15 +140,31 @@ def generate_config_h(cli): if 'split' in kb_info_json: if 'primary' in kb_info_json['split']: - config_h_lines.append('') - config_h_lines.append('#ifndef MASTER_LEFT') - config_h_lines.append('# ifndef MASTER_RIGHT') - if kb_info_json['split']['primary'] == 'left': - config_h_lines.append('# define MASTER_LEFT') - elif kb_info_json['split']['primary'] == 'right': - config_h_lines.append('# define MASTER_RIGHT') - config_h_lines.append('# endif // MASTER_RIGHT') - config_h_lines.append('#endif // MASTER_LEFT') + if kb_info_json['split']['primary'] in ('left', 'right'): + config_h_lines.append('') + config_h_lines.append('#ifndef MASTER_LEFT') + config_h_lines.append('# ifndef MASTER_RIGHT') + if kb_info_json['split']['primary'] == 'left': + config_h_lines.append('# define MASTER_LEFT') + elif kb_info_json['split']['primary'] == 'right': + config_h_lines.append('# define MASTER_RIGHT') + config_h_lines.append('# endif // MASTER_RIGHT') + config_h_lines.append('#endif // MASTER_LEFT') + elif kb_info_json['split']['primary'] == 'pin': + config_h_lines.append('') + config_h_lines.append('#ifndef SPLIT_HAND_PIN') + config_h_lines.append('# define SPLIT_HAND_PIN') + config_h_lines.append('#endif // SPLIT_HAND_PIN') + elif kb_info_json['split']['primary'] == 'matrix_grid': + config_h_lines.append('') + config_h_lines.append('#ifndef SPLIT_HAND_MATRIX_GRID') + config_h_lines.append('# define SPLIT_HAND_MATRIX_GRID {%s}' % (','.join(kb_info_json["split"]["matrix_grid"],))) + config_h_lines.append('#endif // SPLIT_HAND_MATRIX_GRID') + elif kb_info_json['split']['primary'] == 'eeprom': + config_h_lines.append('') + config_h_lines.append('#ifndef EE_HANDS') + config_h_lines.append('# define EE_HANDS') + config_h_lines.append('#endif // EE_HANDS') # Show the results config_h = '\n'.join(config_h_lines) diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index e9965aa3ea58..288d15c19b0c 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -61,8 +61,8 @@ def info_json(keyboard): # Merge in the data from info.json, config.h, and rules.mk info_data = merge_info_jsons(keyboard, info_data) - info_data = _extract_config_h(info_data) info_data = _extract_rules_mk(info_data) + info_data = _extract_config_h(info_data) # Ensure that we have matrix row and column counts info_data = _matrix_size(info_data) @@ -204,12 +204,40 @@ def _extract_audio(info_data, config_c): def _extract_split(info_data, config_c): """Populate data about the split configuration """ + if config_c.get('SPLIT_HAND_PIN') is True: + if 'split' not in info_data: + info_data['split'] = {} + + if 'primary' in info_data['split']: + _log_warning(info_data, 'Split primary hand is specified in both config.h (SPLIT_HAND_PIN) and info.json (split.primary) (Value: %s), the config.h value wins.') + + info_data['split']['primary'] = 'pin' + + if config_c.get('SPLIT_HAND_MATRIX_GRID'): + if 'split' not in info_data: + info_data['split'] = {} + + if 'primary' in info_data['split']: + _log_warning(info_data, 'Split primary hand is specified in both config.h (SPLIT_HAND_MATRIX_GRID) and info.json (split.primary) (Value: %s), the config.h value wins.') + + info_data['split']['primary'] = 'matrix_grid' + info_data['split']['matrix_grid'] = _extract_pins(config_c['SPLIT_HAND_MATRIX_GRID']) + + if config_c.get('EE_HANDS') is True: + if 'split' not in info_data: + info_data['split'] = {} + + if 'primary' in info_data['split']: + _log_warning(info_data, 'Split primary hand is specified in both config.h (EE_HANDS) and info.json (split.primary) (Value: %s), the config.h value wins.') + + info_data['split']['primary'] = 'eeprom' + if config_c.get('MASTER_RIGHT') is True: if 'split' not in info_data: info_data['split'] = {} if 'primary' in info_data['split']: - _log_warning(info_data, 'Split primary hand is specified in both config.h (MASTER_RIGHT) and split.primary (%s), the config.h value wins.') + _log_warning(info_data, 'Split primary hand is specified in both config.h (MASTER_RIGHT) and info.json (split.primary) (Value: %s), the config.h value wins.') info_data['split']['primary'] = 'right' @@ -218,10 +246,31 @@ def _extract_split(info_data, config_c): info_data['split'] = {} if 'primary' in info_data['split']: - _log_warning(info_data, 'Split primary hand is specified in both config.h (MASTER_RIGHT) and split.primary (%s), the config.h value wins.') + _log_warning(info_data, 'Split primary hand is specified in both config.h (MASTER_LEFT) and info.json (split.primary) (Value: %s), the config.h value wins.') info_data['split']['primary'] = 'left' + if config_c.get('USE_I2C') is True: + if 'split' not in info_data: + info_data['split'] = {} + + if 'transport' not in info_data['split']: + info_data['split']['transport'] = {} + + if 'protocol' in info_data['split']['transport']: + _log_warning(info_data, 'Split transport is specified in both config.h (USE_I2C) and info.json (split.transport.protocol) (Value: %s), the config.h value wins.') + + info_data['split']['transport']['protocol'] = 'i2c' + + elif 'protocol' not in info_data.get('split', {}).get('transport', {}): + if 'split' not in info_data: + info_data['split'] = {} + + if 'transport' not in info_data['split']: + info_data['split']['transport'] = {} + + info_data['split']['transport']['protocol'] = 'serial' + def _extract_matrix_info(info_data, config_c): """Populate the matrix information. From cd1c3fc051293d17c0fc7da744417f71a6bb2dbb Mon Sep 17 00:00:00 2001 From: Zach White Date: Fri, 25 Jun 2021 17:27:08 -0700 Subject: [PATCH 06/37] fix bad data in UNUSED_PINS --- keyboards/handwired/tennie/config.h | 2 +- keyboards/mesa/mesa_tkl/config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/keyboards/handwired/tennie/config.h b/keyboards/handwired/tennie/config.h index fee1258dfd29..b1bddac45bc1 100644 --- a/keyboards/handwired/tennie/config.h +++ b/keyboards/handwired/tennie/config.h @@ -42,7 +42,7 @@ along with this program. If not, see . */ #define MATRIX_ROW_PINS { C6, D4, D0} #define MATRIX_COL_PINS { D7, E6, B4, B5 } -#define UNUSED_PINS { B1, B2, B3, B6, F4, F5, F6, F7 D1} +#define UNUSED_PINS { B1, B2, B3, B6, F4, F5, F6, F7, D1} /* COL2ROW, ROW2COL */ #define DIODE_DIRECTION COL2ROW diff --git a/keyboards/mesa/mesa_tkl/config.h b/keyboards/mesa/mesa_tkl/config.h index f4c26e2a0f4f..23da260bcf68 100644 --- a/keyboards/mesa/mesa_tkl/config.h +++ b/keyboards/mesa/mesa_tkl/config.h @@ -42,7 +42,7 @@ along with this program. If not, see . */ #define MATRIX_ROW_PINS { D2, D1, D0, B0, C6, C7 } #define MATRIX_COL_PINS { D3, D5, D4, D6, D7, B4, B5, B6, F7, F6, F5, F4, F1, F0, B1, B2, B3 } -#define UNUSED_PINS { B7 E6 } +#define UNUSED_PINS { B7, E6 } /* COL2ROW, ROW2COL*/ #define DIODE_DIRECTION COL2ROW From c09216e900b49baef069a04d678dde30df991d6c Mon Sep 17 00:00:00 2001 From: Zach White Date: Fri, 25 Jun 2021 17:40:45 -0700 Subject: [PATCH 07/37] fixup custom transport --- data/mappings/info_rules.json | 2 +- lib/python/qmk/cli/generate/config_h.py | 7 +++++++ lib/python/qmk/cli/generate/rules_mk.py | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/data/mappings/info_rules.json b/data/mappings/info_rules.json index bfa71812a643..4845696d5bcd 100644 --- a/data/mappings/info_rules.json +++ b/data/mappings/info_rules.json @@ -13,5 +13,5 @@ "LED_MATRIX_DRIVER": {"info_key": "led_matrix.driver"}, "MCU": {"info_key": "processor", "warn_duplicate": false}, "SPLIT_KEYBOARD": {"info_key": "split.enabled", "value_type": "bool"}, - "SPLIT_TRANSPORT": {"info_key": "split.transport.protocol", "value_type": "str"} + "SPLIT_TRANSPORT": {"info_key": "split.transport.protocol", "value_type": "str", "to_c": false} } diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py index 05fd7856f416..19ee3bbdec2e 100755 --- a/lib/python/qmk/cli/generate/config_h.py +++ b/lib/python/qmk/cli/generate/config_h.py @@ -166,6 +166,13 @@ def generate_config_h(cli): config_h_lines.append('# define EE_HANDS') config_h_lines.append('#endif // EE_HANDS') + if 'protocol' in kb_info_json['split'].get('transport', {}): + if kb_info_json['split']['transport']['protocol'] == 'i2c': + config_h_lines.append('') + config_h_lines.append('#ifndef USE_I2C') + config_h_lines.append('# define USE_I2C') + config_h_lines.append('#endif // USE_I2C') + # Show the results config_h = '\n'.join(config_h_lines) diff --git a/lib/python/qmk/cli/generate/rules_mk.py b/lib/python/qmk/cli/generate/rules_mk.py index 41c94e16b554..70d0663c8d1e 100755 --- a/lib/python/qmk/cli/generate/rules_mk.py +++ b/lib/python/qmk/cli/generate/rules_mk.py @@ -76,6 +76,10 @@ def generate_rules_mk(cli): enabled = 'yes' if enabled else 'no' rules_mk_lines.append(f'{feature}_ENABLE ?= {enabled}') + # Set SPLIT_TRANSPORT, if needed + if kb_info_json.get('split', {}).get('transport', {}).get('protocol') == 'custom': + rules_mk_lines.append('SPLIT_TRANSPORT ?= custom') + # Show the results rules_mk = '\n'.join(rules_mk_lines) + '\n' From aa29277c541d3d45736ffca010ccdb87577dbdfd Mon Sep 17 00:00:00 2001 From: Zach White Date: Fri, 25 Jun 2021 20:20:52 -0700 Subject: [PATCH 08/37] wip --- data/schemas/keyboard.jsonschema | 23 ++++++++++++++ lib/python/qmk/info.py | 54 ++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 1a21c05a6da7..7732c2d23636 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -181,6 +181,29 @@ "additionalProperties": false, "properties": { "enabled": {"type": "boolean"}, + "matrix_pins": { + "type": "object", + "additionalProperties": false, + "properties": { + "right": { + "type": "object", + "additionalProperties": false, + "properties": { + "type": "object", + "additionalProperties": false, + "properties": { + "direct": { + "type": "array", + "items": {"$ref": "qmk.definitions.v1#/mcu_pin_array"} + }, + "cols": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, + "rows": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, + "unused": {"$ref": "qmk.definitions.v1#/mcu_pin_array"} + } + } + } + } + }, "primary": { "type": "string", "enum": ["eeprom", "left", "matrix_grid", "pin", "right"] diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 288d15c19b0c..671c04e6a51f 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -204,6 +204,7 @@ def _extract_audio(info_data, config_c): def _extract_split(info_data, config_c): """Populate data about the split configuration """ + # Figure out how the primary half is determined if config_c.get('SPLIT_HAND_PIN') is True: if 'split' not in info_data: info_data['split'] = {} @@ -250,6 +251,7 @@ def _extract_split(info_data, config_c): info_data['split']['primary'] = 'left' + # Figure out the transport method if config_c.get('USE_I2C') is True: if 'split' not in info_data: info_data['split'] = {} @@ -271,6 +273,58 @@ def _extract_split(info_data, config_c): info_data['split']['transport']['protocol'] = 'serial' + # Figure out the right half matrix pins + row_pins = config_c.get('MATRIX_ROW_PINS_RIGHT', '').replace('{', '').replace('}', '').strip() + col_pins = config_c.get('MATRIX_COL_PINS_RIGHT', '').replace('{', '').replace('}', '').strip() + unused_pin_text = config_c.get('UNUSED_PINS_RIGHT') + unused_pins = unused_pin_text.replace('{', '').replace('}', '').strip() if isinstance(unused_pin_text, str) else None + direct_pins = config_c.get('DIRECT_PINS_RIGHT', '').replace(' ', '')[1:-1] + + if row_pins and col_pins: + if info_data.get('split', {}).get('matrix_pins', {}).get('right', {}) in info_data: + _log_warning(info_data, 'Right hand matrix data is specified in both info.json and config.h, the config.h values win.') + + if 'split' not in info_data: + info_data['split'] = {} + + if 'matrix_pins' not in info_data['split']: + info_data['split']['matrix_pins'] = {} + + if 'right' not in info_data['split']['matrix_pins']: + info_data['split']['matrix_pins']['right'] = {} + + info_data['split']['matrix_pins']['right'] = { + 'cols': _extract_pins(col_pins), + 'rows': _extract_pins(row_pins), + } + + if direct_pins: + if info_data.get('split', {}).get('matrix_pins', {}).get('right', {}) in info_data: + _log_warning(info_data, 'Right hand matrix data is specified in both info.json and config.h, the config.h values win.') + + if 'split' not in info_data: + info_data['split'] = {} + + if 'matrix_pins' not in info_data['split']: + info_data['split']['matrix_pins'] = {} + + if 'right' not in info_data['split']['matrix_pins']: + info_data['split']['matrix_pins']['right'] = {} + + info_data['split']['matrix_pins']['right']['direct'] = _extract_direct_matrix(info_data, direct_pins) + + if unused_pins: + if 'split' not in info_data: + info_data['split'] = {} + + if 'matrix_pins' not in info_data['split']: + info_data['split']['matrix_pins'] = {} + + if 'right' not in info_data['split']['matrix_pins']: + info_data['split']['matrix_pins']['right'] = {} + + info_data['split']['matrix_pins']['right']['unused'] = _extract_pins(unused_pins) + def _extract_matrix_info(info_data, config_c): """Populate the matrix information. From dad8f596e6812cb489b705fb9a5bd2b5e3d32e7a Mon Sep 17 00:00:00 2001 From: Zach White Date: Sun, 27 Jun 2021 19:50:52 -0700 Subject: [PATCH 09/37] allow for setting split right half keyboard matrix --- data/schemas/keyboard.jsonschema | 18 ++++----- lib/python/qmk/cli/generate/config_h.py | 49 +++++++++++++------------ lib/python/qmk/info.py | 5 ++- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 7732c2d23636..5e0788ad7d1a 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -189,17 +189,13 @@ "type": "object", "additionalProperties": false, "properties": { - "type": "object", - "additionalProperties": false, - "properties": { - "direct": { - "type": "array", - "items": {"$ref": "qmk.definitions.v1#/mcu_pin_array"} - }, - "cols": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, - "rows": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, - "unused": {"$ref": "qmk.definitions.v1#/mcu_pin_array"} - } + "direct": { + "type": "array", + "items": {"$ref": "qmk.definitions.v1#/mcu_pin_array"} + }, + "cols": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, + "rows": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, + "unused": {"$ref": "qmk.definitions.v1#/mcu_pin_array"} } } } diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py index 19ee3bbdec2e..ad0b5995cd26 100755 --- a/lib/python/qmk/cli/generate/config_h.py +++ b/lib/python/qmk/cli/generate/config_h.py @@ -12,7 +12,7 @@ from qmk.path import is_keyboard, normpath -def direct_pins(direct_pins): +def direct_pins(direct_pins, postfix): """Return the config.h lines that set the direct pins. """ rows = [] @@ -24,51 +24,51 @@ def direct_pins(direct_pins): col_count = len(direct_pins[0]) row_count = len(direct_pins) - return """ -#ifndef MATRIX_COLS -# define MATRIX_COLS %s -#endif // MATRIX_COLS + return f""" +#ifndef MATRIX_COLS{postfix} +# define MATRIX_COLS{postfix} {col_count} +#endif // MATRIX_COLS{postfix} -#ifndef MATRIX_ROWS -# define MATRIX_ROWS %s -#endif // MATRIX_ROWS +#ifndef MATRIX_ROWS{postfix} +# define MATRIX_ROWS{postfix} {row_count} +#endif // MATRIX_ROWS{postfix} -#ifndef DIRECT_PINS -# define DIRECT_PINS {%s} -#endif // DIRECT_PINS -""" % (col_count, row_count, ','.join(rows)) +#ifndef DIRECT_PINS{postfix} +# define DIRECT_PINS{postfix} {{ {", ".join(rows)} }} +#endif // DIRECT_PINS{postfix} +""" -def pin_array(define, pins): +def pin_array(define, pins, postfix): """Return the config.h lines that set a pin array. """ pin_num = len(pins) pin_array = ', '.join(map(str, [pin or 'NO_PIN' for pin in pins])) return f""" -#ifndef {define}S -# define {define}S {pin_num} -#endif // {define}S +#ifndef {define}S{postfix} +# define {define}S{postfix} {pin_num} +#endif // {define}S{postfix} -#ifndef {define}_PINS -# define {define}_PINS {{ {pin_array} }} -#endif // {define}_PINS +#ifndef {define}_PINS{postfix} +# define {define}_PINS{postfix} {{ {pin_array} }} +#endif // {define}_PINS{postfix} """ -def matrix_pins(matrix_pins): +def matrix_pins(matrix_pins, postfix=''): """Add the matrix config to the config.h. """ pins = [] if 'direct' in matrix_pins: - pins.append(direct_pins(matrix_pins['direct'])) + pins.append(direct_pins(matrix_pins['direct'], postfix)) if 'cols' in matrix_pins: - pins.append(pin_array('MATRIX_COL', matrix_pins['cols'])) + pins.append(pin_array('MATRIX_COL', matrix_pins['cols'], postfix)) if 'rows' in matrix_pins: - pins.append(pin_array('MATRIX_ROW', matrix_pins['rows'])) + pins.append(pin_array('MATRIX_ROW', matrix_pins['rows'], postfix)) return '\n'.join(pins) @@ -173,6 +173,9 @@ def generate_config_h(cli): config_h_lines.append('# define USE_I2C') config_h_lines.append('#endif // USE_I2C') + if 'right' in kb_info_json['split'].get('matrix_pins', {}): + config_h_lines.append(matrix_pins(kb_info_json['split']['matrix_pins']['right'], '_RIGHT')) + # Show the results config_h = '\n'.join(config_h_lines) diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 671c04e6a51f..62499f999808 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -281,7 +281,7 @@ def _extract_split(info_data, config_c): direct_pins = config_c.get('DIRECT_PINS_RIGHT', '').replace(' ', '')[1:-1] if row_pins and col_pins: - if info_data.get('split', {}).get('matrix_pins', {}).get('right', {}) in info_data: + if info_data.get('split', {}).get('matrix_pins', {}).get('right') in info_data: _log_warning(info_data, 'Right hand matrix data is specified in both info.json and config.h, the config.h values win.') if 'split' not in info_data: @@ -299,7 +299,7 @@ def _extract_split(info_data, config_c): } if direct_pins: - if info_data.get('split', {}).get('matrix_pins', {}).get('right', {}) in info_data: + if info_data.get('split', {}).get('matrix_pins', {}).get('right', {}): _log_warning(info_data, 'Right hand matrix data is specified in both info.json and config.h, the config.h values win.') if 'split' not in info_data: @@ -422,6 +422,7 @@ def _extract_config_h(info_data): # Pull data that easily can't be mapped in json _extract_matrix_info(info_data, config_c) _extract_audio(info_data, config_c) + _extract_split(info_data, config_c) return info_data From 8d4494c9f37ed7932d31e70408cd36a77cfe686a Mon Sep 17 00:00:00 2001 From: Zach White Date: Sun, 27 Jun 2021 20:28:17 -0700 Subject: [PATCH 10/37] add SPLIT_USB_DETECT --- data/mappings/info_config.json | 3 ++- data/schemas/keyboard.jsonschema | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/data/mappings/info_config.json b/data/mappings/info_config.json index 90f7a17ff0c8..32619ea35c50 100644 --- a/data/mappings/info_config.json +++ b/data/mappings/info_config.json @@ -1,4 +1,4 @@ -# This file maps keys between `config.h` and `info.json`. It is used by QMK +# This file maps keys between `config.h` and `info.json`. It is used by QMK # to correctly and consistently map back and forth between the two systems. { # Format: @@ -66,6 +66,7 @@ "QMK_SPEAKER": {"info_key": "qmk_lufa_bootloader.speaker"}, "SPLIT_MODS_ENABLE": {"info_key": "split.transport.mods", "value_type": "bool"}, "SPLIT_TRANSPORT_MIRROR": {"info_key": "split.transport.mirror", "value_type": "bool"}, + "SPLIT_USB_DETECT": {"info_key": "split.usb_detect", "value_type": "bool"}, "SOFT_SERIAL_PIN": {"info_key": "split.soft_serial_pin"}, "SOFT_SERIAL_SPEED": {"info_key": "split.soft_serial_speed"}, "TAP_CODE_DELAY": {"info_key": "qmk.tap_keycode_delay", "value_type": "int"}, diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 5e0788ad7d1a..a09b77732ca4 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -204,6 +204,13 @@ "type": "string", "enum": ["eeprom", "left", "matrix_grid", "pin", "right"] }, + "soft_serial_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, + "soft_serial_speed": { + "type": "number", + "min": 0, + "max": 5, + "multipleOf": 1 + }, "transport": { "type": "object", "additionalProperties": false, @@ -213,17 +220,10 @@ "enum": ["custom", "i2c", "serial"] }, "mirror": {"type": "boolean"}, - "mods": {"type": "boolean"}, - + "mods": {"type": "boolean"} } - } - "soft_serial_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, - "soft_serial_speed": { - "type": "number", - "min": 0, - "max": 5, - "multipleOf": 1 - } + }, + "usb_detect": {"type": "boolean"}, } }, "tags": { From 191f78fece81808ec16e1fa17622d794d36c6deb Mon Sep 17 00:00:00 2001 From: Zach White Date: Sun, 27 Jun 2021 20:34:46 -0700 Subject: [PATCH 11/37] minor cleanup --- data/schemas/keyboard.jsonschema | 4 ++++ lib/python/qmk/info.py | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index a09b77732ca4..732979b110d2 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -181,6 +181,10 @@ "additionalProperties": false, "properties": { "enabled": {"type": "boolean"}, + "matrix_grid": { + "type": "array", + "items": {"$ref": "qmk.definitions.v1#/mcu_pin"} + }, "matrix_pins": { "type": "object", "additionalProperties": false, diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 62499f999808..e7c5ba598ebb 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -210,7 +210,7 @@ def _extract_split(info_data, config_c): info_data['split'] = {} if 'primary' in info_data['split']: - _log_warning(info_data, 'Split primary hand is specified in both config.h (SPLIT_HAND_PIN) and info.json (split.primary) (Value: %s), the config.h value wins.') + _log_warning(info_data, 'Split primary hand is specified in both config.h (SPLIT_HAND_PIN) and info.json (split.primary) (Value: %s), the config.h value wins.' % info_data['split']['primary']) info_data['split']['primary'] = 'pin' @@ -219,7 +219,7 @@ def _extract_split(info_data, config_c): info_data['split'] = {} if 'primary' in info_data['split']: - _log_warning(info_data, 'Split primary hand is specified in both config.h (SPLIT_HAND_MATRIX_GRID) and info.json (split.primary) (Value: %s), the config.h value wins.') + _log_warning(info_data, 'Split primary hand is specified in both config.h (SPLIT_HAND_MATRIX_GRID) and info.json (split.primary) (Value: %s), the config.h value wins.' % info_data['split']['primary']) info_data['split']['primary'] = 'matrix_grid' info_data['split']['matrix_grid'] = _extract_pins(config_c['SPLIT_HAND_MATRIX_GRID']) @@ -229,7 +229,7 @@ def _extract_split(info_data, config_c): info_data['split'] = {} if 'primary' in info_data['split']: - _log_warning(info_data, 'Split primary hand is specified in both config.h (EE_HANDS) and info.json (split.primary) (Value: %s), the config.h value wins.') + _log_warning(info_data, 'Split primary hand is specified in both config.h (EE_HANDS) and info.json (split.primary) (Value: %s), the config.h value wins.' % info_data['split']['primary']) info_data['split']['primary'] = 'eeprom' @@ -238,7 +238,7 @@ def _extract_split(info_data, config_c): info_data['split'] = {} if 'primary' in info_data['split']: - _log_warning(info_data, 'Split primary hand is specified in both config.h (MASTER_RIGHT) and info.json (split.primary) (Value: %s), the config.h value wins.') + _log_warning(info_data, 'Split primary hand is specified in both config.h (MASTER_RIGHT) and info.json (split.primary) (Value: %s), the config.h value wins.' % info_data['split']['primary']) info_data['split']['primary'] = 'right' @@ -247,7 +247,7 @@ def _extract_split(info_data, config_c): info_data['split'] = {} if 'primary' in info_data['split']: - _log_warning(info_data, 'Split primary hand is specified in both config.h (MASTER_LEFT) and info.json (split.primary) (Value: %s), the config.h value wins.') + _log_warning(info_data, 'Split primary hand is specified in both config.h (MASTER_LEFT) and info.json (split.primary) (Value: %s), the config.h value wins.' % info_data['split']['primary']) info_data['split']['primary'] = 'left' @@ -260,7 +260,7 @@ def _extract_split(info_data, config_c): info_data['split']['transport'] = {} if 'protocol' in info_data['split']['transport']: - _log_warning(info_data, 'Split transport is specified in both config.h (USE_I2C) and info.json (split.transport.protocol) (Value: %s), the config.h value wins.') + _log_warning(info_data, 'Split transport is specified in both config.h (USE_I2C) and info.json (split.transport.protocol) (Value: %s), the config.h value wins.' % info_data['split']['transport']) info_data['split']['transport']['protocol'] = 'i2c' From c0f3ceb47e47999e66d94852c8bf78ff330080fd Mon Sep 17 00:00:00 2001 From: Zach White Date: Sun, 27 Jun 2021 20:41:59 -0700 Subject: [PATCH 12/37] fix an erroneous message --- lib/python/qmk/info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index e7c5ba598ebb..26aba199461e 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -345,7 +345,7 @@ def _extract_matrix_info(info_data, config_c): } if row_pins and col_pins: - if 'matrix_pins' in info_data: + if 'matrix_pins' in info_data and 'cols' in info_data['matrix_pins'] and 'rows' in info_data['matrix_pins']: _log_warning(info_data, 'Matrix pins are specified in both info.json and config.h, the config.h values win.') info_data['matrix_pins'] = { @@ -354,7 +354,7 @@ def _extract_matrix_info(info_data, config_c): } if direct_pins: - if 'matrix_pins' in info_data: + if 'matrix_pins' in info_data and 'direct' in info_data['matrix_pins']: _log_warning(info_data, 'Direct pins are specified in both info.json and config.h, the config.h values win.') info_data['matrix_pins']['direct'] = _extract_direct_matrix(info_data, direct_pins) From 53562040bdd0deb1075c6c38eeb7daee141d5702 Mon Sep 17 00:00:00 2001 From: Zach White Date: Sun, 27 Jun 2021 20:54:15 -0700 Subject: [PATCH 13/37] rework split.usb_detect --- data/mappings/info_config.json | 4 +++- data/schemas/keyboard.jsonschema | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/data/mappings/info_config.json b/data/mappings/info_config.json index 32619ea35c50..216a610dad9e 100644 --- a/data/mappings/info_config.json +++ b/data/mappings/info_config.json @@ -66,7 +66,9 @@ "QMK_SPEAKER": {"info_key": "qmk_lufa_bootloader.speaker"}, "SPLIT_MODS_ENABLE": {"info_key": "split.transport.mods", "value_type": "bool"}, "SPLIT_TRANSPORT_MIRROR": {"info_key": "split.transport.mirror", "value_type": "bool"}, - "SPLIT_USB_DETECT": {"info_key": "split.usb_detect", "value_type": "bool"}, + "SPLIT_USB_DETECT": {"info_key": "split.usb_detect.enabled", "value_type": "bool"}, + "SPLIT_USB_TIMEOUT": {"info_key": "split.usb_detect.timeout", "value_type": "int"}, + "SPLIT_USB_TIMEOUT_POLL": {"info_key": "split.usb_detect.polling_interval", "value_type": "int"}, "SOFT_SERIAL_PIN": {"info_key": "split.soft_serial_pin"}, "SOFT_SERIAL_SPEED": {"info_key": "split.soft_serial_speed"}, "TAP_CODE_DELAY": {"info_key": "qmk.tap_keycode_delay", "value_type": "int"}, diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 732979b110d2..b8252e3d7007 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -227,7 +227,15 @@ "mods": {"type": "boolean"} } }, - "usb_detect": {"type": "boolean"}, + "usb_detect": { + "type": "object", + "additionalProperties": false, + "properties": { + "enabled": {"type": "boolean"}, + "polling_interval": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"} + } + } } }, "tags": { From 0fe118e35c55a8593f679023393c698563d1ba1d Mon Sep 17 00:00:00 2001 From: Zach White Date: Sun, 27 Jun 2021 21:04:12 -0700 Subject: [PATCH 14/37] adding missing rgblight vars to info.json --- data/mappings/info_config.json | 5 +++++ data/schemas/keyboard.jsonschema | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/data/mappings/info_config.json b/data/mappings/info_config.json index 216a610dad9e..c209473f8701 100644 --- a/data/mappings/info_config.json +++ b/data/mappings/info_config.json @@ -50,12 +50,17 @@ "RGBLIGHT_EFFECT_SNAKE": {"info_key": "rgblight.animations.snake", "value_type": "bool"}, "RGBLIGHT_EFFECT_STATIC_GRADIENT": {"info_key": "rgblight.animations.static_gradient", "value_type": "bool"}, "RGBLIGHT_EFFECT_TWINKLE": {"info_key": "rgblight.animations.twinkle"}, + "RGBLIGHT_LAYER_BLINK": {"info_key": "rgblight.layers.blink", "value_type": "bool"}, + "RGBLIGHT_LAYERS": {"info_key": "rgblight.layers.enabled", "value_type": "bool"}, + "RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF": {"info_key": "rgblight.layers.override_rgb", "value_type": "bool"}, "RGBLIGHT_LIMIT_VAL": {"info_key": "rgblight.max_brightness", "value_type": "int"}, + "RGBLIGHT_MAX_LAYERS": {"info_key": "rgblight.layers.max", "value_type": "int"}, "RGBLIGHT_HUE_STEP": {"info_key": "rgblight.hue_steps", "value_type": "int"}, "RGBLIGHT_SAT_STEP": {"info_key": "rgblight.saturation_steps", "value_type": "int"}, "RGBLIGHT_VAL_STEP": {"info_key": "rgblight.brightness_steps", "value_type": "int"}, "RGBLIGHT_SLEEP": {"info_key": "rgblight.sleep", "value_type": "bool"}, "RGBLIGHT_SPLIT": {"info_key": "rgblight.split", "value_type": "bool"}, + "RGBW": {"info_key": "rgblight.rgbw", "value_type": "bool"}, "PRODUCT": {"info_key": "keyboard_folder", "to_json": false}, "PRODUCT_ID": {"info_key": "usb.pid", "value_type": "hex"}, "VENDOR_ID": {"info_key": "usb.vid", "value_type": "hex"}, diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index b8252e3d7007..f11d8f5dce8f 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -162,9 +162,25 @@ }, "brightness_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, "hue_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "layers": { + "type": "object", + "additionalProperties": false, + "properties": { + "blink": {"type": "boolean"}, + "enabled": {"type": "boolean"}, + "max": { + "type": "number", + "min": 1, + "max": 32, + "multipleOf": 1 + }, + "override_rgb": {"type": "boolean"} + } + }, "led_count": {"$ref": "qmk.definitions.v1#/unsigned_int"}, "max_brightness": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, "pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, + "rgbw": {"type": "boolean"}, "saturation_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, "sleep": {"type": "boolean"}, "split": {"type": "boolean"}, From 605e23a250562f17bb4b8d5ea924ae2847faa6d0 Mon Sep 17 00:00:00 2001 From: Zach White Date: Sun, 27 Jun 2021 21:10:39 -0700 Subject: [PATCH 15/37] add mouse_key to info.json --- data/mappings/info_config.json | 5 +++++ data/mappings/info_rules.json | 3 ++- data/schemas/keyboard.jsonschema | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/data/mappings/info_config.json b/data/mappings/info_config.json index c209473f8701..5a75216a2356 100644 --- a/data/mappings/info_config.json +++ b/data/mappings/info_config.json @@ -30,6 +30,11 @@ "MANUFACTURER": {"info_key": "manufacturer"}, "MATRIX_HAS_GHOST": {"info_key": "matrix_pins.ghost", "value_type": "bool"}, "MATRIX_IO_DELAY": {"info_key": "matrix_pins.io_delay", "value_type": "int"}, + "MOUSEKEY_DELAY": {"info_key": "mousekey.delay", "value_type": "int"}, + "MOUSEKEY_INTERVAL": {"info_key": "mousekey.interval", "value_type": "int"}, + "MOUSEKEY_MAX_SPEED": {"info_key": "mousekey.max_speed", "value_type": "int"}, + "MOUSEKEY_TIME_TO_MAX": {"info_key": "mousekey.time_to_max", "value_type": "int"}, + "MOUSEKEY_WHEEL_DELAY": {"info_key": "mousekey.wheel_delay", "value_type": "int"}, "ONESHOT_TIMEOUT": {"info_key": "oneshot.timeout", "value_type": "int"}, "ONESHOT_TAP_TOGGLE": {"info_key": "oneshot.tap_toggle", "value_type": "int"}, "PERMISSIVE_HOLD": {"info_key": "tapping.permissive_hold", "value_type": "bool"}, diff --git a/data/mappings/info_rules.json b/data/mappings/info_rules.json index 4845696d5bcd..e018a797d94f 100644 --- a/data/mappings/info_rules.json +++ b/data/mappings/info_rules.json @@ -1,4 +1,4 @@ -# This file maps keys between `rules.mk` and `info.json`. It is used by QMK +# This file maps keys between `rules.mk` and `info.json`. It is used by QMK # to correctly and consistently map back and forth between the two systems. { # Format: @@ -12,6 +12,7 @@ "LAYOUTS": {"info_key": "community_layouts", "value_type": "list"}, "LED_MATRIX_DRIVER": {"info_key": "led_matrix.driver"}, "MCU": {"info_key": "processor", "warn_duplicate": false}, + "MOUSEKEY_ENABLE": {"info_key": "mouse_key.enabled", "value_type": "bool"}, "SPLIT_KEYBOARD": {"info_key": "split.enabled", "value_type": "bool"}, "SPLIT_TRANSPORT": {"info_key": "split.transport.protocol", "value_type": "str", "to_c": false} } diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index f11d8f5dce8f..37eda310a7e0 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -143,6 +143,17 @@ "unused": {"$ref": "qmk.definitions.v1#/mcu_pin_array"} } }, + "mouse_key": { + "type": "object", + "properties": { + "enabled": {"type": "boolean"}, + "delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"} + "interval": {"$ref": "qmk.definitions.v1#/unsigned_int_8"} + "max_speed": {"$ref": "qmk.definitions.v1#/unsigned_int_8"} + "time_to_max": {"$ref": "qmk.definitions.v1#/unsigned_int_8"} + "wheel_delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"} + } + }, "oneshot": { "type": "object", "properties": { From a969a809b93b365e2acc25f9bb72306ba6965bae Mon Sep 17 00:00:00 2001 From: Zach White Date: Sun, 27 Jun 2021 21:50:57 -0700 Subject: [PATCH 16/37] add all remaining options from docs/config_options.md --- data/mappings/info_rules.json | 9 +++++- data/schemas/keyboard.jsonschema | 42 +++++++++++++++++++++++-- lib/python/qmk/cli/generate/rules_mk.py | 7 +++++ lib/python/qmk/info.py | 9 ++++++ 4 files changed, 64 insertions(+), 3 deletions(-) diff --git a/data/mappings/info_rules.json b/data/mappings/info_rules.json index e018a797d94f..aea67e04c846 100644 --- a/data/mappings/info_rules.json +++ b/data/mappings/info_rules.json @@ -9,10 +9,17 @@ # warn_duplicate: Default `true`. Set to `false` to turn off warning when a value exists in both places "BOARD": {"info_key": "board"}, "BOOTLOADER": {"info_key": "bootloader", "warn_duplicate": false}, + "BLUETOOTH": {"info_key": "bluetooth.driver"}, + "FIRMWARE_FORMAT": {"info_key": "build.firmware_format"}, + "KEYBOARD_SHARED_EP": {"info_key": "usb.shared_endpoint.keyboard", "value_type": "bool"}, + "MOUSE_SHARED_EP": {"info_key": "usb.shared_endpoint.mouse", "value_type": "bool"}, "LAYOUTS": {"info_key": "community_layouts", "value_type": "list"}, "LED_MATRIX_DRIVER": {"info_key": "led_matrix.driver"}, + "LTO_ENABLE": {"info_key": "build.lto", "value_type": "bool"}, "MCU": {"info_key": "processor", "warn_duplicate": false}, "MOUSEKEY_ENABLE": {"info_key": "mouse_key.enabled", "value_type": "bool"}, + "NO_USB_STARTUP_CHECK": {"info_key": "usb.no_startup_check", "value_type": "bool"}, "SPLIT_KEYBOARD": {"info_key": "split.enabled", "value_type": "bool"}, - "SPLIT_TRANSPORT": {"info_key": "split.transport.protocol", "value_type": "str", "to_c": false} + "SPLIT_TRANSPORT": {"info_key": "split.transport.protocol", "value_type": "str", "to_c": false}, + "WAIT_FOR_USB": {"info_key": "usb.wait_for", "value_type": "bool"} } diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 37eda310a7e0..28b0cbc03711 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -38,6 +38,17 @@ "pin": {"$ref": "qmk.definitions.v1#/mcu_pin"} } }, + "bluetooth": { + "type": "object", + "additionalProperties": false, + "properties": { + "driver": { + "type": "string", + "enum": ["AdafruitBLE", "RN42"] + }, + "lto": {"type": "boolean"}, + } + }, "board": { "type": "string", "minLength": 2, @@ -45,7 +56,22 @@ }, "bootloader": { "type": "string", - "enum": ["atmel-dfu", "bootloadHID", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "micronucleus", "qmk-dfu", "qmk-hid", "stm32-dfu", "stm32duino", "unknown", "USBasp", "tinyuf2"] + "enum": ["atmel-dfu", "bootloadHID", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "micronucleus", "qmk-dfu", "qmk-hid", "stm32-dfu", "stm32duino", "unknown", "USBasp", "tinyuf2"], + }, + "build": { + "type": "object", + "additionalProperties": false, + "properties": { + "debounce_type": { + "type": "string", + "enum": ["custom", "eager_pk", "eager_pr", "sym_defer_pk", "sym_eager_pk"] + }, + "firmware_format": { + "type": "string", + "enum": ["bin", "hex", "uf2"] + }, + "lto": {"type": "boolean"}, + } }, "diode_direction": { "type": "string", @@ -132,6 +158,8 @@ "type": "object", "additionalProperties": false, "properties": { + "custom": {"type": "boolean"}, + "custom_lite": {"type": "boolean"}, "ghost": {"type": "boolean"}, "io_delay": {"$ref": "qmk.definitions.v1#/unsigned_int"}, "direct": { @@ -293,8 +321,18 @@ "pid": {"$ref": "qmk.definitions.v1#/hex_number_4d"}, "vid": {"$ref": "qmk.definitions.v1#/hex_number_4d"}, "max_power": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, + "no_startup_check": {"type": "boolean"}, "polling_interval": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, - "suspend_wakeup_delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"} + "shared_endpoint": { + "type": "object", + "additionalProperties": false, + "properties": { + "keyboard": {"type": "boolean"}, + "mouse": {"type": "boolean"} + } + }, + "suspend_wakeup_delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, + "wait_for": {"type": "boolean"}, } }, "qmk": { diff --git a/lib/python/qmk/cli/generate/rules_mk.py b/lib/python/qmk/cli/generate/rules_mk.py index 70d0663c8d1e..2712b81cb576 100755 --- a/lib/python/qmk/cli/generate/rules_mk.py +++ b/lib/python/qmk/cli/generate/rules_mk.py @@ -80,6 +80,13 @@ def generate_rules_mk(cli): if kb_info_json.get('split', {}).get('transport', {}).get('protocol') == 'custom': rules_mk_lines.append('SPLIT_TRANSPORT ?= custom') + # Set CUSTOM_MATRIX, if needed + if kb_info_json.get('matrix_pins', {}).get('custom'): + if kb_info_json.get('matrix_pins', {}).get('custom_lite'): + rules_mk_lines.append('CUSTOM_MATRIX ?= lite') + else: + rules_mk_lines.append('CUSTOM_MATRIX ?= yes') + # Show the results rules_mk = '\n'.join(rules_mk_lines) + '\n' diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 26aba199461e..575c14f81452 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -365,6 +365,15 @@ def _extract_matrix_info(info_data, config_c): info_data['matrix_pins']['unused'] = _extract_pins(unused_pins) + if config_c.get('CUSTOM_MATRIX', 'no') != 'no': + if 'matrix_pins' in info_data and 'custom' in info_data['matrix_pins']: + _log_warning(info_data, 'Custom Matrix is specified in both info.json and config.h, the config.h values win.') + + info_data['matrix_pins']['custom'] = True + + if config_c['CUSTOM_MATRIX'] == 'lite': + info_data['matrix_pins']['custom_lite'] = True + return info_data From e7a5922e9760f617a6b3fcbc414b759dda0f9fad Mon Sep 17 00:00:00 2001 From: Zach White Date: Sun, 27 Jun 2021 22:00:30 -0700 Subject: [PATCH 17/37] fix audio voices --- data/mappings/info_config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/mappings/info_config.json b/data/mappings/info_config.json index 5a75216a2356..49abb0c98c18 100644 --- a/data/mappings/info_config.json +++ b/data/mappings/info_config.json @@ -7,7 +7,7 @@ # to_json: Default `true`. Set to `false` to exclude this mapping from info.json # to_c: Default `true`. Set to `false` to exclude this mapping from config.h # warn_duplicate: Default `true`. Set to `false` to turn off warning when a value exists in both places - "AUDIO_VOICES": {"info_key": "matrix_pins.ghost", "value_type": "bool"}, + "AUDIO_VOICES": {"info_key": "audio.voices", "value_type": "bool"}, "BACKLIGHT_BREATHING": {"info_key": "backlight.breathing", "value_type": "bool"}, "BREATHING_PERIOD": {"info_key": "backlight.breathing_period", "value_type": "int"}, "BACKLIGHT_PIN": {"info_key": "backlight.pin"}, From 3f6e62bc2f6242cdb3441b62934221295a35b83f Mon Sep 17 00:00:00 2001 From: Zach White Date: Sat, 26 Jun 2021 16:45:53 -0700 Subject: [PATCH 18/37] qmk info: Change text output to use dotted notation --- lib/python/qmk/cli/info.py | 41 ++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/lib/python/qmk/cli/info.py b/lib/python/qmk/cli/info.py index 337b494a99f9..12788503b8ad 100755 --- a/lib/python/qmk/cli/info.py +++ b/lib/python/qmk/cli/info.py @@ -93,15 +93,6 @@ def print_friendly_output(kb_info_json): aliases = [f'{key}={value}' for key, value in kb_info_json['layout_aliases'].items()] cli.echo('{fg_blue}Layout aliases:{fg_reset} %s' % (', '.join(aliases),)) - if cli.config.info.layouts: - show_layouts(kb_info_json, True) - - if cli.config.info.matrix: - show_matrix(kb_info_json, True) - - if cli.config_source.info.keymap and cli.config_source.info.keymap != 'config_file': - show_keymap(kb_info_json, True) - def print_text_output(kb_info_json): """Print the info.json in a plain text format. @@ -122,6 +113,24 @@ def print_text_output(kb_info_json): show_keymap(kb_info_json, False) +def print_dotted_output(kb_info_json, prefix=''): + """Print the info.json in a plain text format with dot-joined keys. + """ + for key in sorted(kb_info_json): + new_prefix = f'{prefix}.{key}' if prefix else key + + if key in ['parse_errors', 'parse_warnings']: + continue + elif key == 'layouts' and prefix == '': + cli.echo('{fg_blue}layouts{fg_reset}: %s', ', '.join(sorted(kb_info_json['layouts'].keys()))) + elif isinstance(kb_info_json[key], dict): + print_dotted_output(kb_info_json[key], new_prefix) + elif isinstance(kb_info_json[key], list): + cli.echo('{fg_blue}%s{fg_reset}: %s', new_prefix, ', '.join(sorted(kb_info_json[key]))) + else: + cli.echo('{fg_blue}%s{fg_reset}: %s', new_prefix, kb_info_json[key]) + + def print_parsed_rules_mk(keyboard_name): rules = rules_mk(keyboard_name) for k in sorted(rules.keys()): @@ -162,10 +171,22 @@ def info(cli): # Output in the requested format if cli.args.format == 'json': print(json.dumps(kb_info_json, cls=InfoJSONEncoder)) + return True elif cli.args.format == 'text': - print_text_output(kb_info_json) + print_dotted_output(kb_info_json) + title_caps = False elif cli.args.format == 'friendly': print_friendly_output(kb_info_json) + title_caps = True else: cli.log.error('Unknown format: %s', cli.args.format) return False + + if cli.config.info.layouts: + show_layouts(kb_info_json, title_caps) + + if cli.config.info.matrix: + show_matrix(kb_info_json, title_caps) + + if cli.config_source.info.keymap and cli.config_source.info.keymap != 'config_file': + show_keymap(kb_info_json, title_caps) From 9cca69dc397d2d24ecdb8cf89280aee12c20791b Mon Sep 17 00:00:00 2001 From: Zach White Date: Mon, 28 Jun 2021 09:35:05 -0700 Subject: [PATCH 19/37] tweak layout output --- lib/python/qmk/cli/info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/python/qmk/cli/info.py b/lib/python/qmk/cli/info.py index 12788503b8ad..7639aef4a8a0 100755 --- a/lib/python/qmk/cli/info.py +++ b/lib/python/qmk/cli/info.py @@ -27,7 +27,7 @@ def show_keymap(kb_info_json, title_caps=True): if title_caps: cli.echo('{fg_blue}Keymap "%s"{fg_reset}:', cli.config.info.keymap) else: - cli.echo('{fg_blue}keymap_%s{fg_reset}:', cli.config.info.keymap) + cli.echo('{fg_blue}keymap.%s{fg_reset}:', cli.config.info.keymap) keymap_data = json.load(keymap_path.open(encoding='utf-8')) layout_name = keymap_data['layout'] @@ -45,7 +45,7 @@ def show_layouts(kb_info_json, title_caps=True): """Render the layouts with info.json labels. """ for layout_name, layout_art in render_layouts(kb_info_json, cli.config.info.ascii).items(): - title = layout_name.title() if title_caps else layout_name + title = f'Layout {layout_name.title()}' if title_caps else f'layouts.{layout_name}' cli.echo('{fg_cyan}%s{fg_reset}:', title) print(layout_art) # Avoid passing dirty data to cli.echo() From 0845e3f7897eb7d736c98580c729513c4e859f6f Mon Sep 17 00:00:00 2001 From: Zach White Date: Mon, 28 Jun 2021 09:42:59 -0700 Subject: [PATCH 20/37] resolve alias names --- lib/python/qmk/cli/info.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/python/qmk/cli/info.py b/lib/python/qmk/cli/info.py index 7639aef4a8a0..cf8dc7396d91 100755 --- a/lib/python/qmk/cli/info.py +++ b/lib/python/qmk/cli/info.py @@ -24,19 +24,15 @@ def show_keymap(kb_info_json, title_caps=True): keymap_path = locate_keymap(cli.config.info.keyboard, cli.config.info.keymap) if keymap_path and keymap_path.suffix == '.json': - if title_caps: - cli.echo('{fg_blue}Keymap "%s"{fg_reset}:', cli.config.info.keymap) - else: - cli.echo('{fg_blue}keymap.%s{fg_reset}:', cli.config.info.keymap) - keymap_data = json.load(keymap_path.open(encoding='utf-8')) layout_name = keymap_data['layout'] + layout_name = kb_info_json.get('layout_aliases', {}).get(layout_name, layout_name) # Resolve alias names for layer_num, layer in enumerate(keymap_data['layers']): if title_caps: - cli.echo('{fg_cyan}Layer %s{fg_reset}:', layer_num) + cli.echo('{fg_cyan}Keymap %s Layer %s{fg_reset}:', cli.config.info.keymap, layer_num) else: - cli.echo('{fg_cyan}layer_%s{fg_reset}:', layer_num) + cli.echo('{fg_cyan}keymap.%s.layer.%s{fg_reset}:', cli.config.info.keymap, layer_num) print(render_layout(kb_info_json['layouts'][layout_name]['layout'], cli.config.info.ascii, layer)) From 089c94fb82d3b4356b30358eda04070b23bc3976 Mon Sep 17 00:00:00 2001 From: Zach White Date: Sun, 11 Jul 2021 09:32:35 -0700 Subject: [PATCH 21/37] break out some functions to make flake8 happy --- lib/python/qmk/cli/generate/config_h.py | 128 +++++++++++++----------- lib/python/qmk/cli/info.py | 2 +- lib/python/qmk/info.py | 10 +- 3 files changed, 78 insertions(+), 62 deletions(-) diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py index ad0b5995cd26..c0c148f1c059 100755 --- a/lib/python/qmk/cli/generate/config_h.py +++ b/lib/python/qmk/cli/generate/config_h.py @@ -73,32 +73,11 @@ def matrix_pins(matrix_pins, postfix=''): return '\n'.join(pins) -@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to') -@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") -@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='Keyboard to generate config.h for.') -@cli.subcommand('Used by the make system to generate info_config.h from info.json', hidden=True) -@automagic_keyboard -@automagic_keymap -def generate_config_h(cli): - """Generates the info_config.h file. +def generate_config_items(kb_info_json, config_h_lines): + """Iterate through the info_config map to generate basic config values. """ - # Determine our keyboard(s) - if not cli.config.generate_config_h.keyboard: - cli.log.error('Missing parameter: --keyboard') - cli.subcommands['info'].print_help() - return False - - if not is_keyboard(cli.config.generate_config_h.keyboard): - cli.log.error('Invalid keyboard: "%s"', cli.config.generate_config_h.keyboard) - return False - - # Build the info_config.h file. - kb_info_json = dotty(info_json(cli.config.generate_config_h.keyboard)) info_config_map = json_load(Path('data/mappings/info_config.json')) - config_h_lines = ['/* This file was generated by `qmk generate-config-h`. Do not edit or copy.' ' */', '', '#pragma once'] - - # Iterate through the info_config map to generate basic things for config_key, info_dict in info_config_map.items(): info_key = info_dict['info_key'] key_type = info_dict.get('value_type', 'str') @@ -135,46 +114,77 @@ def generate_config_h(cli): config_h_lines.append(f'# define {config_key} {config_value}') config_h_lines.append(f'#endif // {config_key}') + +def generate_split_config(kb_info_json, config_h_lines): + """Generate the config.h lines for split boards.""" + if 'primary' in kb_info_json['split']: + if kb_info_json['split']['primary'] in ('left', 'right'): + config_h_lines.append('') + config_h_lines.append('#ifndef MASTER_LEFT') + config_h_lines.append('# ifndef MASTER_RIGHT') + if kb_info_json['split']['primary'] == 'left': + config_h_lines.append('# define MASTER_LEFT') + elif kb_info_json['split']['primary'] == 'right': + config_h_lines.append('# define MASTER_RIGHT') + config_h_lines.append('# endif // MASTER_RIGHT') + config_h_lines.append('#endif // MASTER_LEFT') + elif kb_info_json['split']['primary'] == 'pin': + config_h_lines.append('') + config_h_lines.append('#ifndef SPLIT_HAND_PIN') + config_h_lines.append('# define SPLIT_HAND_PIN') + config_h_lines.append('#endif // SPLIT_HAND_PIN') + elif kb_info_json['split']['primary'] == 'matrix_grid': + config_h_lines.append('') + config_h_lines.append('#ifndef SPLIT_HAND_MATRIX_GRID') + config_h_lines.append('# define SPLIT_HAND_MATRIX_GRID {%s}' % (','.join(kb_info_json["split"]["matrix_grid"],))) + config_h_lines.append('#endif // SPLIT_HAND_MATRIX_GRID') + elif kb_info_json['split']['primary'] == 'eeprom': + config_h_lines.append('') + config_h_lines.append('#ifndef EE_HANDS') + config_h_lines.append('# define EE_HANDS') + config_h_lines.append('#endif // EE_HANDS') + + if 'protocol' in kb_info_json['split'].get('transport', {}): + if kb_info_json['split']['transport']['protocol'] == 'i2c': + config_h_lines.append('') + config_h_lines.append('#ifndef USE_I2C') + config_h_lines.append('# define USE_I2C') + config_h_lines.append('#endif // USE_I2C') + + if 'right' in kb_info_json['split'].get('matrix_pins', {}): + config_h_lines.append(matrix_pins(kb_info_json['split']['matrix_pins']['right'], '_RIGHT')) + + +@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to') +@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") +@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='Keyboard to generate config.h for.') +@cli.subcommand('Used by the make system to generate info_config.h from info.json', hidden=True) +@automagic_keyboard +@automagic_keymap +def generate_config_h(cli): + """Generates the info_config.h file. + """ + # Determine our keyboard(s) + if not cli.config.generate_config_h.keyboard: + cli.log.error('Missing parameter: --keyboard') + cli.subcommands['info'].print_help() + return False + + if not is_keyboard(cli.config.generate_config_h.keyboard): + cli.log.error('Invalid keyboard: "%s"', cli.config.generate_config_h.keyboard) + return False + + # Build the info_config.h file. + kb_info_json = dotty(info_json(cli.config.generate_config_h.keyboard)) + config_h_lines = ['/* This file was generated by `qmk generate-config-h`. Do not edit or copy.' ' */', '', '#pragma once'] + + generate_config_items(kb_info_json, config_h_lines) + if 'matrix_pins' in kb_info_json: config_h_lines.append(matrix_pins(kb_info_json['matrix_pins'])) if 'split' in kb_info_json: - if 'primary' in kb_info_json['split']: - if kb_info_json['split']['primary'] in ('left', 'right'): - config_h_lines.append('') - config_h_lines.append('#ifndef MASTER_LEFT') - config_h_lines.append('# ifndef MASTER_RIGHT') - if kb_info_json['split']['primary'] == 'left': - config_h_lines.append('# define MASTER_LEFT') - elif kb_info_json['split']['primary'] == 'right': - config_h_lines.append('# define MASTER_RIGHT') - config_h_lines.append('# endif // MASTER_RIGHT') - config_h_lines.append('#endif // MASTER_LEFT') - elif kb_info_json['split']['primary'] == 'pin': - config_h_lines.append('') - config_h_lines.append('#ifndef SPLIT_HAND_PIN') - config_h_lines.append('# define SPLIT_HAND_PIN') - config_h_lines.append('#endif // SPLIT_HAND_PIN') - elif kb_info_json['split']['primary'] == 'matrix_grid': - config_h_lines.append('') - config_h_lines.append('#ifndef SPLIT_HAND_MATRIX_GRID') - config_h_lines.append('# define SPLIT_HAND_MATRIX_GRID {%s}' % (','.join(kb_info_json["split"]["matrix_grid"],))) - config_h_lines.append('#endif // SPLIT_HAND_MATRIX_GRID') - elif kb_info_json['split']['primary'] == 'eeprom': - config_h_lines.append('') - config_h_lines.append('#ifndef EE_HANDS') - config_h_lines.append('# define EE_HANDS') - config_h_lines.append('#endif // EE_HANDS') - - if 'protocol' in kb_info_json['split'].get('transport', {}): - if kb_info_json['split']['transport']['protocol'] == 'i2c': - config_h_lines.append('') - config_h_lines.append('#ifndef USE_I2C') - config_h_lines.append('# define USE_I2C') - config_h_lines.append('#endif // USE_I2C') - - if 'right' in kb_info_json['split'].get('matrix_pins', {}): - config_h_lines.append(matrix_pins(kb_info_json['split']['matrix_pins']['right'], '_RIGHT')) + generate_split_config(kb_info_json, config_h_lines) # Show the results config_h = '\n'.join(config_h_lines) diff --git a/lib/python/qmk/cli/info.py b/lib/python/qmk/cli/info.py index cf8dc7396d91..3131d4b53f9f 100755 --- a/lib/python/qmk/cli/info.py +++ b/lib/python/qmk/cli/info.py @@ -122,7 +122,7 @@ def print_dotted_output(kb_info_json, prefix=''): elif isinstance(kb_info_json[key], dict): print_dotted_output(kb_info_json[key], new_prefix) elif isinstance(kb_info_json[key], list): - cli.echo('{fg_blue}%s{fg_reset}: %s', new_prefix, ', '.join(sorted(kb_info_json[key]))) + cli.echo('{fg_blue}%s{fg_reset}: %s', new_prefix, ', '.join(map(str, sorted(kb_info_json[key])))) else: cli.echo('{fg_blue}%s{fg_reset}: %s', new_prefix, kb_info_json[key]) diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 575c14f81452..6fda9b8da531 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -201,7 +201,7 @@ def _extract_audio(info_data, config_c): info_data['audio'] = {'pins': audio_pins} -def _extract_split(info_data, config_c): +def _extract_split_primary(info_data, config_c): """Populate data about the split configuration """ # Figure out how the primary half is determined @@ -251,6 +251,8 @@ def _extract_split(info_data, config_c): info_data['split']['primary'] = 'left' + +def _extract_split_transport(info_data, config_c): # Figure out the transport method if config_c.get('USE_I2C') is True: if 'split' not in info_data: @@ -273,6 +275,8 @@ def _extract_split(info_data, config_c): info_data['split']['transport']['protocol'] = 'serial' + +def _extract_split_right_pins(info_data, config_c): # Figure out the right half matrix pins row_pins = config_c.get('MATRIX_ROW_PINS_RIGHT', '').replace('{', '').replace('}', '').strip() col_pins = config_c.get('MATRIX_COL_PINS_RIGHT', '').replace('{', '').replace('}', '').strip() @@ -431,7 +435,9 @@ def _extract_config_h(info_data): # Pull data that easily can't be mapped in json _extract_matrix_info(info_data, config_c) _extract_audio(info_data, config_c) - _extract_split(info_data, config_c) + _extract_split_primary(info_data, config_c) + _extract_split_transport(info_data, config_c) + _extract_split_right_pins(info_data, config_c) return info_data From 173117d6c1580c63b4419522bef4a42e70c81314 Mon Sep 17 00:00:00 2001 From: Zach White Date: Sun, 11 Jul 2021 09:39:58 -0700 Subject: [PATCH 22/37] add a field for bootloader instructions --- data/schemas/keyboard.jsonschema | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 28b0cbc03711..2ca548bb4ddd 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -58,6 +58,10 @@ "type": "string", "enum": ["atmel-dfu", "bootloadHID", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "micronucleus", "qmk-dfu", "qmk-hid", "stm32-dfu", "stm32duino", "unknown", "USBasp", "tinyuf2"], }, + "bootloader_instructions": { + "type": "string", + "description": "Instructions for putting the keyboard into a mode that allows for firmware flashing." + }, "build": { "type": "object", "additionalProperties": false, From 6eb427e57b0994703a2899534b86d33cd36527e0 Mon Sep 17 00:00:00 2001 From: James Young <18669334+noroadsleft@users.noreply.github.com> Date: Mon, 28 Jun 2021 12:37:05 -0700 Subject: [PATCH 23/37] qmk generate-info-json: add a write-to-file argument Adds an argument that instructs qmk generate-info-json to write the output to a file instead of just to the terminal. --- lib/python/qmk/cli/generate/info_json.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/python/qmk/cli/generate/info_json.py b/lib/python/qmk/cli/generate/info_json.py index 30bb9b6ae44b..4e7b6685555e 100755 --- a/lib/python/qmk/cli/generate/info_json.py +++ b/lib/python/qmk/cli/generate/info_json.py @@ -6,6 +6,7 @@ from jsonschema import Draft7Validator, validators from milc import cli +from pathlib import Path from qmk.decorators import automagic_keyboard, automagic_keymap from qmk.info import info_json @@ -43,6 +44,7 @@ def strip_info_json(kb_info_json): @cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='Keyboard to show info for.') @cli.argument('-km', '--keymap', help='Show the layers for a JSON keymap too.') +@cli.argument('-o', '--output', arg_only=True, help='Write the output to a file.') @cli.subcommand('Generate an info.json file for a keyboard.', hidden=False if cli.config.user.developer else True) @automagic_keyboard @automagic_keymap @@ -65,3 +67,11 @@ def generate_info_json(cli): # Display the results print(json.dumps(kb_info_json, indent=2, cls=InfoJSONEncoder)) + + # Write to a file if --output flag was specified + if cli.args.output: + output_path = Path('keyboards') / cli.config.generate_info_json.keyboard / 'info.json' + with open(output_path, 'w+') as json_file: + json_object = json.dumps(kb_info_json, indent=4, cls=InfoJSONEncoder) + json_file.write(json_object) + cli.log.info('Wrote file to %s.', output_path) From 1241228e38567c515560e4631fdf7014b772f258 Mon Sep 17 00:00:00 2001 From: James Young <18669334+noroadsleft@users.noreply.github.com> Date: Mon, 28 Jun 2021 14:13:58 -0700 Subject: [PATCH 24/37] -arg_only, +action Because it was never my intention that one would have to specify a value for the argument that enables writing the file. --- lib/python/qmk/cli/generate/info_json.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/python/qmk/cli/generate/info_json.py b/lib/python/qmk/cli/generate/info_json.py index 4e7b6685555e..7fc41c8c1a18 100755 --- a/lib/python/qmk/cli/generate/info_json.py +++ b/lib/python/qmk/cli/generate/info_json.py @@ -44,7 +44,7 @@ def strip_info_json(kb_info_json): @cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='Keyboard to show info for.') @cli.argument('-km', '--keymap', help='Show the layers for a JSON keymap too.') -@cli.argument('-o', '--output', arg_only=True, help='Write the output to a file.') +@cli.argument('-o', '--output', action='store_true', help='Write the output to a file.') @cli.subcommand('Generate an info.json file for a keyboard.', hidden=False if cli.config.user.developer else True) @automagic_keyboard @automagic_keymap From 40dfdedb8893b86fc893cb2ac8249de6441d5f90 Mon Sep 17 00:00:00 2001 From: Zach White Date: Thu, 22 Jul 2021 21:30:36 -0700 Subject: [PATCH 25/37] Bring qmk generate-info-json inline with other generate commands --- lib/python/qmk/cli/generate/info_json.py | 46 ++++++++++++++++-------- lib/python/qmk/json_schema.py | 12 +++++-- 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/lib/python/qmk/cli/generate/info_json.py b/lib/python/qmk/cli/generate/info_json.py index 7fc41c8c1a18..24b5f7d4c367 100755 --- a/lib/python/qmk/cli/generate/info_json.py +++ b/lib/python/qmk/cli/generate/info_json.py @@ -4,16 +4,17 @@ """ import json -from jsonschema import Draft7Validator, validators +from argcomplete.completers import FilesCompleter +from jsonschema import Draft7Validator, RefResolver, validators from milc import cli from pathlib import Path from qmk.decorators import automagic_keyboard, automagic_keymap from qmk.info import info_json from qmk.json_encoders import InfoJSONEncoder -from qmk.json_schema import load_jsonschema +from qmk.json_schema import compile_schema_store, load_jsonschema from qmk.keyboard import keyboard_completer, keyboard_folder -from qmk.path import is_keyboard +from qmk.path import is_keyboard, normpath def pruning_validator(validator_class): @@ -35,16 +36,19 @@ def remove_additional_properties(validator, properties, instance, schema): def strip_info_json(kb_info_json): """Remove the API-only properties from the info.json. """ + schema_store = compile_schema_store() pruning_draft_7_validator = pruning_validator(Draft7Validator) - schema = load_jsonschema('qmk.keyboard.v1') - validator = pruning_draft_7_validator(schema).validate + schema = schema_store['qmk.keyboard.v1'] + resolver = RefResolver.from_schema(schema_store['qmk.keyboard.v1'], store=schema_store) + validator = pruning_draft_7_validator(schema, resolver=resolver).validate return validator(kb_info_json) @cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='Keyboard to show info for.') @cli.argument('-km', '--keymap', help='Show the layers for a JSON keymap too.') -@cli.argument('-o', '--output', action='store_true', help='Write the output to a file.') +@cli.argument('-o', '--output', arg_only=True, completer=FilesCompleter, help='Write the output the specified file, overwriting if necessary.') +@cli.argument('-ow', '--overwrite', arg_only=True, action='store_true', help='Overwrite the existing info.json. (Overrides the location of --output)') @cli.subcommand('Generate an info.json file for a keyboard.', hidden=False if cli.config.user.developer else True) @automagic_keyboard @automagic_keymap @@ -61,17 +65,29 @@ def generate_info_json(cli): cli.log.error('Invalid keyboard: "%s"', cli.config.generate_info_json.keyboard) return False + if cli.args.overwrite: + output_path = (Path('keyboards') / cli.config.generate_info_json.keyboard / 'info.json').resolve() + + if cli.args.output: + cli.log.warning('Overwriting user supplied --output with %s', output_path) + + cli.args.output = output_path + # Build the info.json file kb_info_json = info_json(cli.config.generate_info_json.keyboard) strip_info_json(kb_info_json) + info_json_text = json.dumps(kb_info_json, indent=4, cls=InfoJSONEncoder) - # Display the results - print(json.dumps(kb_info_json, indent=2, cls=InfoJSONEncoder)) - - # Write to a file if --output flag was specified if cli.args.output: - output_path = Path('keyboards') / cli.config.generate_info_json.keyboard / 'info.json' - with open(output_path, 'w+') as json_file: - json_object = json.dumps(kb_info_json, indent=4, cls=InfoJSONEncoder) - json_file.write(json_object) - cli.log.info('Wrote file to %s.', output_path) + # Write to a file + output_path = normpath(cli.args.output) + + if output_path.exists(): + cli.log.warning('Overwriting output file %s', output_path) + + output_path.write_text(info_json_text + '\n') + cli.log.info('Wrote info.json to %s.', output_path) + + else: + # Display the results + print(info_json_text) \ No newline at end of file diff --git a/lib/python/qmk/json_schema.py b/lib/python/qmk/json_schema.py index f73303f86fa0..ffc7c6bcd127 100644 --- a/lib/python/qmk/json_schema.py +++ b/lib/python/qmk/json_schema.py @@ -42,8 +42,8 @@ def load_jsonschema(schema_name): @lru_cache(maxsize=0) -def create_validator(schema): - """Creates a validator for the given schema id. +def compile_schema_store(): + """Compile all our schemas into a schema store. """ schema_store = {} @@ -54,6 +54,14 @@ def create_validator(schema): continue schema_store[schema_data['$id']] = schema_data + return schema_store + + +@lru_cache(maxsize=0) +def create_validator(schema): + """Creates a validator for the given schema id. + """ + schema_store = compile_schema_store() resolver = jsonschema.RefResolver.from_schema(schema_store['qmk.keyboard.v1'], store=schema_store) return jsonschema.Draft7Validator(schema_store[schema], resolver=resolver).validate From c00b00294e72e519bb2a9a7a8dd11c7bc9eff0b5 Mon Sep 17 00:00:00 2001 From: Zach White Date: Thu, 22 Jul 2021 21:35:08 -0700 Subject: [PATCH 26/37] pytest fixup --- lib/python/qmk/cli/generate/info_json.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/python/qmk/cli/generate/info_json.py b/lib/python/qmk/cli/generate/info_json.py index 24b5f7d4c367..284d1a851098 100755 --- a/lib/python/qmk/cli/generate/info_json.py +++ b/lib/python/qmk/cli/generate/info_json.py @@ -12,7 +12,7 @@ from qmk.decorators import automagic_keyboard, automagic_keymap from qmk.info import info_json from qmk.json_encoders import InfoJSONEncoder -from qmk.json_schema import compile_schema_store, load_jsonschema +from qmk.json_schema import compile_schema_store from qmk.keyboard import keyboard_completer, keyboard_folder from qmk.path import is_keyboard, normpath @@ -90,4 +90,4 @@ def generate_info_json(cli): else: # Display the results - print(info_json_text) \ No newline at end of file + print(info_json_text) From 87a4fdee2e6a49919d8da7725f87ea5d255b4e6e Mon Sep 17 00:00:00 2001 From: Zach White Date: Mon, 9 Aug 2021 16:01:45 -0700 Subject: [PATCH 27/37] fix esca/getawayvan --- keyboards/esca/getawayvan/config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/keyboards/esca/getawayvan/config.h b/keyboards/esca/getawayvan/config.h index e9fbc6b4047d..3b718c583596 100644 --- a/keyboards/esca/getawayvan/config.h +++ b/keyboards/esca/getawayvan/config.h @@ -35,7 +35,6 @@ along with this program. If not, see . #define MATRIX_ROW_PINS { A9, A8, A3, A5 } #define DIODE_DIRECTION COL2ROW -#define BACKLIGHT_PIN #define BACKLIGHT_LEVELS 6 #define GRAVE_ESC_CTRL_OVERRIDE From 6b4293f2abc7ea991cdbbcd2c4682ea7669c1469 Mon Sep 17 00:00:00 2001 From: Zach White Date: Mon, 9 Aug 2021 16:02:02 -0700 Subject: [PATCH 28/37] fix data driven errors for bpiphany converters --- keyboards/bpiphany/frosty_flake/config.h | 5 +++++ keyboards/bpiphany/tiger_lily/config.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/keyboards/bpiphany/frosty_flake/config.h b/keyboards/bpiphany/frosty_flake/config.h index 344db5f0d91e..74c771c8a9a2 100644 --- a/keyboards/bpiphany/frosty_flake/config.h +++ b/keyboards/bpiphany/frosty_flake/config.h @@ -40,7 +40,12 @@ along with this program. If not, see . /* * Keyboard Matrix Assignments + * + * MATRIX_ROW_PINS and MATRIX_COL_PINS aren't actually used and are included + * for data driven compatibility. */ +#define MATRIX_ROW_PINS { B0, B3, B2, B1, B6, B4, B5, C7 } +#define MATRIX_COL_PINS { NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN } #define UNUSED_PINS { C0, C1, C2, C3, C4, D2, D7 } /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ diff --git a/keyboards/bpiphany/tiger_lily/config.h b/keyboards/bpiphany/tiger_lily/config.h index a86cffd16b5d..d3e2464bee91 100644 --- a/keyboards/bpiphany/tiger_lily/config.h +++ b/keyboards/bpiphany/tiger_lily/config.h @@ -40,7 +40,12 @@ along with this program. If not, see . /* * Keyboard Matrix Assignments + * + * MATRIX_ROW_PINS and MATRIX_COL_PINS aren't actually used and are included + * for data driven compatibility. */ +#define MATRIX_ROW_PINS { C2, B3, B4, B2, B1, C7, B6, B5 } +#define MATRIX_COL_PINS { NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN } #define UNUSED_PINS { B0, C4, D3 } #define LED_NUM_LOCK_PIN C5 From 9f13125923cf93b3bf808ac59e48ac8fe7e49ba6 Mon Sep 17 00:00:00 2001 From: Zach White Date: Mon, 9 Aug 2021 16:05:32 -0700 Subject: [PATCH 29/37] features.force_nkro -> usb.force_nkro --- data/mappings/info_config.json | 2 +- data/schemas/keyboard.jsonschema | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/data/mappings/info_config.json b/data/mappings/info_config.json index 49abb0c98c18..d965a5a37094 100644 --- a/data/mappings/info_config.json +++ b/data/mappings/info_config.json @@ -17,7 +17,7 @@ "DEVICE_VER": {"info_key": "usb.device_ver", "value_type": "hex"}, "DESCRIPTION": {"info_key": "keyboard_folder", "to_json": false}, "DIODE_DIRECTION": {"info_key": "diode_direction"}, - "FORCE_NKRO": {"info_key": "features.force_nkro", "value_type": "bool"}, + "FORCE_NKRO": {"info_key": "usb.force_nkro", "value_type": "bool"}, "IGNORE_MOD_TAP_INTERRUPT": {"info_key": "tapping.ignore_mod_tap_interrupt", "value_type": "bool"}, "IGNORE_MOD_TAP_INTERRUPT_PER_KEY": {"info_key": "tapping.ignore_mod_tap_interrupt_per_key", "value_type": "bool"}, "LAYOUTS": {"info_key": "layout_aliases", "value_type": "mapping"}, diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 2ca548bb4ddd..4cf8876d7bf8 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -322,6 +322,7 @@ "additionalProperties": false, "properties": { "device_ver": {"$ref": "qmk.definitions.v1#/hex_number_4d"}, + "force_nkro": {"type": "boolean"}, "pid": {"$ref": "qmk.definitions.v1#/hex_number_4d"}, "vid": {"$ref": "qmk.definitions.v1#/hex_number_4d"}, "max_power": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, From 26c3ab3bb0db219f38edcbcec69d97e37bc5c8b6 Mon Sep 17 00:00:00 2001 From: Zach White Date: Mon, 9 Aug 2021 16:08:02 -0700 Subject: [PATCH 30/37] split.primary->split.main --- data/schemas/keyboard.jsonschema | 2 +- lib/python/qmk/info.py | 36 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 4cf8876d7bf8..ab23510fd286 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -263,7 +263,7 @@ } } }, - "primary": { + "main": { "type": "string", "enum": ["eeprom", "left", "matrix_grid", "pin", "right"] }, diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 6fda9b8da531..221279f5c88d 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -201,55 +201,55 @@ def _extract_audio(info_data, config_c): info_data['audio'] = {'pins': audio_pins} -def _extract_split_primary(info_data, config_c): +def _extract_split_main(info_data, config_c): """Populate data about the split configuration """ - # Figure out how the primary half is determined + # Figure out how the main half is determined if config_c.get('SPLIT_HAND_PIN') is True: if 'split' not in info_data: info_data['split'] = {} - if 'primary' in info_data['split']: - _log_warning(info_data, 'Split primary hand is specified in both config.h (SPLIT_HAND_PIN) and info.json (split.primary) (Value: %s), the config.h value wins.' % info_data['split']['primary']) + if 'main' in info_data['split']: + _log_warning(info_data, 'Split main hand is specified in both config.h (SPLIT_HAND_PIN) and info.json (split.main) (Value: %s), the config.h value wins.' % info_data['split']['main']) - info_data['split']['primary'] = 'pin' + info_data['split']['main'] = 'pin' if config_c.get('SPLIT_HAND_MATRIX_GRID'): if 'split' not in info_data: info_data['split'] = {} - if 'primary' in info_data['split']: - _log_warning(info_data, 'Split primary hand is specified in both config.h (SPLIT_HAND_MATRIX_GRID) and info.json (split.primary) (Value: %s), the config.h value wins.' % info_data['split']['primary']) + if 'main' in info_data['split']: + _log_warning(info_data, 'Split main hand is specified in both config.h (SPLIT_HAND_MATRIX_GRID) and info.json (split.main) (Value: %s), the config.h value wins.' % info_data['split']['main']) - info_data['split']['primary'] = 'matrix_grid' + info_data['split']['main'] = 'matrix_grid' info_data['split']['matrix_grid'] = _extract_pins(config_c['SPLIT_HAND_MATRIX_GRID']) if config_c.get('EE_HANDS') is True: if 'split' not in info_data: info_data['split'] = {} - if 'primary' in info_data['split']: - _log_warning(info_data, 'Split primary hand is specified in both config.h (EE_HANDS) and info.json (split.primary) (Value: %s), the config.h value wins.' % info_data['split']['primary']) + if 'main' in info_data['split']: + _log_warning(info_data, 'Split main hand is specified in both config.h (EE_HANDS) and info.json (split.main) (Value: %s), the config.h value wins.' % info_data['split']['main']) - info_data['split']['primary'] = 'eeprom' + info_data['split']['main'] = 'eeprom' if config_c.get('MASTER_RIGHT') is True: if 'split' not in info_data: info_data['split'] = {} - if 'primary' in info_data['split']: - _log_warning(info_data, 'Split primary hand is specified in both config.h (MASTER_RIGHT) and info.json (split.primary) (Value: %s), the config.h value wins.' % info_data['split']['primary']) + if 'main' in info_data['split']: + _log_warning(info_data, 'Split main hand is specified in both config.h (MASTER_RIGHT) and info.json (split.main) (Value: %s), the config.h value wins.' % info_data['split']['main']) - info_data['split']['primary'] = 'right' + info_data['split']['main'] = 'right' if config_c.get('MASTER_LEFT') is True: if 'split' not in info_data: info_data['split'] = {} - if 'primary' in info_data['split']: - _log_warning(info_data, 'Split primary hand is specified in both config.h (MASTER_LEFT) and info.json (split.primary) (Value: %s), the config.h value wins.' % info_data['split']['primary']) + if 'main' in info_data['split']: + _log_warning(info_data, 'Split main hand is specified in both config.h (MASTER_LEFT) and info.json (split.main) (Value: %s), the config.h value wins.' % info_data['split']['main']) - info_data['split']['primary'] = 'left' + info_data['split']['main'] = 'left' def _extract_split_transport(info_data, config_c): @@ -435,7 +435,7 @@ def _extract_config_h(info_data): # Pull data that easily can't be mapped in json _extract_matrix_info(info_data, config_c) _extract_audio(info_data, config_c) - _extract_split_primary(info_data, config_c) + _extract_split_main(info_data, config_c) _extract_split_transport(info_data, config_c) _extract_split_right_pins(info_data, config_c) From 3389e50169924db34cfab3d7742064b3729a612b Mon Sep 17 00:00:00 2001 From: Zach White Date: Mon, 9 Aug 2021 16:08:54 -0700 Subject: [PATCH 31/37] fix esca/getawayvan_f042 --- keyboards/esca/getawayvan_f042/config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/keyboards/esca/getawayvan_f042/config.h b/keyboards/esca/getawayvan_f042/config.h index f83ec743417a..8921e9db4d16 100644 --- a/keyboards/esca/getawayvan_f042/config.h +++ b/keyboards/esca/getawayvan_f042/config.h @@ -34,7 +34,6 @@ along with this program. If not, see . #define MATRIX_ROW_PINS { A9, A8, A3, A5 } #define DIODE_DIRECTION COL2ROW -#define BACKLIGHT_PIN #define BACKLIGHT_LEVELS 6 #define GRAVE_ESC_CTRL_OVERRIDE From 3be43308e64d960d88d8dfdd08c1681241dfd63d Mon Sep 17 00:00:00 2001 From: Zach White Date: Mon, 9 Aug 2021 16:12:34 -0700 Subject: [PATCH 32/37] fix the bpiphany converters for real --- keyboards/bpiphany/frosty_flake/config.h | 4 ++-- keyboards/bpiphany/tiger_lily/config.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/keyboards/bpiphany/frosty_flake/config.h b/keyboards/bpiphany/frosty_flake/config.h index 74c771c8a9a2..ae19184a6a7f 100644 --- a/keyboards/bpiphany/frosty_flake/config.h +++ b/keyboards/bpiphany/frosty_flake/config.h @@ -44,8 +44,8 @@ along with this program. If not, see . * MATRIX_ROW_PINS and MATRIX_COL_PINS aren't actually used and are included * for data driven compatibility. */ -#define MATRIX_ROW_PINS { B0, B3, B2, B1, B6, B4, B5, C7 } -#define MATRIX_COL_PINS { NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN } +#define MATRIX_COL_PINS { B0, B3, B2, B1, B6, B4, B5, C7 } +#define MATRIX_ROW_PINS { NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN } #define UNUSED_PINS { C0, C1, C2, C3, C4, D2, D7 } /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ diff --git a/keyboards/bpiphany/tiger_lily/config.h b/keyboards/bpiphany/tiger_lily/config.h index d3e2464bee91..e3e77a62274e 100644 --- a/keyboards/bpiphany/tiger_lily/config.h +++ b/keyboards/bpiphany/tiger_lily/config.h @@ -44,8 +44,8 @@ along with this program. If not, see . * MATRIX_ROW_PINS and MATRIX_COL_PINS aren't actually used and are included * for data driven compatibility. */ -#define MATRIX_ROW_PINS { C2, B3, B4, B2, B1, C7, B6, B5 } -#define MATRIX_COL_PINS { NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN } +#define MATRIX_COL_PINS { C2, B3, B4, B2, B1, C7, B6, B5 } +#define MATRIX_ROW_PINS { NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN } #define UNUSED_PINS { B0, C4, D3 } #define LED_NUM_LOCK_PIN C5 From 967a21d01c3f1ed3638499ccfbe55b17ce95b5f2 Mon Sep 17 00:00:00 2001 From: Zach White Date: Tue, 10 Aug 2021 09:43:17 -0700 Subject: [PATCH 33/37] fix bpiphany/tiger_lily --- keyboards/bpiphany/tiger_lily/config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keyboards/bpiphany/tiger_lily/config.h b/keyboards/bpiphany/tiger_lily/config.h index e3e77a62274e..d3e2464bee91 100644 --- a/keyboards/bpiphany/tiger_lily/config.h +++ b/keyboards/bpiphany/tiger_lily/config.h @@ -44,8 +44,8 @@ along with this program. If not, see . * MATRIX_ROW_PINS and MATRIX_COL_PINS aren't actually used and are included * for data driven compatibility. */ -#define MATRIX_COL_PINS { C2, B3, B4, B2, B1, C7, B6, B5 } -#define MATRIX_ROW_PINS { NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN } +#define MATRIX_ROW_PINS { C2, B3, B4, B2, B1, C7, B6, B5 } +#define MATRIX_COL_PINS { NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN } #define UNUSED_PINS { B0, C4, D3 } #define LED_NUM_LOCK_PIN C5 From ae29ea4d581b448f238847e9058990fd6a05b9f2 Mon Sep 17 00:00:00 2001 From: Zach White Date: Sun, 15 Aug 2021 19:11:33 -0700 Subject: [PATCH 34/37] Apply suggestions from code review Co-authored-by: Nick Brassel --- data/mappings/info_config.json | 4 ++-- data/schemas/keyboard.jsonschema | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/data/mappings/info_config.json b/data/mappings/info_config.json index d965a5a37094..18477f9129f5 100644 --- a/data/mappings/info_config.json +++ b/data/mappings/info_config.json @@ -74,8 +74,8 @@ "QMK_KEYS_PER_SCAN": {"info_key": "qmk.keys_per_scan", "value_type": "int"}, "QMK_LED": {"info_key": "qmk_lufa_bootloader.led"}, "QMK_SPEAKER": {"info_key": "qmk_lufa_bootloader.speaker"}, - "SPLIT_MODS_ENABLE": {"info_key": "split.transport.mods", "value_type": "bool"}, - "SPLIT_TRANSPORT_MIRROR": {"info_key": "split.transport.mirror", "value_type": "bool"}, + "SPLIT_MODS_ENABLE": {"info_key": "split.transport.sync_modifiers", "value_type": "bool"}, + "SPLIT_TRANSPORT_MIRROR": {"info_key": "split.transport.sync_matrix_state", "value_type": "bool"}, "SPLIT_USB_DETECT": {"info_key": "split.usb_detect.enabled", "value_type": "bool"}, "SPLIT_USB_TIMEOUT": {"info_key": "split.usb_detect.timeout", "value_type": "int"}, "SPLIT_USB_TIMEOUT_POLL": {"info_key": "split.usb_detect.polling_interval", "value_type": "int"}, diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index ab23510fd286..de07443f64b0 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -280,7 +280,7 @@ "properties": { "protocol": { "type": "string", - "enum": ["custom", "i2c", "serial"] + "enum": ["custom", "i2c", "serial", "serial_usart"] }, "mirror": {"type": "boolean"}, "mods": {"type": "boolean"} From b885c633725acbb4aae3f566f247442841004294 Mon Sep 17 00:00:00 2001 From: Zach White Date: Sun, 15 Aug 2021 19:28:13 -0700 Subject: [PATCH 35/37] fix generate-api errors --- data/schemas/keyboard.jsonschema | 4 ++-- keyboards/cest73/tkm/config.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index de07443f64b0..78c9a8d36ba6 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -282,8 +282,8 @@ "type": "string", "enum": ["custom", "i2c", "serial", "serial_usart"] }, - "mirror": {"type": "boolean"}, - "mods": {"type": "boolean"} + "sync_matrix_state": {"type": "boolean"}, + "sync_modifiers": {"type": "boolean"} } }, "usb_detect": { diff --git a/keyboards/cest73/tkm/config.h b/keyboards/cest73/tkm/config.h index deef979b2c48..e925f397150a 100644 --- a/keyboards/cest73/tkm/config.h +++ b/keyboards/cest73/tkm/config.h @@ -34,7 +34,7 @@ #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7, C6, C7, D0 } /* column handy ruler: c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 */ #define MATRIX_COL_PINS { D1, D2, D3, D4, D5, D6, D7, F0, F1, F4 } -#define UNUSED_PINS { AF } +#define UNUSED_PINS { } //NOTE: if D6 pin shows any issues in exploatation the LED on the Teensy is to be removed From 0ca7238a68f10d61ed7841b8150233ad01665555 Mon Sep 17 00:00:00 2001 From: Zach White Date: Sun, 15 Aug 2021 21:08:41 -0700 Subject: [PATCH 36/37] fix matrix pin extraction for split boards --- lib/python/qmk/info.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 221279f5c88d..b6f2ecf64440 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -161,10 +161,9 @@ def _extract_pins(pins): return [_pin_name(pin) for pin in pins.split(',')] -def _extract_direct_matrix(info_data, direct_pins): +def _extract_direct_matrix(direct_pins): """ """ - info_data['matrix_pins'] = {} direct_pin_array = [] while direct_pins[-1] != '}': @@ -315,7 +314,7 @@ def _extract_split_right_pins(info_data, config_c): if 'right' not in info_data['split']['matrix_pins']: info_data['split']['matrix_pins']['right'] = {} - info_data['split']['matrix_pins']['right']['direct'] = _extract_direct_matrix(info_data, direct_pins) + info_data['split']['matrix_pins']['right']['direct'] = _extract_direct_matrix(direct_pins) if unused_pins: if 'split' not in info_data: @@ -338,6 +337,7 @@ def _extract_matrix_info(info_data, config_c): unused_pin_text = config_c.get('UNUSED_PINS') unused_pins = unused_pin_text.replace('{', '').replace('}', '').strip() if isinstance(unused_pin_text, str) else None direct_pins = config_c.get('DIRECT_PINS', '').replace(' ', '')[1:-1] + info_snippet = {} if 'MATRIX_ROWS' in config_c and 'MATRIX_COLS' in config_c: if 'matrix_size' in info_data: @@ -352,31 +352,32 @@ def _extract_matrix_info(info_data, config_c): if 'matrix_pins' in info_data and 'cols' in info_data['matrix_pins'] and 'rows' in info_data['matrix_pins']: _log_warning(info_data, 'Matrix pins are specified in both info.json and config.h, the config.h values win.') - info_data['matrix_pins'] = { - 'cols': _extract_pins(col_pins), - 'rows': _extract_pins(row_pins), - } + info_snippet['cols'] = _extract_pins(col_pins) + info_snippet['rows'] = _extract_pins(row_pins) if direct_pins: if 'matrix_pins' in info_data and 'direct' in info_data['matrix_pins']: _log_warning(info_data, 'Direct pins are specified in both info.json and config.h, the config.h values win.') - info_data['matrix_pins']['direct'] = _extract_direct_matrix(info_data, direct_pins) + info_snippet['direct'] = _extract_direct_matrix(direct_pins) if unused_pins: if 'matrix_pins' not in info_data: info_data['matrix_pins'] = {} - info_data['matrix_pins']['unused'] = _extract_pins(unused_pins) + info_snippet['unused'] = _extract_pins(unused_pins) if config_c.get('CUSTOM_MATRIX', 'no') != 'no': if 'matrix_pins' in info_data and 'custom' in info_data['matrix_pins']: _log_warning(info_data, 'Custom Matrix is specified in both info.json and config.h, the config.h values win.') - info_data['matrix_pins']['custom'] = True + info_snippet['custom'] = True if config_c['CUSTOM_MATRIX'] == 'lite': - info_data['matrix_pins']['custom_lite'] = True + info_snippet['custom_lite'] = True + + if info_snippet: + info_data['matrix_pins'] = info_snippet return info_data From 7a5f286e3d18d51d7a8f596d1be2ac9888a6b821 Mon Sep 17 00:00:00 2001 From: Zach White Date: Sun, 15 Aug 2021 21:43:15 -0700 Subject: [PATCH 37/37] fix ploopyco/trackball_nano/rev1_001 --- keyboards/ploopyco/trackball_nano/rev1_001/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/ploopyco/trackball_nano/rev1_001/config.h b/keyboards/ploopyco/trackball_nano/rev1_001/config.h index 63780ef048c4..6d265d723376 100644 --- a/keyboards/ploopyco/trackball_nano/rev1_001/config.h +++ b/keyboards/ploopyco/trackball_nano/rev1_001/config.h @@ -29,7 +29,7 @@ * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) * */ -#define DIRECT_PINS {} +#define DIRECT_PINS {{NO_PIN}} // These pins are not broken out, and cannot be used normally. // They are set as output and pulled high, by default