summaryrefslogtreecommitdiff
path: root/lib/python/qmk/info.py
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2022-01-17 08:44:34 +1100
committerGitHub <noreply@github.com>2022-01-17 08:44:34 +1100
commitc72ed7c02473dec4da6cb263c1e0fb2ca4856b94 (patch)
tree4c218562b5ed5bbd34da67f37093ba6f47012d57 /lib/python/qmk/info.py
parent557fbbd6afbff3bdd571e580ea79ba3905a28ce4 (diff)
downloadqmk_firmware-c72ed7c02473dec4da6cb263c1e0fb2ca4856b94.tar.gz
qmk_firmware-c72ed7c02473dec4da6cb263c1e0fb2ca4856b94.zip
CLI: Parse USB device version BCD (#14580)
* CLI: Parse USB device version BCD * Apply suggestions
Diffstat (limited to 'lib/python/qmk/info.py')
-rw-r--r--lib/python/qmk/info.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py
index 6bdf2cb166..905f10ecc2 100644
--- a/lib/python/qmk/info.py
+++ b/lib/python/qmk/info.py
@@ -387,6 +387,19 @@ def _extract_matrix_info(info_data, config_c):
return info_data
+# TODO: kill off usb.device_ver in favor of usb.device_version
+def _extract_device_version(info_data):
+ if info_data.get('usb'):
+ if info_data['usb'].get('device_version') and not info_data['usb'].get('device_ver'):
+ (major, minor, revision) = info_data['usb']['device_version'].split('.', 3)
+ info_data['usb']['device_ver'] = f'0x{major.zfill(2)}{minor}{revision}'
+ if not info_data['usb'].get('device_version') and info_data['usb'].get('device_ver'):
+ major = int(info_data['usb']['device_ver'][2:4])
+ minor = int(info_data['usb']['device_ver'][4])
+ revision = int(info_data['usb']['device_ver'][5])
+ info_data['usb']['device_version'] = f'{major}.{minor}.{revision}'
+
+
def _extract_config_h(info_data):
"""Pull some keyboard information from existing config.h files
"""
@@ -430,6 +443,13 @@ def _extract_config_h(info_data):
elif key_type == 'int':
dotty_info[info_key] = int(config_c[config_key])
+ elif key_type == 'bcd_version':
+ major = int(config_c[config_key][2:4])
+ minor = int(config_c[config_key][4])
+ revision = int(config_c[config_key][5])
+
+ dotty_info[info_key] = f'{major}.{minor}.{revision}'
+
else:
dotty_info[info_key] = config_c[config_key]
@@ -444,6 +464,7 @@ def _extract_config_h(info_data):
_extract_split_main(info_data, config_c)
_extract_split_transport(info_data, config_c)
_extract_split_right_pins(info_data, config_c)
+ _extract_device_version(info_data)
return info_data