From 8d44f11a5435f5e1efcd3d2076a6ca7a8e3a80cc Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 27 Sep 2023 01:55:01 +0100 Subject: [PATCH 1/3] Fix parsing/validation for 21939 --- data/mappings/info_config.hjson | 8 ++++---- data/schemas/keyboard.jsonschema | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data/mappings/info_config.hjson b/data/mappings/info_config.hjson index e68a4439d05e..5b89b73adfcd 100644 --- a/data/mappings/info_config.hjson +++ b/data/mappings/info_config.hjson @@ -67,9 +67,9 @@ "LEADER_TIMEOUT": {"info_key": "leader_key.timeout", "value_type": "int"}, // LED Matrix - "LED_DISABLE_WHEN_USB_SUSPENDED": {"info_key": "led_matrix.sleep", "value_type": "bool"}, + "LED_DISABLE_WHEN_USB_SUSPENDED": {"info_key": "led_matrix.sleep", "value_type": "bool", "to_json": false}, "LED_MATRIX_CENTER": {"info_key": "led_matrix.center_point", "value_type": "array.int"}, - "LED_MATRIX_KEYRELEASES": {"info_key": "led_matrix.react_on_keyup", "value_type": "bool"}, + "LED_MATRIX_KEYRELEASES": {"info_key": "led_matrix.react_on_keyup", "value_type": "bool", "to_json": false}, "LED_MATRIX_LED_FLUSH_LIMIT": {"info_key": "led_matrix.led_flush_limit", "value_type": "int"}, "LED_MATRIX_LED_PROCESS_LIMIT": {"info_key": "led_matrix.led_process_limit", "value_type": "int", "to_json": false}, "LED_MATRIX_MAXIMUM_BRIGHTNESS": {"info_key": "led_matrix.max_brightness", "value_type": "int"}, @@ -108,10 +108,10 @@ "PS2_DATA_PIN": {"info_key": "ps2.data_pin"}, // RGB Matrix - "RGB_DISABLE_WHEN_USB_SUSPENDED": {"info_key": "rgb_matrix.sleep", "value_type": "bool"}, + "RGB_DISABLE_WHEN_USB_SUSPENDED": {"info_key": "rgb_matrix.sleep", "value_type": "bool", "to_json": false}, "RGB_MATRIX_CENTER": {"info_key": "rgb_matrix.center_point", "value_type": "array.int"}, "RGB_MATRIX_HUE_STEP": {"info_key": "rgb_matrix.hue_steps", "value_type": "int"}, - "RGB_MATRIX_KEYRELEASES": {"info_key": "rgb_matrix.react_on_keyup", "value_type": "bool"}, + "RGB_MATRIX_KEYRELEASES": {"info_key": "rgb_matrix.react_on_keyup", "value_type": "bool", "to_json": false}, "RGB_MATRIX_LED_FLUSH_LIMIT": {"info_key": "rgb_matrix.led_flush_limit", "value_type": "int"}, "RGB_MATRIX_LED_PROCESS_LIMIT": {"info_key": "rgb_matrix.led_process_limit", "value_type": "int", "to_json": false}, "RGB_MATRIX_MAXIMUM_BRIGHTNESS": {"info_key": "rgb_matrix.max_brightness", "value_type": "int"}, diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 9c63ab8bcf5b..e0be8f5b972a 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -404,7 +404,7 @@ "speed_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, "led_flush_limit": {"$ref": "qmk.definitions.v1#/unsigned_int"}, "led_process_limit": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "react_on_keyup": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "react_on_keyup": {"type": "boolean"}, "sleep": {"type": "boolean"}, "split_count": { "type": "array", @@ -460,7 +460,7 @@ "speed_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, "led_flush_limit": {"$ref": "qmk.definitions.v1#/unsigned_int"}, "led_process_limit": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "react_on_keyup": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "react_on_keyup": {"type": "boolean"}, "sleep": {"type": "boolean"}, "split_count": { "type": "array", From 30eeddd29ccb54eb6532b6a9d4559f286216746b Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 27 Sep 2023 02:31:01 +0100 Subject: [PATCH 2/3] Fix parsing value_type=bool defines with no value --- data/mappings/info_config.hjson | 8 ++++---- lib/python/qmk/info.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data/mappings/info_config.hjson b/data/mappings/info_config.hjson index 5b89b73adfcd..e68a4439d05e 100644 --- a/data/mappings/info_config.hjson +++ b/data/mappings/info_config.hjson @@ -67,9 +67,9 @@ "LEADER_TIMEOUT": {"info_key": "leader_key.timeout", "value_type": "int"}, // LED Matrix - "LED_DISABLE_WHEN_USB_SUSPENDED": {"info_key": "led_matrix.sleep", "value_type": "bool", "to_json": false}, + "LED_DISABLE_WHEN_USB_SUSPENDED": {"info_key": "led_matrix.sleep", "value_type": "bool"}, "LED_MATRIX_CENTER": {"info_key": "led_matrix.center_point", "value_type": "array.int"}, - "LED_MATRIX_KEYRELEASES": {"info_key": "led_matrix.react_on_keyup", "value_type": "bool", "to_json": false}, + "LED_MATRIX_KEYRELEASES": {"info_key": "led_matrix.react_on_keyup", "value_type": "bool"}, "LED_MATRIX_LED_FLUSH_LIMIT": {"info_key": "led_matrix.led_flush_limit", "value_type": "int"}, "LED_MATRIX_LED_PROCESS_LIMIT": {"info_key": "led_matrix.led_process_limit", "value_type": "int", "to_json": false}, "LED_MATRIX_MAXIMUM_BRIGHTNESS": {"info_key": "led_matrix.max_brightness", "value_type": "int"}, @@ -108,10 +108,10 @@ "PS2_DATA_PIN": {"info_key": "ps2.data_pin"}, // RGB Matrix - "RGB_DISABLE_WHEN_USB_SUSPENDED": {"info_key": "rgb_matrix.sleep", "value_type": "bool", "to_json": false}, + "RGB_DISABLE_WHEN_USB_SUSPENDED": {"info_key": "rgb_matrix.sleep", "value_type": "bool"}, "RGB_MATRIX_CENTER": {"info_key": "rgb_matrix.center_point", "value_type": "array.int"}, "RGB_MATRIX_HUE_STEP": {"info_key": "rgb_matrix.hue_steps", "value_type": "int"}, - "RGB_MATRIX_KEYRELEASES": {"info_key": "rgb_matrix.react_on_keyup", "value_type": "bool", "to_json": false}, + "RGB_MATRIX_KEYRELEASES": {"info_key": "rgb_matrix.react_on_keyup", "value_type": "bool"}, "RGB_MATRIX_LED_FLUSH_LIMIT": {"info_key": "rgb_matrix.led_flush_limit", "value_type": "int"}, "RGB_MATRIX_LED_PROCESS_LIMIT": {"info_key": "rgb_matrix.led_process_limit", "value_type": "int", "to_json": false}, "RGB_MATRIX_MAXIMUM_BRIGHTNESS": {"info_key": "rgb_matrix.max_brightness", "value_type": "int"}, diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 9c8521a2a3ee..6de46382d54c 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -15,8 +15,8 @@ from qmk.makefile import parse_rules_mk_file from qmk.math import compute -true_values = ['1', 'on', 'yes'] -false_values = ['0', 'off', 'no'] +true_values = [True, '1', 'on', 'yes'] +false_values = [False, '0', 'off', 'no'] def _keyboard_in_layout_name(keyboard, layout): From 453ad51448fcc20d4cd58b3a7c82d69593a04c78 Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 27 Sep 2023 02:39:10 +0100 Subject: [PATCH 3/3] More isolated parsing fix --- lib/python/qmk/info.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 6de46382d54c..4806add67ae4 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -15,8 +15,8 @@ from qmk.makefile import parse_rules_mk_file from qmk.math import compute -true_values = [True, '1', 'on', 'yes'] -false_values = [False, '0', 'off', 'no'] +true_values = ['1', 'on', 'yes'] +false_values = ['0', 'off', 'no'] def _keyboard_in_layout_name(keyboard, layout): @@ -520,6 +520,8 @@ def _config_to_json(key_type, config_value): return list(map(str.strip, config_value.split(','))) elif key_type == 'bool': + if isinstance(config_value, bool): + return config_value return config_value in true_values elif key_type == 'hex':