diff options
Diffstat (limited to 'lib/python/qmk/info.py')
-rw-r--r-- | lib/python/qmk/info.py | 56 |
1 files changed, 20 insertions, 36 deletions
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 7460d84ad3..5dc8b9c5fe 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -437,19 +437,6 @@ def _extract_matrix_info(info_data, config_c): return info_data -# TODO: kill off usb.device_ver in favor of usb.device_version -def _extract_device_version(info_data): - if info_data.get('usb'): - if info_data['usb'].get('device_version') and not info_data['usb'].get('device_ver'): - (major, minor, revision) = info_data['usb']['device_version'].split('.', 3) - info_data['usb']['device_ver'] = f'0x{major.zfill(2)}{minor}{revision}' - if not info_data['usb'].get('device_version') and info_data['usb'].get('device_ver'): - major = int(info_data['usb']['device_ver'][2:4]) - minor = int(info_data['usb']['device_ver'][4]) - revision = int(info_data['usb']['device_ver'][5]) - info_data['usb']['device_version'] = f'{major}.{minor}.{revision}' - - def _config_to_json(key_type, config_value): """Convert config value using spec """ @@ -479,7 +466,7 @@ def _config_to_json(key_type, config_value): return int(config_value) elif key_type == 'str': - return config_value.strip('"') + return config_value.strip('"').replace('\\"', '"').replace('\\\\', '\\') elif key_type == 'bcd_version': major = int(config_value[2:4]) @@ -496,7 +483,7 @@ def _extract_config_h(info_data, config_c): """ # Pull in data from the json map dotty_info = dotty(info_data) - info_config_map = json_load(Path('data/mappings/info_config.json')) + info_config_map = json_load(Path('data/mappings/info_config.hjson')) for config_key, info_dict in info_config_map.items(): info_key = info_dict['info_key'] @@ -535,7 +522,6 @@ def _extract_config_h(info_data, config_c): _extract_split_right_pins(info_data, config_c) _extract_encoders(info_data, config_c) _extract_split_encoders(info_data, config_c) - _extract_device_version(info_data) return info_data @@ -543,7 +529,7 @@ def _extract_config_h(info_data, config_c): def _process_defaults(info_data): """Process any additional defaults based on currently discovered information """ - defaults_map = json_load(Path('data/mappings/defaults.json')) + defaults_map = json_load(Path('data/mappings/defaults.hjson')) for default_type in defaults_map.keys(): thing_map = defaults_map[default_type] if default_type in info_data: @@ -569,7 +555,7 @@ def _extract_rules_mk(info_data, rules): # Pull in data from the json map dotty_info = dotty(info_data) - info_rules_map = json_load(Path('data/mappings/info_rules.json')) + info_rules_map = json_load(Path('data/mappings/info_rules.hjson')) for rules_key, info_dict in info_rules_map.items(): info_key = info_dict['info_key'] @@ -627,20 +613,24 @@ def _extract_led_config(info_data, keyboard): cols = info_data['matrix_size']['cols'] rows = info_data['matrix_size']['rows'] - # Assume what feature owns g_led_config - feature = "rgb_matrix" - if info_data.get("features", {}).get("led_matrix", False): + # 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" - # 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 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}') return info_data @@ -755,9 +745,6 @@ def arm_processor_rules(info_data, rules): info_data['processor_type'] = 'arm' info_data['protocol'] = 'ChibiOS' - if 'bootloader' not in info_data: - info_data['bootloader'] = 'unknown' - if 'STM32' in info_data['processor']: info_data['platform'] = 'STM32' elif 'MCU_SERIES' in rules: @@ -775,9 +762,6 @@ def avr_processor_rules(info_data, rules): info_data['platform'] = rules['ARCH'] if 'ARCH' in rules else 'unknown' info_data['protocol'] = 'V-USB' if rules.get('MCU') in VUSB_PROCESSORS else 'LUFA' - if 'bootloader' not in info_data: - info_data['bootloader'] = 'atmel-dfu' - # FIXME(fauxpark/anyone): Eventually we should detect the protocol by looking at PROTOCOL inherited from mcu_selection.mk: # info_data['protocol'] = 'V-USB' if rules.get('PROTOCOL') == 'VUSB' else 'LUFA' |