mirror of
https://github.com/systemd/systemd
synced 2024-07-21 02:05:05 +00:00
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.
This commit is contained in:
parent
0c3c9a4096
commit
9fc168cd1e
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue