From 5267329caa6ce08a5497d774bae0c8f386220a16 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Thu, 4 Jan 2024 05:47:52 +0000 Subject: Ensure LED config is extracted when feature is disabled (#22809) * Ensure LED config is extracted when feature is disabled * Only attempt LED search if dd led config is missing --- lib/python/qmk/info.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'lib/python/qmk/info.py') diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index d51741ecb6..e960bf20ee 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -684,26 +684,26 @@ def _extract_led_config(info_data, keyboard): rows = info_data['matrix_size']['rows'] # Determine what feature owns g_led_config - features = info_data.get("features", {}) feature = None - if features.get("rgb_matrix", False): - feature = "rgb_matrix" - elif features.get("led_matrix", False): - feature = "led_matrix" + for feat in ['rgb_matrix', 'led_matrix']: + if info_data.get('features', {}).get(feat, False) or feat in info_data: + feature = feat if feature: - # Process - for file in find_keyboard_c(keyboard): - try: - ret = find_led_config(file, cols, rows) - if ret: - info_data[feature] = info_data.get(feature, {}) - info_data[feature]["layout"] = ret - except Exception as e: - _log_warning(info_data, f'led_config: {file.name}: {e}') - - if info_data[feature].get("layout", None) and not info_data[feature].get("led_count", None): - info_data[feature]["led_count"] = len(info_data[feature]["layout"]) + # Only attempt search if dd led config is missing + if 'layout' not in info_data.get(feature, {}): + # Process + for file in find_keyboard_c(keyboard): + try: + ret = find_led_config(file, cols, rows) + if ret: + info_data[feature] = info_data.get(feature, {}) + info_data[feature]['layout'] = ret + except Exception as e: + _log_warning(info_data, f'led_config: {file.name}: {e}') + + if info_data[feature].get('layout', None) and not info_data[feature].get('led_count', None): + info_data[feature]['led_count'] = len(info_data[feature]['layout']) return info_data -- cgit v1.2.3 From 71257e21e68d350c1c789a79440be8266be19788 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sat, 6 Jan 2024 13:16:23 +0000 Subject: Generate true/false for _DEFAULT_ON options (#22829) --- data/mappings/info_config.hjson | 94 ++++++++++++++++----------------- lib/python/qmk/cli/generate/config_h.py | 2 + lib/python/qmk/info.py | 2 +- 3 files changed, 50 insertions(+), 48 deletions(-) (limited to 'lib/python/qmk/info.py') diff --git a/data/mappings/info_config.hjson b/data/mappings/info_config.hjson index 7930eed642..2c4a75df89 100644 --- a/data/mappings/info_config.hjson +++ b/data/mappings/info_config.hjson @@ -3,7 +3,7 @@ { // Format: // : {"info_key": , ["value_type": ], ["to_json": ], ["to_c": ]} - // value_type: one of "array", "array.int", "bool", "int", "hex", "list", "mapping", "str", "raw" + // value_type: one of "array", "array.int", "bool, "flag", "int", "hex", "list", "mapping", "str", "raw" // 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 @@ -19,12 +19,12 @@ // Audio "AUDIO_DEFAULT_ON": {"info_key": "audio.default.on", "value_type": "bool"}, "AUDIO_DEFAULT_CLICKY_ON": {"info_key": "audio.default.clicky", "value_type": "bool"}, - "AUDIO_VOICES": {"info_key": "audio.voices", "value_type": "bool"}, - "SENDSTRING_BELL": {"info_key": "audio.macro_beep", "value_type": "bool"}, + "AUDIO_VOICES": {"info_key": "audio.voices", "value_type": "flag"}, + "SENDSTRING_BELL": {"info_key": "audio.macro_beep", "value_type": "flag"}, // Backlight - "BACKLIGHT_BREATHING": {"info_key": "backlight.breathing", "value_type": "bool"}, - "BACKLIGHT_CAPS_LOCK": {"info_key": "backlight.as_caps_lock", "value_type": "bool"}, + "BACKLIGHT_BREATHING": {"info_key": "backlight.breathing", "value_type": "flag"}, + "BACKLIGHT_CAPS_LOCK": {"info_key": "backlight.as_caps_lock", "value_type": "flag"}, "BACKLIGHT_LEVELS": {"info_key": "backlight.levels", "value_type": "int"}, "BACKLIGHT_LIMIT_VAL": {"info_key": "backlight.max_brightness", "value_type": "int"}, "BACKLIGHT_ON_STATE": {"info_key": "backlight.on_state", "value_type": "int"}, @@ -42,10 +42,10 @@ "BOOTMAGIC_LITE_ROW_RIGHT": {"info_key": "split.bootmagic.matrix.0", "value_type": "int"}, // Caps Word - "BOTH_SHIFTS_TURNS_ON_CAPS_WORD": {"info_key": "caps_word.both_shifts_turns_on", "value_type": "bool"}, + "BOTH_SHIFTS_TURNS_ON_CAPS_WORD": {"info_key": "caps_word.both_shifts_turns_on", "value_type": "flag"}, "CAPS_WORD_IDLE_TIMEOUT": {"info_key": "caps_word.idle_timeout", "value_type": "int"}, - "CAPS_WORD_INVERT_ON_SHIFT": {"info_key": "caps_word.invert_on_shift", "value_type": "bool"}, - "DOUBLE_TAP_SHIFT_TURNS_ON_CAPS_WORD": {"info_key": "caps_word.double_tap_shift_turns_on", "value_type": "bool"}, + "CAPS_WORD_INVERT_ON_SHIFT": {"info_key": "caps_word.invert_on_shift", "value_type": "flag"}, + "DOUBLE_TAP_SHIFT_TURNS_ON_CAPS_WORD": {"info_key": "caps_word.double_tap_shift_turns_on", "value_type": "flag"}, // Combos "COMBO_TERM": {"info_key": "combo.term", "value_type": "int"}, @@ -71,17 +71,17 @@ "LED_PIN_ON_STATE": {"info_key": "indicators.on_state", "value_type": "int"}, // Leader Key - "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_PER_KEY_TIMING": {"info_key": "leader_key.timing", "value_type": "flag"}, + "LEADER_KEY_STRICT_KEY_PROCESSING": {"info_key": "leader_key.strict_processing", "value_type": "flag"}, "LEADER_TIMEOUT": {"info_key": "leader_key.timeout", "value_type": "int"}, // LED Matrix "LED_MATRIX_CENTER": {"info_key": "led_matrix.center_point", "value_type": "array.int"}, - "LED_MATRIX_KEYRELEASES": {"info_key": "led_matrix.react_on_keyup", "value_type": "bool"}, + "LED_MATRIX_KEYRELEASES": {"info_key": "led_matrix.react_on_keyup", "value_type": "flag"}, "LED_MATRIX_LED_FLUSH_LIMIT": {"info_key": "led_matrix.led_flush_limit", "value_type": "int"}, "LED_MATRIX_LED_PROCESS_LIMIT": {"info_key": "led_matrix.led_process_limit", "value_type": "int", "to_json": false}, "LED_MATRIX_MAXIMUM_BRIGHTNESS": {"info_key": "led_matrix.max_brightness", "value_type": "int"}, - "LED_MATRIX_SLEEP": {"info_key": "led_matrix.sleep", "value_type": "bool"}, + "LED_MATRIX_SLEEP": {"info_key": "led_matrix.sleep", "value_type": "flag"}, "LED_MATRIX_SPD_STEP": {"info_key": "led_matrix.speed_steps", "value_type": "int"}, "LED_MATRIX_SPLIT": {"info_key": "led_matrix.split_count", "value_type": "array.int"}, "LED_MATRIX_TIMEOUT": {"info_key": "led_matrix.timeout", "value_type": "int"}, @@ -92,8 +92,8 @@ "LED_MATRIX_DEFAULT_SPD": {"info_key": "led_matrix.default.speed", "value_type": "int"}, // Locking Switch - "LOCKING_SUPPORT_ENABLE": {"info_key": "qmk.locking.enabled", "value_type": "bool"}, - "LOCKING_RESYNC_ENABLE": {"info_key": "qmk.locking.resync", "value_type": "bool"}, + "LOCKING_SUPPORT_ENABLE": {"info_key": "qmk.locking.enabled", "value_type": "flag"}, + "LOCKING_RESYNC_ENABLE": {"info_key": "qmk.locking.resync", "value_type": "flag"}, // LUFA Bootloader "QMK_ESC_INPUT": {"info_key": "qmk_lufa_bootloader.esc_input"}, @@ -104,7 +104,7 @@ // Matrix "DEBOUNCE": {"info_key": "debounce", "value_type": "int"}, "DIODE_DIRECTION": {"info_key": "diode_direction"}, - "MATRIX_HAS_GHOST": {"info_key": "matrix_pins.ghost", "value_type": "bool"}, + "MATRIX_HAS_GHOST": {"info_key": "matrix_pins.ghost", "value_type": "flag"}, "MATRIX_INPUT_PRESSED_STATE": {"info_key": "matrix_pins.input_pressed_state", "value_type": "int"}, "MATRIX_IO_DELAY": {"info_key": "matrix_pins.io_delay", "value_type": "int"}, @@ -126,12 +126,12 @@ // RGB Matrix "RGB_MATRIX_CENTER": {"info_key": "rgb_matrix.center_point", "value_type": "array.int"}, "RGB_MATRIX_HUE_STEP": {"info_key": "rgb_matrix.hue_steps", "value_type": "int"}, - "RGB_MATRIX_KEYRELEASES": {"info_key": "rgb_matrix.react_on_keyup", "value_type": "bool"}, + "RGB_MATRIX_KEYRELEASES": {"info_key": "rgb_matrix.react_on_keyup", "value_type": "flag"}, "RGB_MATRIX_LED_FLUSH_LIMIT": {"info_key": "rgb_matrix.led_flush_limit", "value_type": "int"}, "RGB_MATRIX_LED_PROCESS_LIMIT": {"info_key": "rgb_matrix.led_process_limit", "value_type": "int", "to_json": false}, "RGB_MATRIX_MAXIMUM_BRIGHTNESS": {"info_key": "rgb_matrix.max_brightness", "value_type": "int"}, "RGB_MATRIX_SAT_STEP": {"info_key": "rgb_matrix.sat_steps", "value_type": "int"}, - "RGB_MATRIX_SLEEP": {"info_key": "rgb_matrix.sleep", "value_type": "bool"}, + "RGB_MATRIX_SLEEP": {"info_key": "rgb_matrix.sleep", "value_type": "flag"}, "RGB_MATRIX_SPD_STEP": {"info_key": "rgb_matrix.speed_steps", "value_type": "int"}, "RGB_MATRIX_SPLIT": {"info_key": "rgb_matrix.split_count", "value_type": "array.int"}, "RGB_MATRIX_TIMEOUT": {"info_key": "rgb_matrix.timeout", "value_type": "int"}, @@ -146,23 +146,23 @@ // RGBLight "RGBLED_SPLIT": {"info_key": "rgblight.split_count", "value_type": "array.int"}, "RGBLIGHT_HUE_STEP": {"info_key": "rgblight.hue_steps", "value_type": "int"}, - "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_LAYER_BLINK": {"info_key": "rgblight.layers.blink", "value_type": "flag"}, + "RGBLIGHT_LAYERS": {"info_key": "rgblight.layers.enabled", "value_type": "flag"}, + "RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF": {"info_key": "rgblight.layers.override_rgb", "value_type": "flag"}, "RGBLIGHT_LED_COUNT": {"info_key": "rgblight.led_count", "value_type": "int"}, "RGBLIGHT_LED_MAP": {"info_key": "rgblight.led_map", "value_type": "array.int"}, "RGBLIGHT_LIMIT_VAL": {"info_key": "rgblight.max_brightness", "value_type": "int"}, "RGBLIGHT_MAX_LAYERS": {"info_key": "rgblight.layers.max", "value_type": "int"}, "RGBLIGHT_SAT_STEP": {"info_key": "rgblight.saturation_steps", "value_type": "int"}, - "RGBLIGHT_SLEEP": {"info_key": "rgblight.sleep", "value_type": "bool"}, - "RGBLIGHT_SPLIT": {"info_key": "rgblight.split", "value_type": "bool"}, + "RGBLIGHT_SLEEP": {"info_key": "rgblight.sleep", "value_type": "flag"}, + "RGBLIGHT_SPLIT": {"info_key": "rgblight.split", "value_type": "flag"}, "RGBLIGHT_VAL_STEP": {"info_key": "rgblight.brightness_steps", "value_type": "int"}, "RGBLIGHT_DEFAULT_ON": {"info_key": "rgblight.default.on", "value_type": "bool"}, "RGBLIGHT_DEFAULT_HUE": {"info_key": "rgblight.default.hue", "value_type": "int"}, "RGBLIGHT_DEFAULT_SAT": {"info_key": "rgblight.default.sat", "value_type": "int"}, "RGBLIGHT_DEFAULT_VAL": {"info_key": "rgblight.default.val", "value_type": "int"}, "RGBLIGHT_DEFAULT_SPD": {"info_key": "rgblight.default.speed", "value_type": "int"}, - "RGBW": {"info_key": "rgblight.rgbw", "value_type": "bool"}, + "RGBW": {"info_key": "rgblight.rgbw", "value_type": "flag"}, // Secure "SECURE_IDLE_TIMEOUT": {"info_key": "secure.idle_timeout", "value_type": "int"}, @@ -174,37 +174,37 @@ "SOFT_SERIAL_SPEED": {"info_key": "split.soft_serial_speed"}, "SPLIT_HAND_MATRIX_GRID": {"info_key": "split.handedness.matrix_grid", "value_type": "array", "to_c": false}, "SPLIT_HAND_PIN": {"info_key": "split.handedness.pin"}, - "SPLIT_USB_DETECT": {"info_key": "split.usb_detect.enabled", "value_type": "bool"}, + "SPLIT_USB_DETECT": {"info_key": "split.usb_detect.enabled", "value_type": "flag"}, "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"}, - "SPLIT_WATCHDOG_ENABLE": {"info_key": "split.transport.watchdog", "value_type": "bool"}, + "SPLIT_WATCHDOG_ENABLE": {"info_key": "split.transport.watchdog", "value_type": "flag"}, "SPLIT_WATCHDOG_TIMEOUT": {"info_key": "split.transport.watchdog_timeout", "value_type": "int"}, - "SPLIT_ACTIVITY_ENABLE": {"info_key": "split.transport.sync.activity", "value_type": "bool"}, - "SPLIT_DETECTED_OS_ENABLE": {"info_key": "split.transport.sync.detected_os", "value_type": "bool"}, - "SPLIT_HAPTIC_ENABLE": {"info_key": "split.transport.sync.haptic", "value_type": "bool"}, - "SPLIT_LAYER_STATE_ENABLE": {"info_key": "split.transport.sync.layer_state", "value_type": "bool"}, - "SPLIT_LED_STATE_ENABLE": {"info_key": "split.transport.sync.indicators", "value_type": "bool"}, - "SPLIT_TRANSPORT_MIRROR": {"info_key": "split.transport.sync.matrix_state", "value_type": "bool"}, - "SPLIT_MODS_ENABLE": {"info_key": "split.transport.sync.modifiers", "value_type": "bool"}, - "SPLIT_OLED_ENABLE": {"info_key": "split.transport.sync.oled", "value_type": "bool"}, - "SPLIT_ST7565_ENABLE": {"info_key": "split.transport.sync.st7565", "value_type": "bool"}, - "SPLIT_WPM_ENABLE": {"info_key": "split.transport.sync.wpm", "value_type": "bool"}, + "SPLIT_ACTIVITY_ENABLE": {"info_key": "split.transport.sync.activity", "value_type": "flag"}, + "SPLIT_DETECTED_OS_ENABLE": {"info_key": "split.transport.sync.detected_os", "value_type": "flag"}, + "SPLIT_HAPTIC_ENABLE": {"info_key": "split.transport.sync.haptic", "value_type": "flag"}, + "SPLIT_LAYER_STATE_ENABLE": {"info_key": "split.transport.sync.layer_state", "value_type": "flag"}, + "SPLIT_LED_STATE_ENABLE": {"info_key": "split.transport.sync.indicators", "value_type": "flag"}, + "SPLIT_TRANSPORT_MIRROR": {"info_key": "split.transport.sync.matrix_state", "value_type": "flag"}, + "SPLIT_MODS_ENABLE": {"info_key": "split.transport.sync.modifiers", "value_type": "flag"}, + "SPLIT_OLED_ENABLE": {"info_key": "split.transport.sync.oled", "value_type": "flag"}, + "SPLIT_ST7565_ENABLE": {"info_key": "split.transport.sync.st7565", "value_type": "flag"}, + "SPLIT_WPM_ENABLE": {"info_key": "split.transport.sync.wpm", "value_type": "flag"}, // Tapping - "HOLD_ON_OTHER_KEY_PRESS": {"info_key": "tapping.hold_on_other_key_press", "value_type": "bool"}, - "HOLD_ON_OTHER_KEY_PRESS_PER_KEY": {"info_key": "tapping.hold_on_other_key_press_per_key", "value_type": "bool"}, - "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"}, + "HOLD_ON_OTHER_KEY_PRESS": {"info_key": "tapping.hold_on_other_key_press", "value_type": "flag"}, + "HOLD_ON_OTHER_KEY_PRESS_PER_KEY": {"info_key": "tapping.hold_on_other_key_press_per_key", "value_type": "flag"}, + "PERMISSIVE_HOLD": {"info_key": "tapping.permissive_hold", "value_type": "flag"}, + "PERMISSIVE_HOLD_PER_KEY": {"info_key": "tapping.permissive_hold_per_key", "value_type": "flag"}, + "RETRO_TAPPING": {"info_key": "tapping.retro", "value_type": "flag"}, + "RETRO_TAPPING_PER_KEY": {"info_key": "tapping.retro_per_key", "value_type": "flag"}, "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_TERM": {"info_key": "tapping.term", "value_type": "int"}, - "TAPPING_TERM_PER_KEY": {"info_key": "tapping.term_per_key", "value_type": "bool"}, + "TAPPING_TERM_PER_KEY": {"info_key": "tapping.term_per_key", "value_type": "flag"}, "TAPPING_TOGGLE": {"info_key": "tapping.toggle", "value_type": "int"}, // USB - "FORCE_NKRO": {"info_key": "usb.force_nkro", "value_type": "bool"}, + "FORCE_NKRO": {"info_key": "usb.force_nkro", "value_type": "flag"}, "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"}, @@ -219,7 +219,7 @@ // Items we want flagged in lint "DEBOUNCING_DELAY": {"info_key": "_invalid.debouncing_delay", "invalid": true, "replace_with": "DEBOUNCE"}, "DESCRIPTION": {"info_key": "_invalid.usb_description", "invalid": true}, - "IGNORE_MOD_TAP_INTERRUPT": {"info_key": "_invalid.ignore_mod_tap_interrupt", "value_type": "bool", "invalid": true}, + "IGNORE_MOD_TAP_INTERRUPT": {"info_key": "_invalid.ignore_mod_tap_interrupt", "value_type": "flag", "invalid": true}, "IGNORE_MOD_TAP_INTERRUPT_PER_KEY": {"info_key": "_invalid.ignore_mod_tap_interrupt_per_key", "invalid": true}, "LED_DISABLE_WHEN_USB_SUSPENDED": {"info_key": "_invalid.led_matrix_sleep", "invalid": true, "replace_with": "LED_MATRIX_SLEEP"}, "NO_ACTION_FUNCTION": {"info_key": "_invalid.no_action_function", "invalid": true}, @@ -228,9 +228,9 @@ "QMK_KEYS_PER_SCAN": {"info_key": "qmk.keys_per_scan", "value_type": "int", "deprecated": true}, "RGB_DI_PIN": {"info_key": "rgblight.pin", "invalid": true, "replace_with": "WS2812_DI_PIN or APA102_DI_PIN"}, "RGB_DISABLE_WHEN_USB_SUSPENDED": {"info_key": "_invalid.rgb_matrix_sleep", "invalid": true, "replace_with": "RGB_MATRIX_SLEEP"}, - "RGBLIGHT_ANIMATIONS": {"info_key": "_invalid.rgblight.animations.all", "value_type": "bool", "invalid": true}, - "TAPPING_FORCE_HOLD": {"info_key": "tapping.force_hold", "value_type": "bool", "deprecated": true}, - "TAPPING_FORCE_HOLD_PER_KEY": {"info_key": "tapping.force_hold_per_key", "value_type": "bool", "deprecated": true}, + "RGBLIGHT_ANIMATIONS": {"info_key": "_invalid.rgblight.animations.all", "value_type": "flag", "invalid": true}, + "TAPPING_FORCE_HOLD": {"info_key": "tapping.force_hold", "value_type": "flag", "deprecated": true}, + "TAPPING_FORCE_HOLD_PER_KEY": {"info_key": "tapping.force_hold_per_key", "value_type": "flag", "deprecated": true}, "UNUSED_PINS": {"info_key": "_invalid.unused_pins", "deprecated": true}, "COMBO_COUNT": {"info_key": "_invalid.combo.count", "invalid": true}, diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py index 00fb1d9585..fc681300a3 100755 --- a/lib/python/qmk/cli/generate/config_h.py +++ b/lib/python/qmk/cli/generate/config_h.py @@ -108,6 +108,8 @@ def generate_config_items(kb_info_json, config_h_lines): elif key_type.startswith('array'): config_h_lines.append(generate_define(config_key, f'{{ {", ".join(map(str, config_value))} }}')) elif key_type == 'bool': + config_h_lines.append(generate_define(config_key, 'true' if config_value else 'false')) + elif key_type == 'flag': if config_value: config_h_lines.append(generate_define(config_key)) elif key_type == 'mapping': diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index e960bf20ee..5500ecdd19 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -513,7 +513,7 @@ def _config_to_json(key_type, config_value): else: return list(map(str.strip, config_value.split(','))) - elif key_type == 'bool': + elif key_type in ['bool', 'flag']: if isinstance(config_value, bool): return config_value return config_value in true_values -- cgit v1.2.3 From 455cd65e80563469712fe56de15666e06b945636 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Tue, 9 Jan 2024 09:59:36 +0000 Subject: Prevent `qmk migrate` processing unparsed info.json values (#22374) --- lib/python/qmk/cli/migrate.py | 5 ++++- lib/python/qmk/info.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/python/qmk/info.py') diff --git a/lib/python/qmk/cli/migrate.py b/lib/python/qmk/cli/migrate.py index c1b1ad1ea9..0bab5c1949 100644 --- a/lib/python/qmk/cli/migrate.py +++ b/lib/python/qmk/cli/migrate.py @@ -47,9 +47,12 @@ def migrate(cli): files = _candidate_files(cli.args.keyboard) # Filter down keys if requested - keys = info_map.keys() + keys = list(filter(lambda key: info_map[key].get("to_json", True), info_map.keys())) if cli.args.filter: keys = list(set(keys) & set(cli.args.filter)) + rejected = set(cli.args.filter) - set(keys) + for key in rejected: + cli.log.info(f'{{fg_yellow}}Skipping {key} as migration not possible...') cli.log.info(f'{{fg_green}}Migrating keyboard {{fg_cyan}}{cli.args.keyboard}{{fg_green}}.{{fg_reset}}') diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 5500ecdd19..b018ba96fd 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -501,6 +501,9 @@ def _config_to_json(key_type, config_value): """Convert config value using spec """ if key_type.startswith('array'): + if key_type.count('.') > 1: + raise Exception(f"Conversion of {key_type} not possible") + if '.' in key_type: key_type, array_type = key_type.split('.', 1) else: -- cgit v1.2.3 From 1bebaa310abb637cbca146b6d7859f3efe503cfd Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 14 Jan 2024 21:33:58 +1100 Subject: CLI: Allow generation of both LED and RGB Matrix config (#22896) --- lib/python/qmk/cli/generate/keyboard_c.py | 25 ++++++++++++-------- lib/python/qmk/info.py | 38 ++++++++++++++----------------- 2 files changed, 32 insertions(+), 31 deletions(-) (limited to 'lib/python/qmk/info.py') diff --git a/lib/python/qmk/cli/generate/keyboard_c.py b/lib/python/qmk/cli/generate/keyboard_c.py index f010341613..5a6c967486 100755 --- a/lib/python/qmk/cli/generate/keyboard_c.py +++ b/lib/python/qmk/cli/generate/keyboard_c.py @@ -9,21 +9,25 @@ from qmk.path import normpath from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE -def _gen_led_config(info_data): +def _gen_led_configs(info_data): + lines = [] + + if 'layout' in info_data.get('rgb_matrix', {}): + lines.extend(_gen_led_config(info_data, 'rgb_matrix')) + + if 'layout' in info_data.get('led_matrix', {}): + lines.extend(_gen_led_config(info_data, 'led_matrix')) + + return lines + + +def _gen_led_config(info_data, config_type): """Convert info.json content to g_led_config """ cols = info_data['matrix_size']['cols'] rows = info_data['matrix_size']['rows'] - config_type = None - if 'layout' in info_data.get('rgb_matrix', {}): - config_type = 'rgb_matrix' - elif 'layout' in info_data.get('led_matrix', {}): - config_type = 'led_matrix' - lines = [] - if not config_type: - return lines matrix = [['NO_LED'] * cols for _ in range(rows)] pos = [] @@ -53,6 +57,7 @@ def _gen_led_config(info_data): lines.append(f' {{ {", ".join(flags)} }},') lines.append('};') lines.append('#endif') + lines.append('') return lines @@ -98,7 +103,7 @@ def generate_keyboard_c(cli): # Build the layouts.h file. keyboard_h_lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '#include QMK_KEYBOARD_H', ''] - keyboard_h_lines.extend(_gen_led_config(kb_info_json)) + keyboard_h_lines.extend(_gen_led_configs(kb_info_json)) keyboard_h_lines.extend(_gen_matrix_mask(kb_info_json)) # Show the results diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index b018ba96fd..efe4dac34a 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -686,27 +686,23 @@ def _extract_led_config(info_data, keyboard): cols = info_data['matrix_size']['cols'] rows = info_data['matrix_size']['rows'] - # Determine what feature owns g_led_config - feature = None - for feat in ['rgb_matrix', 'led_matrix']: - if info_data.get('features', {}).get(feat, False) or feat in info_data: - feature = feat - - if feature: - # Only attempt search if dd led config is missing - if 'layout' not in info_data.get(feature, {}): - # Process - for file in find_keyboard_c(keyboard): - try: - ret = find_led_config(file, cols, rows) - if ret: - info_data[feature] = info_data.get(feature, {}) - info_data[feature]['layout'] = ret - except Exception as e: - _log_warning(info_data, f'led_config: {file.name}: {e}') - - if info_data[feature].get('layout', None) and not info_data[feature].get('led_count', None): - info_data[feature]['led_count'] = len(info_data[feature]['layout']) + for feature in ['rgb_matrix', 'led_matrix']: + if info_data.get('features', {}).get(feature, False) or feature in info_data: + + # Only attempt search if dd led config is missing + if 'layout' not in info_data.get(feature, {}): + # Process + for file in find_keyboard_c(keyboard): + try: + ret = find_led_config(file, cols, rows) + if ret: + info_data[feature] = info_data.get(feature, {}) + info_data[feature]['layout'] = ret + except Exception as e: + _log_warning(info_data, f'led_config: {file.name}: {e}') + + if info_data[feature].get('layout', None) and not info_data[feature].get('led_count', None): + info_data[feature]['led_count'] = len(info_data[feature]['layout']) return info_data -- cgit v1.2.3 From 3a13c2120a9e3d897e05923c68efa542f3b3efc7 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Thu, 1 Feb 2024 15:45:58 +0000 Subject: Ensure LTO is enabled as a `info.json` build config option (#22932) * feature.lto -> build.lto * keymaps too --- data/schemas/keyboard.jsonschema | 4 ++-- keyboards/acheron/themis/87h/info.json | 4 +++- keyboards/acheron/themis/87htsc/info.json | 4 +++- keyboards/acheron/themis/88htsc/info.json | 4 +++- keyboards/clueboard/card/info.json | 1 - keyboards/crkbd/info.json | 1 - keyboards/dark/magnum_ergo_1/info.json | 4 +++- keyboards/fancytech/fancyalice66/info.json | 4 +++- keyboards/hotdox76v2/info.json | 1 - keyboards/kbdfans/kbdpad/mk3/info.json | 1 - keyboards/keychron/q1v1/info.json | 4 +++- keyboards/mode/m256wh/info.json | 4 +++- keyboards/mode/m256ws/info.json | 4 +++- keyboards/moondrop/dash75/info.json | 6 ++++-- keyboards/moondrop/dash75/keymaps/via/keymap.json | 3 +-- keyboards/pauperboards/brick/info.json | 3 +-- keyboards/quadrum/delta/info.json | 4 +++- keyboards/quokka/info.json | 1 - keyboards/smithrune/magnus/m75h/info.json | 4 +++- keyboards/smithrune/magnus/m75s/info.json | 4 +++- keyboards/teleport/native/info.json | 6 ++++-- keyboards/thevankeyboards/minivan/keymaps/via/keymap.json | 6 ++++-- lib/python/qmk/info.py | 3 +++ 23 files changed, 52 insertions(+), 28 deletions(-) (limited to 'lib/python/qmk/info.py') diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 4836cf1fca..d953079659 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -314,8 +314,8 @@ }, "features": { "$ref": "qmk.definitions.v1#/boolean_array", - "propertyNames": { "$ref": "qmk.definitions.v1#/snake_case" } - + "propertyNames": { "$ref": "qmk.definitions.v1#/snake_case" }, + "not": { "required": [ "lto" ] } }, "indicators": { "type": "object", diff --git a/keyboards/acheron/themis/87h/info.json b/keyboards/acheron/themis/87h/info.json index 0ef52a61a0..a7bfb89997 100644 --- a/keyboards/acheron/themis/87h/info.json +++ b/keyboards/acheron/themis/87h/info.json @@ -8,9 +8,11 @@ "cols": ["A8" ,"C9" ,"C8" ,"B14","B12","B10","B1" ,"B0" ,"A7" ,"A6" ,"A5" ,"A4" ,"C5" ,"C7" ,"B3" ,"A2" ,"C12","D2" ], "rows": ["A15","A10","C6" ,"C4" ,"A3" ,"A1" ,"C11","C10","B4"] }, + "build": { + "lto": true + }, "features": { "bootmagic": true, - "lto": true, "mousekey": true, "extrakey": true, "console": false, diff --git a/keyboards/acheron/themis/87htsc/info.json b/keyboards/acheron/themis/87htsc/info.json index 75c680d2a4..5f38814789 100644 --- a/keyboards/acheron/themis/87htsc/info.json +++ b/keyboards/acheron/themis/87htsc/info.json @@ -8,9 +8,11 @@ "cols": ["A8" ,"C9" ,"C8" ,"B14","B12","B10","B1" ,"B0" ,"A7" ,"A6" ,"A5" ,"A4" ,"C5" ,"C7" ,"B3" ,"A2" ,"C12","D2" ], "rows": ["A15","A10","C6" ,"C4" ,"A3" ,"A1" ,"C11","C10","B4"] }, + "build": { + "lto": true + }, "features": { "bootmagic": true, - "lto": true, "mousekey": true, "extrakey": true, "console": false, diff --git a/keyboards/acheron/themis/88htsc/info.json b/keyboards/acheron/themis/88htsc/info.json index 8726642c0c..20b3d38828 100644 --- a/keyboards/acheron/themis/88htsc/info.json +++ b/keyboards/acheron/themis/88htsc/info.json @@ -8,9 +8,11 @@ "cols": ["A8" ,"C9" ,"C8" ,"B14","B12","B10","B1" ,"B0" ,"A7" ,"A6" ,"A5" ,"A4" ,"C5" ,"C7" ,"B3" ,"A2" ,"C12","D2" ], "rows": ["A15","A10","C6" ,"C4" ,"A3" ,"A1" ,"C11","C10","B4"] }, + "build": { + "lto": true + }, "features": { "bootmagic": true, - "lto": true, "mousekey": true, "extrakey": true, "console": false, diff --git a/keyboards/clueboard/card/info.json b/keyboards/clueboard/card/info.json index 98c9f4d5f1..7799110ba6 100644 --- a/keyboards/clueboard/card/info.json +++ b/keyboards/clueboard/card/info.json @@ -14,7 +14,6 @@ "command": false, "console": true, "extrakey": true, - "lto": true, "midi": false, "mousekey": true, "nkro": false, diff --git a/keyboards/crkbd/info.json b/keyboards/crkbd/info.json index fa9abc574e..880cbccc29 100644 --- a/keyboards/crkbd/info.json +++ b/keyboards/crkbd/info.json @@ -14,7 +14,6 @@ "features": { "bootmagic": true, "extrakey": true, - "lto": true, "mousekey": true, "nkro": true, "oled": true diff --git a/keyboards/dark/magnum_ergo_1/info.json b/keyboards/dark/magnum_ergo_1/info.json index a213d92fd5..6ed3908479 100644 --- a/keyboards/dark/magnum_ergo_1/info.json +++ b/keyboards/dark/magnum_ergo_1/info.json @@ -8,6 +8,9 @@ "pid": "0x4D45", "device_version": "0.0.1" }, + "build": { + "lto": true + }, "features": { "audio": false, "backlight": true, @@ -16,7 +19,6 @@ "console": false, "encoder": false, "extrakey": true, - "lto": true, "mousekey": false, "nkro": true, "rgblight": false diff --git a/keyboards/fancytech/fancyalice66/info.json b/keyboards/fancytech/fancyalice66/info.json index 21c89849fd..b2e219c1c9 100644 --- a/keyboards/fancytech/fancyalice66/info.json +++ b/keyboards/fancytech/fancyalice66/info.json @@ -9,11 +9,13 @@ {"pin_a": "F0", "pin_b": "F1", "resolution": 2} ] }, + "build": { + "lto": true + }, "features": { "bootmagic": true, "encoder": false, "extrakey": true, - "lto": true, "mousekey": true, "nkro": true, "rgb_matrix": true diff --git a/keyboards/hotdox76v2/info.json b/keyboards/hotdox76v2/info.json index 2270d33273..30fd71f62a 100644 --- a/keyboards/hotdox76v2/info.json +++ b/keyboards/hotdox76v2/info.json @@ -11,7 +11,6 @@ "extrakey": true, "mousekey": true, "nkro": true, - "lto": true, "oled": true, "rgb_matrix": true }, diff --git a/keyboards/kbdfans/kbdpad/mk3/info.json b/keyboards/kbdfans/kbdpad/mk3/info.json index 56c7b80977..735dd3e4ef 100644 --- a/keyboards/kbdfans/kbdpad/mk3/info.json +++ b/keyboards/kbdfans/kbdpad/mk3/info.json @@ -9,7 +9,6 @@ "command": false, "console": false, "extrakey": true, - "lto": true, "mousekey": true, "nkro": true, "rgb_matrix": true diff --git a/keyboards/keychron/q1v1/info.json b/keyboards/keychron/q1v1/info.json index 26c846927b..0041687269 100644 --- a/keyboards/keychron/q1v1/info.json +++ b/keyboards/keychron/q1v1/info.json @@ -4,13 +4,15 @@ "maintainer": "lalalademaxiya1", "bootloader": "atmel-dfu", "diode_direction": "ROW2COL", + "build": { + "lto": true + }, "features": { "bootmagic": true, "command": false, "console": false, "dip_switch": true, "extrakey": true, - "lto": true, "mousekey": true, "nkro": true, "rgb_matrix": true diff --git a/keyboards/mode/m256wh/info.json b/keyboards/mode/m256wh/info.json index 6caaa754ed..bbd3c17e97 100644 --- a/keyboards/mode/m256wh/info.json +++ b/keyboards/mode/m256wh/info.json @@ -4,9 +4,11 @@ "maintainer": "Gondolindrim", "bootloader": "stm32-dfu", "diode_direction": "COL2ROW", + "build": { + "lto": true + }, "features": { "extrakey": true, - "lto": true, "mousekey": true, "nkro": true, "rgblight": true diff --git a/keyboards/mode/m256ws/info.json b/keyboards/mode/m256ws/info.json index 6a36d4af8e..820ed536c2 100644 --- a/keyboards/mode/m256ws/info.json +++ b/keyboards/mode/m256ws/info.json @@ -4,12 +4,14 @@ "maintainer": "Gondolindrim", "bootloader": "stm32-dfu", "diode_direction": "COL2ROW", + "build": { + "lto": true + }, "features": { "bootmagic": true, "command": false, "console": false, "extrakey": true, - "lto": true, "mousekey": true, "nkro": true, "rgblight": true diff --git a/keyboards/moondrop/dash75/info.json b/keyboards/moondrop/dash75/info.json index 13e28fb325..59f956815e 100644 --- a/keyboards/moondrop/dash75/info.json +++ b/keyboards/moondrop/dash75/info.json @@ -3,14 +3,16 @@ "keyboard_name": "Dash 75", "maintainer": "vinorodrigues", "bootloader": "atmel-dfu", + "build": { + "lto": true + }, "features": { "bootmagic": true, "command": false, "console": false, "extrakey": true, "mousekey": true, - "nkro": false, - "lto": true + "nkro": false }, "diode_direction": "COL2ROW", "matrix_pins": { diff --git a/keyboards/moondrop/dash75/keymaps/via/keymap.json b/keyboards/moondrop/dash75/keymaps/via/keymap.json index d811aaa780..91faa45808 100644 --- a/keyboards/moondrop/dash75/keymaps/via/keymap.json +++ b/keyboards/moondrop/dash75/keymaps/via/keymap.json @@ -7,8 +7,7 @@ "author": "vinorodrigues", "config": { "features": { - "via": true, - "lto": true + "via": true } }, "layers": [ diff --git a/keyboards/pauperboards/brick/info.json b/keyboards/pauperboards/brick/info.json index 112a84ff1a..8ebe32ded4 100644 --- a/keyboards/pauperboards/brick/info.json +++ b/keyboards/pauperboards/brick/info.json @@ -23,8 +23,7 @@ "mousekey": true, "nkro": true, "encoder": true, - "rgblight": true, - "lto": true + "rgblight": true }, "build": { "lto": true diff --git a/keyboards/quadrum/delta/info.json b/keyboards/quadrum/delta/info.json index 118a2dcbd6..bfdc0afd62 100644 --- a/keyboards/quadrum/delta/info.json +++ b/keyboards/quadrum/delta/info.json @@ -4,6 +4,9 @@ "maintainer": "Sleepdealr", "bootloader": "atmel-dfu", "diode_direction": "COL2ROW", + "build": { + "lto": true + }, "features": { "bootmagic": true, "command": false, @@ -11,7 +14,6 @@ "extrakey": true, "mousekey": true, "nkro": true, - "lto": true, "encoder": true }, "matrix_pins": { diff --git a/keyboards/quokka/info.json b/keyboards/quokka/info.json index ed951ff0b2..0c34b0ee65 100644 --- a/keyboards/quokka/info.json +++ b/keyboards/quokka/info.json @@ -10,7 +10,6 @@ "features": { "audio": true, "extrakey": true, - "lto": true, "oled": true, "rgb_matrix": true }, diff --git a/keyboards/smithrune/magnus/m75h/info.json b/keyboards/smithrune/magnus/m75h/info.json index 0592d2a7a6..9b120a186e 100644 --- a/keyboards/smithrune/magnus/m75h/info.json +++ b/keyboards/smithrune/magnus/m75h/info.json @@ -8,6 +8,9 @@ "pid": "0x1676", "device_version": "0.0.1" }, + "build": { + "lto": true + }, "features": { "audio": false, "backlight": false, @@ -16,7 +19,6 @@ "console": false, "encoder": false, "extrakey": true, - "lto": true, "mousekey": true, "nkro": true, "rgblight": true diff --git a/keyboards/smithrune/magnus/m75s/info.json b/keyboards/smithrune/magnus/m75s/info.json index da2f4e3eff..56f7a06b04 100644 --- a/keyboards/smithrune/magnus/m75s/info.json +++ b/keyboards/smithrune/magnus/m75s/info.json @@ -8,6 +8,9 @@ "pid": "0x1675", "device_version": "0.0.1" }, + "build": { + "lto": true + }, "features": { "audio": false, "backlight": true, @@ -16,7 +19,6 @@ "console": false, "encoder": false, "extrakey": true, - "lto": true, "mousekey": true, "nkro": true, "rgblight": true diff --git a/keyboards/teleport/native/info.json b/keyboards/teleport/native/info.json index eaf9118ff9..3cd857a55d 100644 --- a/keyboards/teleport/native/info.json +++ b/keyboards/teleport/native/info.json @@ -29,14 +29,16 @@ "led_flush_limit": 32, "sleep": true }, + "build": { + "lto": true + }, "features": { "bootmagic": true, "command": false, "console": false, "extrakey": true, "mousekey": true, - "nkro": true, - "lto": true + "nkro": true }, "diode_direction": "ROW2COL", "matrix_pins": { diff --git a/keyboards/thevankeyboards/minivan/keymaps/via/keymap.json b/keyboards/thevankeyboards/minivan/keymaps/via/keymap.json index 54ceb5c342..bff872dee8 100644 --- a/keyboards/thevankeyboards/minivan/keymaps/via/keymap.json +++ b/keyboards/thevankeyboards/minivan/keymaps/via/keymap.json @@ -9,10 +9,12 @@ ["KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS"] ], "config": { - "features": { - "via": true, + "build": { "lto": true }, + "features": { + "via": true + }, "dynamic_keymap": { "layer_count": 4 } diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 4ef12bea71..13588abdb8 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -233,6 +233,9 @@ def _extract_features(info_data, rules): key = '_'.join(key.split('_')[:-1]).lower() value = True if value.lower() in true_values else False if value.lower() in false_values else value + if key in ['lto']: + continue + if 'config_h_features' not in info_data: info_data['config_h_features'] = {} -- cgit v1.2.3