diff options
Diffstat (limited to 'lib/python/qmk/info.py')
| -rw-r--r-- | lib/python/qmk/info.py | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 59a64095e7..e6d51e1239 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py | |||
| @@ -302,6 +302,24 @@ def _extract_features(info_data, rules): | |||
| 302 | return info_data | 302 | return info_data |
| 303 | 303 | ||
| 304 | 304 | ||
| 305 | def _extract_matrix_rules(info_data, rules): | ||
| 306 | """Find all the features enabled in rules.mk. | ||
| 307 | """ | ||
| 308 | if rules.get('CUSTOM_MATRIX', 'no') != 'no': | ||
| 309 | if 'matrix_pins' in info_data and 'custom' in info_data['matrix_pins']: | ||
| 310 | _log_warning(info_data, 'Custom Matrix is specified in both info.json and rules.mk, the rules.mk values win.') | ||
| 311 | |||
| 312 | if 'matrix_pins' not in info_data: | ||
| 313 | info_data['matrix_pins'] = {} | ||
| 314 | |||
| 315 | if rules['CUSTOM_MATRIX'] == 'lite': | ||
| 316 | info_data['matrix_pins']['custom_lite'] = True | ||
| 317 | else: | ||
| 318 | info_data['matrix_pins']['custom'] = True | ||
| 319 | |||
| 320 | return info_data | ||
| 321 | |||
| 322 | |||
| 305 | def _pin_name(pin): | 323 | def _pin_name(pin): |
| 306 | """Returns the proper representation for a pin. | 324 | """Returns the proper representation for a pin. |
| 307 | """ | 325 | """ |
| @@ -552,7 +570,6 @@ def _extract_matrix_info(info_data, config_c): | |||
| 552 | row_pins = config_c.get('MATRIX_ROW_PINS', '').replace('{', '').replace('}', '').strip() | 570 | row_pins = config_c.get('MATRIX_ROW_PINS', '').replace('{', '').replace('}', '').strip() |
| 553 | col_pins = config_c.get('MATRIX_COL_PINS', '').replace('{', '').replace('}', '').strip() | 571 | col_pins = config_c.get('MATRIX_COL_PINS', '').replace('{', '').replace('}', '').strip() |
| 554 | direct_pins = config_c.get('DIRECT_PINS', '').replace(' ', '')[1:-1] | 572 | direct_pins = config_c.get('DIRECT_PINS', '').replace(' ', '')[1:-1] |
| 555 | info_snippet = {} | ||
| 556 | 573 | ||
| 557 | if 'MATRIX_ROWS' in config_c and 'MATRIX_COLS' in config_c: | 574 | if 'MATRIX_ROWS' in config_c and 'MATRIX_COLS' in config_c: |
| 558 | if 'matrix_size' in info_data: | 575 | if 'matrix_size' in info_data: |
| @@ -567,26 +584,20 @@ def _extract_matrix_info(info_data, config_c): | |||
| 567 | if 'matrix_pins' in info_data and 'cols' in info_data['matrix_pins'] and 'rows' in info_data['matrix_pins']: | 584 | if 'matrix_pins' in info_data and 'cols' in info_data['matrix_pins'] and 'rows' in info_data['matrix_pins']: |
| 568 | _log_warning(info_data, 'Matrix pins are specified in both info.json and config.h, the config.h values win.') | 585 | _log_warning(info_data, 'Matrix pins are specified in both info.json and config.h, the config.h values win.') |
| 569 | 586 | ||
| 570 | info_snippet['cols'] = _extract_pins(col_pins) | 587 | if 'matrix_pins' not in info_data: |
| 571 | info_snippet['rows'] = _extract_pins(row_pins) | 588 | info_data['matrix_pins'] = {} |
| 589 | |||
| 590 | info_data['matrix_pins']['cols'] = _extract_pins(col_pins) | ||
| 591 | info_data['matrix_pins']['rows'] = _extract_pins(row_pins) | ||
| 572 | 592 | ||
| 573 | if direct_pins: | 593 | if direct_pins: |
| 574 | if 'matrix_pins' in info_data and 'direct' in info_data['matrix_pins']: | 594 | if 'matrix_pins' in info_data and 'direct' in info_data['matrix_pins']: |
| 575 | _log_warning(info_data, 'Direct pins are specified in both info.json and config.h, the config.h values win.') | 595 | _log_warning(info_data, 'Direct pins are specified in both info.json and config.h, the config.h values win.') |
| 576 | 596 | ||
| 577 | info_snippet['direct'] = _extract_direct_matrix(direct_pins) | 597 | if 'matrix_pins' not in info_data: |
| 578 | 598 | info_data['matrix_pins'] = {} | |
| 579 | if config_c.get('CUSTOM_MATRIX', 'no') != 'no': | ||
| 580 | if 'matrix_pins' in info_data and 'custom' in info_data['matrix_pins']: | ||
| 581 | _log_warning(info_data, 'Custom Matrix is specified in both info.json and config.h, the config.h values win.') | ||
| 582 | |||
| 583 | info_snippet['custom'] = True | ||
| 584 | |||
| 585 | if config_c['CUSTOM_MATRIX'] == 'lite': | ||
| 586 | info_snippet['custom_lite'] = True | ||
| 587 | 599 | ||
| 588 | if info_snippet: | 600 | info_data['matrix_pins']['direct'] = _extract_direct_matrix(direct_pins) |
| 589 | info_data['matrix_pins'] = info_snippet | ||
| 590 | 601 | ||
| 591 | return info_data | 602 | return info_data |
| 592 | 603 | ||
| @@ -755,6 +766,7 @@ def _extract_rules_mk(info_data, rules): | |||
| 755 | 766 | ||
| 756 | # Merge in config values that can't be easily mapped | 767 | # Merge in config values that can't be easily mapped |
| 757 | _extract_features(info_data, rules) | 768 | _extract_features(info_data, rules) |
| 769 | _extract_matrix_rules(info_data, rules) | ||
| 758 | 770 | ||
| 759 | return info_data | 771 | return info_data |
| 760 | 772 | ||
