diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-07-22 19:23:19 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-07-22 19:25:43 -0400 |
commit | 494d16aa0c50df4bafa4f2c885756a5babc1ad45 (patch) | |
tree | 08ffb20291442b396e9b35a2139ffc2e4276533f /hwdb | |
parent | 8ae12e733c5369a7e6360eaa5c942ea05fe44bde (diff) | |
download | systemd-494d16aa0c50df4bafa4f2c885756a5babc1ad45.tar.gz |
hwdb: disallow acceleration matrices with trivial rows
All zeros means that we cannot detect acceleration in that direction.
Related to #6430.
Diffstat (limited to 'hwdb')
-rwxr-xr-x | hwdb/parse_hwdb.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/hwdb/parse_hwdb.py b/hwdb/parse_hwdb.py index c7b49b83df..a25ac8d904 100755 --- a/hwdb/parse_hwdb.py +++ b/hwdb/parse_hwdb.py @@ -168,6 +168,20 @@ def check_one_default(prop, settings): if len(defaults) > 1: error('More than one star entry: {!r}', prop) +def check_one_mount_matrix(prop, value): + numbers = [s for s in value if s not in {';', ','}] + if len(numbers) != 9: + error('Wrong accel matrix: {!r}', prop) + try: + numbers = [abs(float(number)) for number in numbers] + except ValueError: + error('Wrong accel matrix: {!r}', prop) + bad_x, bad_y, bad_z = max(numbers[0:3]) == 0, max(numbers[3:6]) == 0, max(numbers[6:9]) == 0 + if bad_x or bad_y or bad_z: + error('Mount matrix is all zero in {} row: {!r}', + 'x' if bad_x else ('y' if bad_y else 'z'), + prop) + def check_one_keycode(prop, value): if value != '!' and ecodes is not None: key = 'KEY_' + value.upper() @@ -194,6 +208,8 @@ def check_properties(groups): prop_names.add(parsed.NAME) if parsed.NAME == 'MOUSE_DPI': check_one_default(prop, parsed.VALUE.SETTINGS) + elif parsed.NAME == 'ACCEL_MOUNT_MATRIX': + check_one_mount_matrix(prop, parsed.VALUE) elif parsed.NAME.startswith('KEYBOARD_KEY_'): check_one_keycode(prop, parsed.VALUE) |