summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli/generate
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2023-11-01 00:55:48 +0000
committerGitHub <noreply@github.com>2023-11-01 00:55:48 +0000
commita19ae3d78466588caa9caf7c38d1617932255733 (patch)
treec559d39f852ed6016ea677a630d10130e0cc71af /lib/python/qmk/cli/generate
parentb52aca0af83fade24c56b4bb7369f18183123bd3 (diff)
Add dd mapping for hardware based split handedness (#22369)
Diffstat (limited to 'lib/python/qmk/cli/generate')
-rwxr-xr-xlib/python/qmk/cli/generate/config_h.py13
-rwxr-xr-xlib/python/qmk/cli/generate/keyboard_c.py15
2 files changed, 21 insertions, 7 deletions
diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py
index 924834caef..2c624e3e9a 100755
--- a/lib/python/qmk/cli/generate/config_h.py
+++ b/lib/python/qmk/cli/generate/config_h.py
@@ -74,7 +74,14 @@ def generate_matrix_size(kb_info_json, config_h_lines):
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'))
@@ -141,6 +148,12 @@ 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 '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':
config_h_lines.append(generate_define('USE_I2C'))
diff --git a/lib/python/qmk/cli/generate/keyboard_c.py b/lib/python/qmk/cli/generate/keyboard_c.py
index 325624c9cc..f8a2372cf3 100755
--- a/lib/python/qmk/cli/generate/keyboard_c.py
+++ b/lib/python/qmk/cli/generate/keyboard_c.py
@@ -63,13 +63,14 @@ def _gen_matrix_mask(info_data):
cols = info_data['matrix_size']['cols']
rows = info_data['matrix_size']['rows']
- # Default mask to everything enabled
- mask = [['1'] * cols for i in range(rows)]
-
- # Automatically mask out dip_switch.matrix_grid locations
- matrix_grid = info_data.get('dip_switch', {}).get('matrix_grid', [])
- for row, col in matrix_grid:
- mask[row][col] = '0'
+ # 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')