From: Peter Hutterer Date: Fri, 29 Jan 2021 04:57:30 +0000 (+1000) Subject: hwdb: check for the right set of MOUSE_WHEEL_CLICK_ properties X-Git-Tag: v248-rc1~238 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9fc168cd1ee301b68b0e152284a93287430a8951;p=thirdparty%2Fsystemd.git hwdb: check for the right set of MOUSE_WHEEL_CLICK_ properties As documented at the top of the file we require the normal property if we have the horizontal property, and we require the CLICK_ANGLE property if the CLICK_COUNT property is present. Codify this into the hwdb parser so we can pick up on it. --- diff --git a/hwdb.d/parse_hwdb.py b/hwdb.d/parse_hwdb.py index d76a290f73e..24964ff8d16 100755 --- a/hwdb.d/parse_hwdb.py +++ b/hwdb.d/parse_hwdb.py @@ -246,10 +246,19 @@ def check_one_keycode(prop, value): 'KBD_LCD_MENU' in key): error('Keycode {} unknown', key) +def check_wheel_clicks(properties): + pairs = (('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', 'MOUSE_WHEEL_CLICK_COUNT'), + ('MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL', 'MOUSE_WHEEL_CLICK_ANGLE'), + ('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', 'MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL'), + ('MOUSE_WHEEL_CLICK_COUNT', 'MOUSE_WHEEL_CLICK_ANGLE')) + for pair in pairs: + if pair[0] in properties and pair[1] not in properties: + error('{} requires {} to be specified', *pair) + def check_properties(groups): grammar = property_grammar() for matches, props in groups: - prop_names = set() + seen_props = {} for prop in props: # print('--', prop) prop = prop.partition('#')[0].rstrip() @@ -259,9 +268,9 @@ def check_properties(groups): error('Failed to parse: {!r}', prop) continue # print('{!r}'.format(parsed)) - if parsed.NAME in prop_names: + if parsed.NAME in seen_props: error('Property {} is duplicated', parsed.NAME) - prop_names.add(parsed.NAME) + seen_props[parsed.NAME] = parsed.VALUE if parsed.NAME == 'MOUSE_DPI': check_one_default(prop, parsed.VALUE.SETTINGS) elif parsed.NAME == 'ACCEL_MOUNT_MATRIX': @@ -270,6 +279,8 @@ def check_properties(groups): val = parsed.VALUE if isinstance(parsed.VALUE, str) else parsed.VALUE[0] check_one_keycode(prop, val) + check_wheel_clicks(seen_props) + def print_summary(fname, groups): n_matches = sum(len(matches) for matches, props in groups) n_props = sum(len(props) for matches, props in groups)