mirror of
https://github.com/qmk/qmk_firmware.git
synced 2026-07-11 11:26:17 -04:00
Merge remote-tracking branch 'origin/develop' into xap
This commit is contained in:
@@ -72,6 +72,19 @@ def generate_matrix_size(kb_info_json, config_h_lines):
|
||||
config_h_lines.append(generate_define('MATRIX_ROWS', kb_info_json['matrix_size']['rows']))
|
||||
|
||||
|
||||
def generate_matrix_masked(kb_info_json, config_h_lines):
|
||||
""""Enable matrix mask if required"""
|
||||
mask_required = False
|
||||
|
||||
if 'matrix_grid' in kb_info_json.get('dip_switch', {}):
|
||||
mask_required = True
|
||||
if 'matrix_grid' in kb_info_json.get('split', {}).get('handedness', {}):
|
||||
mask_required = True
|
||||
|
||||
if mask_required:
|
||||
config_h_lines.append(generate_define('MATRIX_MASKED'))
|
||||
|
||||
|
||||
def generate_config_items(kb_info_json, config_h_lines):
|
||||
"""Iterate through the info_config map to generate basic config values.
|
||||
"""
|
||||
@@ -80,9 +93,9 @@ def generate_config_items(kb_info_json, config_h_lines):
|
||||
for config_key, info_dict in info_config_map.items():
|
||||
info_key = info_dict['info_key']
|
||||
key_type = info_dict.get('value_type', 'raw')
|
||||
to_config = info_dict.get('to_config', True)
|
||||
to_c = info_dict.get('to_c', True)
|
||||
|
||||
if not to_config:
|
||||
if not to_c:
|
||||
continue
|
||||
|
||||
try:
|
||||
@@ -135,23 +148,11 @@ def generate_encoder_config(encoder_json, config_h_lines, postfix=''):
|
||||
|
||||
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(generate_define('SPLIT_HAND_PIN'))
|
||||
elif kb_info_json['split']['primary'] == 'matrix_grid':
|
||||
config_h_lines.append(generate_define('SPLIT_HAND_MATRIX_GRID', f'{{ {",".join(kb_info_json["split"]["matrix_grid"])} }}'))
|
||||
elif kb_info_json['split']['primary'] == 'eeprom':
|
||||
config_h_lines.append(generate_define('EE_HANDS'))
|
||||
if 'handedness' in kb_info_json['split']:
|
||||
# TODO: change SPLIT_HAND_MATRIX_GRID to require brackets
|
||||
handedness = kb_info_json['split']['handedness']
|
||||
if 'matrix_grid' in handedness:
|
||||
config_h_lines.append(generate_define('SPLIT_HAND_MATRIX_GRID', ', '.join(handedness['matrix_grid'])))
|
||||
|
||||
if 'protocol' in kb_info_json['split'].get('transport', {}):
|
||||
if kb_info_json['split']['transport']['protocol'] == 'i2c':
|
||||
@@ -196,6 +197,8 @@ def generate_config_h(cli):
|
||||
|
||||
generate_matrix_size(kb_info_json, config_h_lines)
|
||||
|
||||
generate_matrix_masked(kb_info_json, config_h_lines)
|
||||
|
||||
if 'matrix_pins' in kb_info_json:
|
||||
config_h_lines.append(matrix_pins(kb_info_json['matrix_pins']))
|
||||
|
||||
|
||||
@@ -57,6 +57,32 @@ def _gen_led_config(info_data):
|
||||
return lines
|
||||
|
||||
|
||||
def _gen_matrix_mask(info_data):
|
||||
"""Convert info.json content to matrix_mask
|
||||
"""
|
||||
cols = info_data['matrix_size']['cols']
|
||||
rows = info_data['matrix_size']['rows']
|
||||
|
||||
# Default mask to everything disabled
|
||||
mask = [['0'] * cols for i in range(rows)]
|
||||
|
||||
# Mirror layout macros squashed on top of each other
|
||||
for layout_data in info_data['layouts'].values():
|
||||
for key_data in layout_data['layout']:
|
||||
row, col = key_data['matrix']
|
||||
mask[row][col] = '1'
|
||||
|
||||
lines = []
|
||||
lines.append('#ifdef MATRIX_MASKED')
|
||||
lines.append('__attribute__((weak)) const matrix_row_t matrix_mask[] = {')
|
||||
for i in range(rows):
|
||||
lines.append(f' 0b{"".join(reversed(mask[i]))},')
|
||||
lines.append('};')
|
||||
lines.append('#endif')
|
||||
|
||||
return lines
|
||||
|
||||
|
||||
@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', arg_only=True, type=keyboard_folder, completer=keyboard_completer, required=True, help='Keyboard to generate keyboard.c for.')
|
||||
@@ -70,6 +96,7 @@ def generate_keyboard_c(cli):
|
||||
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_matrix_mask(kb_info_json))
|
||||
|
||||
# Show the results
|
||||
dump_lines(cli.args.output, keyboard_h_lines, cli.args.quiet)
|
||||
|
||||
+7
-50
@@ -352,55 +352,12 @@ def _extract_secure_unlock(info_data, config_c):
|
||||
info_data['secure']['unlock_sequence'] = unlock_array
|
||||
|
||||
|
||||
def _extract_split_main(info_data, config_c):
|
||||
"""Populate data about the split configuration
|
||||
"""
|
||||
# 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 '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']['main'] = 'pin'
|
||||
|
||||
if config_c.get('SPLIT_HAND_MATRIX_GRID'):
|
||||
if 'split' not in info_data:
|
||||
info_data['split'] = {}
|
||||
|
||||
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']['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 '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']['main'] = 'eeprom'
|
||||
|
||||
if config_c.get('MASTER_RIGHT') is True:
|
||||
if 'split' not in info_data:
|
||||
info_data['split'] = {}
|
||||
|
||||
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']['main'] = 'right'
|
||||
|
||||
if config_c.get('MASTER_LEFT') is True:
|
||||
if 'split' not in info_data:
|
||||
info_data['split'] = {}
|
||||
|
||||
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']['main'] = 'left'
|
||||
def _extract_split_handedness(info_data, config_c):
|
||||
# Migrate
|
||||
split = info_data.get('split', {})
|
||||
if 'matrix_grid' in split:
|
||||
split['handedness'] = split.get('handedness', {})
|
||||
split['handedness']['matrix_grid'] = split.pop('matrix_grid')
|
||||
|
||||
|
||||
def _extract_split_transport(info_data, config_c):
|
||||
@@ -594,7 +551,7 @@ def _extract_config_h(info_data, config_c):
|
||||
_extract_matrix_info(info_data, config_c)
|
||||
_extract_audio(info_data, config_c)
|
||||
_extract_secure_unlock(info_data, config_c)
|
||||
_extract_split_main(info_data, config_c)
|
||||
_extract_split_handedness(info_data, config_c)
|
||||
_extract_split_transport(info_data, config_c)
|
||||
_extract_split_right_pins(info_data, config_c)
|
||||
_extract_encoders(info_data, config_c)
|
||||
|
||||
Reference in New Issue
Block a user