summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am6
-rw-r--r--hwdb/60-keyboard.hwdb35
-rw-r--r--hwdb/70-mouse.hwdb9
-rw-r--r--hwdb/70-pointingstick.hwdb14
-rwxr-xr-xhwdb/parse_hwdb.py183
5 files changed, 212 insertions, 35 deletions
diff --git a/Makefile.am b/Makefile.am
index bf853c8f90..d4e3e9a013 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3872,7 +3872,8 @@ TESTS += \
if HAVE_PYTHON
TESTS += \
- test/rule-syntax-check.py
+ test/rule-syntax-check.py \
+ hwdb/parse_hwdb.py
if HAVE_SYSV_COMPAT
TESTS += \
@@ -3924,7 +3925,8 @@ EXTRA_DIST += \
test/udev-test.pl \
test/rule-syntax-check.py \
test/sysv-generator-test.py \
- test/mocks/fsck
+ test/mocks/fsck \
+ hwdb/parse_hwdb.py
# ------------------------------------------------------------------------------
ata_id_SOURCES = \
diff --git a/hwdb/60-keyboard.hwdb b/hwdb/60-keyboard.hwdb
index 1f96d9e3cc..1176881650 100644
--- a/hwdb/60-keyboard.hwdb
+++ b/hwdb/60-keyboard.hwdb
@@ -213,7 +213,7 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnDell*:pn*
KEYBOARD_KEY_8a=suspend # Fn+F1 hibernate
KEYBOARD_KEY_8b=switchvideomode # Fn+F8 CRT/LCD (high keycode: "displaytoggle")
KEYBOARD_KEY_8c=unknown # Fn+Right Auto Brightness
- KEYBOARD_KEY_8F=switchvideomode # Fn+F7 aspect ratio
+ KEYBOARD_KEY_8f=switchvideomode # Fn+F7 aspect ratio
KEYBOARD_KEY_90=previoussong # Front panel previous song
KEYBOARD_KEY_91=prog1 # Wi-Fi Catcher (Dell-specific)
KEYBOARD_KEY_92=media # MediaDirect button (house icon)
@@ -482,8 +482,7 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnHewlett-Packard*:pnFalco:pvr*
KEYBOARD_KEY_43=volumedown
KEYBOARD_KEY_44=volumeup
KEYBOARD_KEY_db=search # Same position as caps lock key on most keyboards
-# KEYBOARD_KEY_3e=fullscreen, no defined key sym
-
+ # KEYBOARD_KEY_3e=fullscreen, no defined key sym
# HP EliteBook 725 G2
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnHewlett-Packard*:pnHPLicrice:pvr*
@@ -694,7 +693,7 @@ evdev:input:b0003v046DpC308*
KEYBOARD_KEY_90003=finance # Finance
KEYBOARD_KEY_90004=prog1 # My Sites
KEYBOARD_KEY_90005=prog2 # Community
- KEYBOARD_KEY_C0183=media # Media
+ KEYBOARD_KEY_c0183=media # Media
# Cordless Desktop S510
evdev:input:b0003v046DpC50C*
@@ -763,18 +762,18 @@ evdev:input:b0003v046DpC309*
KEYBOARD_KEY_90002=camera # webcam
KEYBOARD_KEY_90003=prog1 # iTouch
KEYBOARD_KEY_90004=shop # Shopping
- KEYBOARD_KEY_C0201=new # New (F1)
- KEYBOARD_KEY_C0289=reply # Reply mail (F2)
- KEYBOARD_KEY_C028B=forwardmail # Forward mail (F3)
- KEYBOARD_KEY_C028C=send # Send (F4)
- KEYBOARD_KEY_C021A=undo # Undo (F5).
- KEYBOARD_KEY_C0279=redo # Redo (F6).
- KEYBOARD_KEY_C0208=print # Print (F7)
- KEYBOARD_KEY_C0207=save # Save (F8)
- KEYBOARD_KEY_C0194=file # My Computer (F9)
- KEYBOARD_KEY_C01A7=documents # My Documents (F10)
- KEYBOARD_KEY_C01B6=images # My Pictures (F11) ??
- KEYBOARD_KEY_C01B7=sound # My Music (F12) ??
+ KEYBOARD_KEY_c0201=new # New (F1)
+ KEYBOARD_KEY_c0289=reply # Reply mail (F2)
+ KEYBOARD_KEY_c028b=forwardmail # Forward mail (F3)
+ KEYBOARD_KEY_c028c=send # Send (F4)
+ KEYBOARD_KEY_c021a=undo # Undo (F5).
+ KEYBOARD_KEY_c0279=redo # Redo (F6).
+ KEYBOARD_KEY_c0208=print # Print (F7)
+ KEYBOARD_KEY_c0207=save # Save (F8)
+ KEYBOARD_KEY_c0194=file # My Computer (F9)
+ KEYBOARD_KEY_c01a7=documents # My Documents (F10)
+ KEYBOARD_KEY_c01b6=images # My Pictures (F11) ??
+ KEYBOARD_KEY_c01b7=sound # My Music (F12) ??
###########################################################
@@ -897,7 +896,7 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnOLPC:pnXO:*
KEYBOARD_KEY_c2=f8
KEYBOARD_KEY_c3=f9
KEYBOARD_KEY_c4=f10
- KEYBOARD_KEY_c7=f11
+ # KEYBOARD_KEY_c7=f11 # FIXME!
KEYBOARD_KEY_d8=f12
KEYBOARD_KEY_f7=f13
KEYBOARD_KEY_f6=f14
@@ -917,7 +916,7 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnOLPC:pnXO:*
KEYBOARD_KEY_c9=pageup
KEYBOARD_KEY_d1=pagedown
KEYBOARD_KEY_c7=home
- KEYBOARD_KEY_cF=end
+ KEYBOARD_KEY_cf=end
KEYBOARD_KEY_73=hp
KEYBOARD_KEY_7e=hp
KEYBOARD_KEY_db=leftmeta # left grab
diff --git a/hwdb/70-mouse.hwdb b/hwdb/70-mouse.hwdb
index c569d66d47..d8215a6179 100644
--- a/hwdb/70-mouse.hwdb
+++ b/hwdb/70-mouse.hwdb
@@ -297,7 +297,7 @@ mouse:usb:v046dpc049:name:Logitech USB Gaming Mouse:
mouse:usb:v046dpc24e:name:Logitech G500s Laser Gaming Mouse:
MOUSE_DPI=400@500 *800@500 2000@500
- # Logitech G9
+# Logitech G9
mouse:usb:v046dpc048:name:Logitech G9 Laser Mouse:
MOUSE_DPI=400@1000 800@1000 *1600@1000
@@ -342,8 +342,6 @@ mouse:usb:v046dp402d:name:Logitech M560:
mouse:usb:v046dpc52b:name:Logitech Unifying Device. Wireless PID:402d:
MOUSE_DPI=1000@125
-# Logitech V220 Cordless Optical Mouse
-mouse:usb:v046dpc51b:name:Logitech USB Receiver:
# Logitech Performance MX
mouse:usb:v046dp101a:name:Logitech Performance MX:
# Logitech MX Master
@@ -373,11 +371,6 @@ mouse:usb:v046dp4027:name:Logitech T620:
mouse:usb:v046dpc52b:name:Logitech Unifying Device. Wireless PID:4027:
MOUSE_DPI=1200@250
-# Logitech LX8 Cordless Laser Mouse
-mouse:usb:v046dpc51b:name:Logitech USB Receiver:
- MOUSE_DPI=1300@125
- MOUSE_WHEEL_CLICK_ANGLE=15
-
# Logitech ZoneTouch Mouse T400
mouse:usb:v046dp4026:name:Logitech T400:
mouse:usb:v046dpc52b:name:Logitech Unifying Device. Wireless PID:4026:
diff --git a/hwdb/70-pointingstick.hwdb b/hwdb/70-pointingstick.hwdb
index c0ec8ffbe0..5e2ab393bd 100644
--- a/hwdb/70-pointingstick.hwdb
+++ b/hwdb/70-pointingstick.hwdb
@@ -77,15 +77,15 @@
# Latitude D620
evdev:name:*DualPoint Stick:dmi:bvn*:bvr*:bd*:svnDellInc.:pnLatitudeD620*:pvr*
- POINTINGSTICK_CONST_ACCEL=0.5
+ POINTINGSTICK_CONST_ACCEL=0.5
# Latitude E6320
evdev:name:*DualPoint Stick:dmi:bvn*:bvr*:bd*:svnDellInc.:pnLatitudeE6320*:pvr*
- POINTINGSTICK_CONST_ACCEL=2.0
+ POINTINGSTICK_CONST_ACCEL=2.0
# Latitude E6400
evdev:name:*DualPoint Stick:dmi:bvn*:bvr*:bd*:svnDellInc.:pnLatitudeE6400*:pvr*
- POINTINGSTICK_CONST_ACCEL=1.5
+ POINTINGSTICK_CONST_ACCEL=1.5
#########################################
# Lenovo
@@ -108,13 +108,13 @@ evdev:name:TPPS/2 IBM TrackPoint:dmi:bvn*:bvr*:bd*:svnLENOVO:pn*:pvrThinkPad??60
evdev:name:TPPS/2 IBM TrackPoint:dmi:bvn*:bvr*:bd*:svnLENOVO:pn*:pvrThinkPadX1Carbon3rd:*
# Lenovo Thinkpad X1 Carbon 4th gen
evdev:name:TPPS/2 IBM TrackPoint:dmi:bvn*:bvr*:bd*:svnLENOVO:pn*:pvrThinkPadX1Carbon4th:*
- POINTINGSTICK_SENSITIVITY=200
- POINTINGSTICK_CONST_ACCEL=1.0
+ POINTINGSTICK_SENSITIVITY=200
+ POINTINGSTICK_CONST_ACCEL=1.0
# Lenovo Thinkpad X200s / X201s
# Note these come with 2 revisions of keyboard, with the trackpoints having a
# different sensitivity in the different revisions. 1.25 is a bit slow for the
# least sensitive revision, but it is better to be a bit slow than too fast.
evdev:name:TPPS/2 IBM TrackPoint:dmi:bvn*:bvr*:bd*:svnLENOVO:pn*:pvrThinkPadX20?s:*
- POINTINGSTICK_SENSITIVITY=200
- POINTINGSTICK_CONST_ACCEL=1.25
+ POINTINGSTICK_SENSITIVITY=200
+ POINTINGSTICK_CONST_ACCEL=1.25
diff --git a/hwdb/parse_hwdb.py b/hwdb/parse_hwdb.py
new file mode 100755
index 0000000000..99d034b4e0
--- /dev/null
+++ b/hwdb/parse_hwdb.py
@@ -0,0 +1,183 @@
+#!/usr/bin/python3
+# -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */
+#
+# This file is part of systemd.
+#
+# Copyright 2016 Zbigniew Jędrzejewski-Szmek
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+#
+# systemd is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with systemd; If not, see <http://www.gnu.org/licenses/>.
+
+import functools
+import glob
+import string
+import sys
+import os
+
+try:
+ from pyparsing import (Word, White, Literal, ParserElement, Regex,
+ LineStart, LineEnd,
+ ZeroOrMore, OneOrMore, Combine, Or, Optional, Suppress, Group,
+ nums, alphanums, printables,
+ stringEnd, pythonStyleComment,
+ ParseBaseException)
+except ImportError:
+ print('pyparsing is not available')
+ sys.exit(77)
+
+try:
+ from evdev.ecodes import ecodes
+except ImportError:
+ ecodes = None
+ print('WARNING: evdev is not available')
+
+EOL = LineEnd().suppress()
+EMPTYLINE = LineStart() + LineEnd()
+COMMENTLINE = pythonStyleComment + EOL
+INTEGER = Word(nums)
+REAL = Combine((INTEGER + Optional('.' + Optional(INTEGER))) ^ ('.' + INTEGER))
+UDEV_TAG = Word(string.ascii_uppercase, alphanums + '_')
+
+TYPES = {'mouse': ('usb', 'bluetooth', 'ps2', '*'),
+ 'evdev': ('name', 'atkbd', 'input'),
+ 'touchpad': ('i8042', 'rmi', 'bluetooth', 'usb'),
+ 'keyboard': ('name', ),
+ }
+
+@functools.lru_cache()
+def hwdb_grammar():
+ ParserElement.setDefaultWhitespaceChars('')
+
+ prefix = Or(category + ':' + Or(conn) + ':'
+ for category, conn in TYPES.items())
+ matchline = Combine(prefix + Word(printables + ' ' + '®')) + EOL
+ propertyline = (White(' ', exact=1).suppress() +
+ Combine(UDEV_TAG - '=' - Word(alphanums + '_=:@*.! ') - Optional(pythonStyleComment)) +
+ EOL)
+ propertycomment = White(' ', exact=1) + pythonStyleComment + EOL
+
+ group = (OneOrMore(matchline('MATCHES*') ^ COMMENTLINE.suppress()) -
+ OneOrMore(propertyline('PROPERTIES*') ^ propertycomment.suppress()) -
+ (EMPTYLINE ^ stringEnd()).suppress() )
+ commentgroup = OneOrMore(COMMENTLINE).suppress() - EMPTYLINE.suppress()
+
+ grammar = OneOrMore(group('GROUPS*') ^ commentgroup) + stringEnd()
+
+ return grammar
+
+@functools.lru_cache()
+def property_grammar():
+ ParserElement.setDefaultWhitespaceChars(' ')
+
+ setting = Optional('*')('DEFAULT') + INTEGER('DPI') + Suppress('@') + INTEGER('HZ')
+ props = (('MOUSE_DPI', Group(OneOrMore(setting('SETTINGS*')))),
+ ('MOUSE_WHEEL_CLICK_ANGLE', INTEGER),
+ ('ID_INPUT_TRACKBALL', Literal('1')),
+ ('POINTINGSTICK_SENSITIVITY', INTEGER),
+ ('POINTINGSTICK_CONST_ACCEL', REAL),
+ ('ID_INPUT_TOUCHPAD_INTEGRATION', Or(('internal', 'external'))),
+ )
+ fixed_props = [Literal(name)('NAME') - Suppress('=') - val('VALUE')
+ for name, val in props]
+ kbd_props = [Regex(r'KEYBOARD_KEY_[0-9a-f]+')('NAME')
+ - Suppress('=') -
+ ('!' ^ (Optional('!') - Word(alphanums + '_')))('VALUE')
+ ]
+ abs_props = [Regex(r'EVDEV_ABS_[0-9a-f]{2}')('NAME')
+ - Suppress('=') -
+ Word(nums + ':')('VALUE')
+ ]
+
+ grammar = Or(fixed_props + kbd_props + abs_props)
+
+ return grammar
+
+ERROR = False
+def error(fmt, *args, **kwargs):
+ global ERROR
+ ERROR = True
+ print(fmt.format(*args, **kwargs))
+
+def convert_properties(group):
+ matches = [m[0] for m in group.MATCHES]
+ props = [p[0] for p in group.PROPERTIES]
+ return matches, props
+
+def parse(fname):
+ grammar = hwdb_grammar()
+ try:
+ parsed = grammar.parseFile(fname)
+ except ParseBaseException as e:
+ error('Cannot parse {}: {}', fname, e)
+ return []
+ return [convert_properties(g) for g in parsed.GROUPS]
+
+def check_match_uniqueness(groups):
+ matches = sum((group[0] for group in groups), [])
+ matches.sort()
+ prev = None
+ for match in matches:
+ if match == prev:
+ error('Match {!r} is duplicated', match)
+ prev = match
+
+def check_one_default(prop, settings):
+ defaults = [s for s in settings if s.DEFAULT]
+ if len(defaults) > 1:
+ error('More than one star entry: {!r}', prop)
+
+def check_one_keycode(prop, value):
+ if value != '!' and ecodes is not None:
+ key = 'KEY_' + value.upper()
+ if key not in ecodes:
+ error('Keycode {} unknown', key)
+
+def check_properties(groups):
+ grammar = property_grammar()
+ for matches, props in groups:
+ prop_names = set()
+ for prop in props:
+ # print('--', prop)
+ prop = prop.partition('#')[0].rstrip()
+ try:
+ parsed = grammar.parseString(prop)
+ except ParseBaseException as e:
+ error('Failed to parse: {!r}', prop)
+ continue
+ # print('{!r}'.format(parsed))
+ if parsed.NAME in prop_names:
+ error('Property {} is duplicated', parsed.NAME)
+ prop_names.add(parsed.NAME)
+ if parsed.NAME == 'MOUSE_DPI':
+ check_one_default(prop, parsed.VALUE.SETTINGS)
+ elif parsed.NAME.startswith('KEYBOARD_KEY_'):
+ check_one_keycode(prop, parsed.VALUE)
+
+def print_summary(fname, groups):
+ print('{}: {} match groups, {} matches, {} properties'
+ .format(fname,
+ len(groups),
+ sum(len(matches) for matches, props in groups),
+ sum(len(props) for matches, props in groups),
+ ))
+
+if __name__ == '__main__':
+ args = sys.argv[1:] or glob.glob(os.path.dirname(sys.argv[0]) + '/[67]0-*.hwdb')
+
+ for fname in args:
+ groups = parse(fname)
+ print_summary(fname, groups)
+ check_match_uniqueness(groups)
+ check_properties(groups)
+
+ sys.exit(ERROR)