summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2025-11-08 20:48:48 +0000
committerGitHub <noreply@github.com>2025-11-08 20:48:48 +0000
commit6e35013bc2e30af022cdb8c176e869c5c94ee17a (patch)
treec1a5e1142f89851d1a99508e34242c9e793cc1f0 /lib
parentcf05c7d1e4bd93ccd184e3a78eaba9f2eeb5976e (diff)
Generate `CUSTOM_MATRIX = lite` without `matrix_pins.custom` (#25453)
Diffstat (limited to 'lib')
-rwxr-xr-xlib/python/qmk/cli/generate/rules_mk.py9
-rw-r--r--lib/python/qmk/info.py42
2 files changed, 31 insertions, 20 deletions
diff --git a/lib/python/qmk/cli/generate/rules_mk.py b/lib/python/qmk/cli/generate/rules_mk.py
index 358a22fd1d..16084bded1 100755
--- a/lib/python/qmk/cli/generate/rules_mk.py
+++ b/lib/python/qmk/cli/generate/rules_mk.py
@@ -96,11 +96,10 @@ def generate_rules_mk(cli):
96 rules_mk_lines.append(generate_rule('SPLIT_TRANSPORT', 'custom')) 96 rules_mk_lines.append(generate_rule('SPLIT_TRANSPORT', 'custom'))
97 97
98 # Set CUSTOM_MATRIX, if needed 98 # Set CUSTOM_MATRIX, if needed
99 if kb_info_json.get('matrix_pins', {}).get('custom'): 99 if kb_info_json.get('matrix_pins', {}).get('custom_lite'):
100 if kb_info_json.get('matrix_pins', {}).get('custom_lite'): 100 rules_mk_lines.append(generate_rule('CUSTOM_MATRIX', 'lite'))
101 rules_mk_lines.append(generate_rule('CUSTOM_MATRIX', 'lite')) 101 elif kb_info_json.get('matrix_pins', {}).get('custom'):
102 else: 102 rules_mk_lines.append(generate_rule('CUSTOM_MATRIX', 'yes'))
103 rules_mk_lines.append(generate_rule('CUSTOM_MATRIX', 'yes'))
104 103
105 if converter: 104 if converter:
106 rules_mk_lines.append(generate_rule('CONVERT_TO', converter)) 105 rules_mk_lines.append(generate_rule('CONVERT_TO', converter))
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
305def _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
305def _pin_name(pin): 323def _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