Add dd mapping for hardware based split handedness (#22369)

master
Joel Challis 2023-11-01 00:55:48 +00:00 committed by GitHub
parent b52aca0af8
commit a19ae3d784
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 10 deletions

View File

@ -154,6 +154,8 @@
// Split Keyboard
"SOFT_SERIAL_PIN": {"info_key": "split.soft_serial_pin"},
"SOFT_SERIAL_SPEED": {"info_key": "split.soft_serial_speed"},
"SPLIT_HAND_MATRIX_GRID": {"info_key": "split.handedness.matrix_grid", "value_type": "array", "to_c": false},
"SPLIT_HAND_PIN": {"info_key": "split.handedness.pin"},
"SPLIT_USB_DETECT": {"info_key": "split.usb_detect.enabled", "value_type": "bool"},
"SPLIT_USB_TIMEOUT": {"info_key": "split.usb_detect.timeout", "value_type": "int"},
"SPLIT_USB_TIMEOUT_POLL": {"info_key": "split.usb_detect.polling_interval", "value_type": "int"},

View File

@ -640,10 +640,6 @@
}
}
},
"matrix_grid": {
"type": "array",
"items": {"$ref": "qmk.definitions.v1#/mcu_pin"}
},
"matrix_pins": {
"type": "object",
"additionalProperties": false,
@ -681,6 +677,18 @@
}
}
},
"handedness": {
"type": "object",
"additionalProperties": false,
"properties": {
"pin": {"$ref": "qmk.definitions.v1#/mcu_pin"},
"matrix_grid": {
"$ref": "qmk.definitions.v1#/mcu_pin_array",
"minItems": 2,
"maxItems": 2
}
}
},
"soft_serial_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"},
"soft_serial_speed": {
"type": "integer",
@ -736,6 +744,11 @@
"type": "string",
"enum": ["eeprom", "left", "matrix_grid", "pin", "right"],
"$comment": "Deprecated: use config.h options for now"
},
"matrix_grid": {
"type": "array",
"items": {"$ref": "qmk.definitions.v1#/mcu_pin"},
"$comment": "Deprecated: use split.handedness.matrix_grid instead"
}
}
},

View File

@ -647,6 +647,12 @@ Configures the [Split Keyboard](feature_split_keyboard.md) feature.
* `right`
* `rotary`
* See [Encoder](#encoder) config.
* `handedness`
* `pin`
* The GPIO pin connected to determine handedness.
* `matrix_grid`
* The GPIO pins of the matrix position which determines the handedness.
* Example: `["A1", "B5"]`
* `matrix_pins`
* `right`
* See [Matrix](#matrix) config.

View File

@ -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'))

View File

@ -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)]
# Default mask to everything disabled
mask = [['0'] * 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'
# 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')

View File

@ -352,6 +352,14 @@ def _extract_secure_unlock(info_data, config_c):
info_data['secure']['unlock_sequence'] = unlock_array
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):
# Figure out the transport method
if config_c.get('USE_I2C') is True:
@ -543,6 +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_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)