Commit 870ddce9 authored by Peter Hutterer's avatar Peter Hutterer

Drop the udev hwdb model quirks

Replaced with the quirks files in merge commit
000ac14cSigned-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent a7d19e44
......@@ -116,13 +116,6 @@ executable('libinput-model-quirks',
install : true,
install_dir : udev_dir)
model_quirks = files('udev/90-libinput-model-quirks.hwdb')
parse_hwdb_py = find_program('udev/parse_hwdb.py')
test('parse-hwdb',
parse_hwdb_py,
args : model_quirks)
udev_rules_config = configuration_data()
udev_rules_config.set('UDEV_TEST_PATH', '')
configure_file(input : 'udev/80-libinput-device-groups.rules.in',
......@@ -130,16 +123,6 @@ configure_file(input : 'udev/80-libinput-device-groups.rules.in',
install : true,
install_dir : udev_rules_dir,
configuration : udev_rules_config)
configure_file(input : 'udev/90-libinput-model-quirks.rules.in',
output : '90-libinput-model-quirks.rules',
install : true,
install_dir : udev_rules_dir,
configuration : udev_rules_config)
configure_file(input : model_quirks,
output : '90-libinput-model-quirks.hwdb',
install : true,
install_dir : udev_hwdb_dir,
configuration : udev_rules_config)
litest_udev_rules_config = configuration_data()
litest_udev_rules_config.set('UDEV_TEST_PATH', meson.build_root() + '/')
......@@ -147,10 +130,6 @@ litest_groups_rules_file = configure_file(input : 'udev/80-libinput-device-group
output : '80-libinput-device-groups-litest.rules',
install : false,
configuration : litest_udev_rules_config)
litest_model_quirks_file = configure_file(input : 'udev/90-libinput-model-quirks.rules.in',
output : '90-libinput-model-quirks-litest.rules',
install : false,
configuration : litest_udev_rules_config)
############ libinput-util.a ############
src_libinput_util = [
......@@ -812,10 +791,6 @@ if get_option('tests')
install : false,
configuration : udev_rules_config)
config_h.set_quoted('LIBINPUT_MODEL_QUIRKS_UDEV_RULES_FILE',
join_paths(meson.build_root(), '90-libinput-model-quirks.rules'))
config_h.set_quoted('LIBINPUT_MODEL_QUIRKS_UDEV_HWDB_FILE',
join_paths(meson.build_root(), '90-libinput-model-quirks.hwdb'))
config_h.set_quoted('LIBINPUT_TEST_DEVICE_RULES_FILE',
join_paths(meson.build_root(), '80-libinput-test-device.rules'))
config_h.set_quoted('LIBINPUT_DEVICE_GROUPS_RULES_FILE',
......
......@@ -1185,16 +1185,6 @@ litest_install_model_quirks(struct list *created_files_list)
"#################################################################\n\n";
struct created_file *file;
file = litest_copy_file(UDEV_MODEL_QUIRKS_RULE_FILE,
LIBINPUT_MODEL_QUIRKS_UDEV_RULES_FILE,
warning);
list_insert(created_files_list, &file->link);
file = litest_copy_file(UDEV_MODEL_QUIRKS_HWDB_FILE,
LIBINPUT_MODEL_QUIRKS_UDEV_HWDB_FILE,
warning);
list_insert(created_files_list, &file->link);
file = litest_copy_file(UDEV_TEST_DEVICE_RULE_FILE,
LIBINPUT_TEST_DEVICE_RULES_FILE,
warning);
......
# Do not edit this file, it will be overwritten on update
#
# This file contains hwdb matches for libinput model-specific quirks.
# The contents of this file are a contract between libinput, udev rules and
# the hwdb.
# IT IS NOT A STABLE API AND SUBJECT TO CHANGE AT ANY TIME
# The lookup keys are composed in:
# 90-libinput-model-quirks.rules
#
# Match string formats:
# libinput:mouse:<modalias>
# libinput:touchpad:<modalias>
# libinput:name:<name>:dmi:<dmi string>
# libinput:name:<name>:dt:<device-tree string>
#
# Sort by brand, model
##########################################
# Chassis types 9 (Laptop) and 10
# (Notebook) are expected to have working
# lid switches
##########################################
libinput:name:*Lid Switch*:dmi:*:ct10:*
libinput:name:*Lid Switch*:dmi:*:ct9:*
LIBINPUT_ATTR_LID_SWITCH_RELIABILITY=reliable
##########################################
# Serial keyboards are internal
##########################################
libinput:keyboard:input:b0011v*
LIBINPUT_ATTR_KEYBOARD_INTEGRATION=internal
##########################################
# Aiptek
##########################################
libinput:tablet:input:b0003v08CAp*
LIBINPUT_MODEL_TABLET_NO_TILT=1
##########################################
# ALPS
##########################################
libinput:name:*AlpsPS/2 ALPS DualPoint TouchPad:dmi:*
libinput:name:*AlpsPS/2 ALPS GlidePoint:dmi:*
LIBINPUT_MODEL_ALPS_TOUCHPAD=1
# ALPS firmware versions:
# V1 = 0x100
# V2 = 0x200
# V3 = 0x300
# V3_RUSHMORE = 0x310
# V4 = 0x400
# V5 = 0x500
# V6 = 0x600
# V7 = 0x700 /* t3btl t4s */
# V8 = 0x800 /* SS4btl SS4s */
# V9 = 0x900 /* ss3btl */
libinput:touchpad:input:b0011v0002p0008e0800*
LIBINPUT_ATTR_SIZE_HINT=100x55
libinput:pointingstick:input:b0011v0002p0008e0800*
LIBINPUT_ATTR_TRACKPOINT_RANGE=160
##########################################
# Apple
##########################################
libinput:touchpad:input:b0003v05ACp*
libinput:touchpad:input:b0005v05ACp*
LIBINPUT_MODEL_APPLE_TOUCHPAD=1
LIBINPUT_ATTR_SIZE_HINT=104x75
LIBINPUT_ATTR_TOUCH_SIZE_RANGE=150:130
LIBINPUT_ATTR_PALM_SIZE_THRESHOLD=800
libinput:name:*Apple Inc. Apple Internal Keyboard*:dmi:*
LIBINPUT_ATTR_KEYBOARD_INTEGRATION=internal
libinput:mouse:input:b0005v05ACp030D*
LIBINPUT_MODEL_APPLE_MAGICMOUSE=1
# Apple Magic Trackpad v1 (2010, clickpad)
libinput:touchpad:input:b0005v05ACp030E*
LIBINPUT_ATTR_SIZE_HINT=130x110
LIBINPUT_ATTR_TOUCH_SIZE_RANGE=20:10
LIBINPUT_ATTR_PALM_SIZE_THRESHOLD=900
libinput:touchpad:input:b0003v05ACp021A*
LIBINPUT_MODEL_APPLE_TOUCHPAD_ONEBUTTON=1
# MacBookPro5,5 (Mid 2009)
libinput:touchpad:input:b0003v05ACp0237*
LIBINPUT_ATTR_PALM_SIZE_THRESHOLD=1000
##########################################
# Asus
##########################################
libinput:name:*ETPS/2 Elantech Touchpad*:dmi:*svnASUSTeKCOMPUTERINC.:pnX555LAB:*
LIBINPUT_MODEL_TOUCHPAD_VISIBLE_MARKER=1
##########################################
# Chicony
##########################################
# Acer Hawaii Keyboard, uses Chicony VID
libinput:touchpad:input:b0003v04F2p1558*
LIBINPUT_ATTR_TPKBCOMBO_LAYOUT=below
##########################################
# Cyborg
##########################################
# Saitek Cyborg R.A.T.5 Mouse
libinput:mouse:input:b0003v06A3p0CD5*
LIBINPUT_MODEL_CYBORG_RAT=1
##########################################
# Dell
##########################################
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnDellInc.:*
libinput:name:* Touchpad:dmi:*svnDellInc.:*
LIBINPUT_MODEL_TOUCHPAD_VISIBLE_MARKER=1
libinput:name:*AlpsPS/2 ALPS GlidePoint:dmi:*svnDellInc.:pnLatitudeE6220:*
LIBINPUT_ATTR_PRESSURE_RANGE=100:90
libinput:name:*CyPS/2 Cypress Trackpad:dmi:*svnDell*:*XPSL322X*
LIBINPUT_ATTR_PRESSURE_RANGE=30:20
LIBINPUT_ATTR_PALM_PRESSURE_THRESHOLD=254
##########################################
# Elantech
##########################################
libinput:name:*ETPS/2 Elantech Touchpad*:dmi:*
LIBINPUT_ATTR_RESOLUTION_HINT=31x31
LIBINPUT_ATTR_PRESSURE_RANGE=10:8
libinput:name:*ETPS/2 Elantech Touchpad*:dmi:*svnASUSTeKComputerInc.:pnUX21E:*
LIBINPUT_ATTR_PRESSURE_RANGE=24:10
libinput:name:*Elan Touchpad*:dt:*
LIBINPUT_ATTR_PRESSURE_RANGE=10:8
libinput:name:*Elan Touchpad*:dt:*Chromebook R13 CB5-312T*
libinput:name:*Elan Touchpad*:dt:*CB5-312T*
libinput:name:*Elan Touchpad*:dt:*Elm*
LIBINPUT_ATTR_PRESSURE_RANGE=6:4
##########################################
# Google
##########################################
# The various chromebooks, info from modinfo chromeos_laptop, touchpad names
# extrapolated from the chromiumos touchad-tests repo
# https://chromium.googlesource.com/chromiumos/platform/touchpad-tests
libinput:name:Cypress APA Trackpad ?cyapa?:dmi:*pn*Falco*
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*pn*Mario*
libinput:name:Cypress APA Trackpad ?cyapa?:dmi:*pn*Butterfly*
libinput:name:Cypress APA Trackpad ?cyapa?:dmi:*pn*Peppy*
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*pn*ZGB*
libinput:name:Cypress APA Trackpad ?cyapa?:dmi:*pn*Parrot*
libinput:name:Cypress APA Trackpad ?cyapa?:dmi:*bvn*coreboot*:pn*Leon*
libinput:name:Cypress APA Trackpad ?cyapa?:dmi:*bvn*coreboot*:pn*Wolf*
libinput:name:Cypress APA Trackpad ?cyapa?:dmi:*svn*GOOGLE*:pn*Link*
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*pn*Alex*
libinput:name:Cypress APA Trackpad ?cyapa?:dmi:*svn*SAMSUNG*:pn*Lumpy*
libinput:name:Atmel maXTouch Touchpad:dmi:*svn*GOOGLE*:pn*Samus*
LIBINPUT_MODEL_CHROMEBOOK=1
libinput:name:Cypress APA Trackpad ?cyapa?:dmi:*
LIBINPUT_ATTR_PRESSURE_RANGE=10:8
##########################################
# HP
##########################################
# HP Compaq6910p
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnHewlett-Packard:*pnHPCompaq6910p*
LIBINPUT_MODEL_HP6910_TOUCHPAD=1
# HP Compaq 8510w
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnHewlett-Packard:*pnHPCompaq8510w*
LIBINPUT_MODEL_HP8510_TOUCHPAD=1
# HP Pavillion dm4
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnHewlett-Packard:*pnHPPaviliondm4NotebookPC*
LIBINPUT_MODEL_HP_PAVILION_DM4_TOUCHPAD=1
# HP Stream 11
libinput:name:SYN1EDE:00 06CB:7442:dmi:*svnHewlett-Packard:pnHPStreamNotebookPC11*
LIBINPUT_MODEL_HP_STREAM11_TOUCHPAD=1
# HP Zbook Studio G3
libinput:name:AlpsPS/2 ALPS GlidePoint:dmi:*svnHP:pnHPZBookStudioG3:*
LIBINPUT_MODEL_HP_ZBOOK_STUDIO_G3=1
##########################################
# HUION
##########################################
#
# HUION PenTablet device. Some of these devices send a BTN_TOOL_PEN event
# with value 1 on the first event received by the device but never send the
# matching BTN_TOOL_PEN value 0 event. The device appears as if it was
# permanently in proximity.
#
# HUION re-uses USB IDs for its devices, not every HUION tablet is
# affected by this bug, libinput will auto-disable this feature
libinput:tablet:input:b0003v256Cp*
LIBINPUT_MODEL_TABLET_NO_PROXIMITY_OUT=1
##########################################
# IBM
##########################################
#
# IBM/Lenovo Scrollpoint mouse. Instead of a scroll wheel these mice
# feature trackpoint-like sticks which generate a huge amount of scroll
# events that need to be handled differently than scroll wheel events
libinput:mouse:b0003v04B3p3100*
libinput:mouse:b0003v04B3p3103*
libinput:mouse:b0003v04B3p3105*
libinput:mouse:b0003v04B3p3108*
libinput:mouse:b0003v04B3p3109*
libinput:mouse:b0003v17EFp6049*
LIBINPUT_MODEL_LENOVO_SCROLLPOINT=1
# Lenovo Thinkpad X41 Tablet has lid buttons to be used in tablet mode
# (#103749)
libinput:name:AT Translated Set 2 keyboard:dmi:*svnIBM:*pvrThinkPadX41Tablet:*
LIBINPUT_MODEL_TABLET_MODE_NO_SUSPEND=1
##########################################
# LENOVO
##########################################
# X220 after a bios update updating the touchpad firmware version to 8.1
# See https://bugzilla.redhat.com/show_bug.cgi?id=1264453 for details
# If the touchpad is unresponsive and dmesg includes this line
# psmouse serio1: synaptics: Touchpad model: 1, fw: 8.1 [...]
# then copy the two lines below into a new file
# /etc/udev/hwdb.d/90-libinput-x220-touchpad-fw81.hwdb, then run
# sudo udevadm hwdb --update and reboot.
#
# Copy the two lines below:
#libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO:*:pvrThinkPadX220*
# LIBINPUT_MODEL_LENOVO_X220_TOUCHPAD_FW81=1
# X230 (Tablet)
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO:*:pvrThinkPadX230*
LIBINPUT_MODEL_LENOVO_X230=1
# T440p on PS/2
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO:*:pvrThinkPadT440p*
# T440p on RMI4
libinput:name:Synaptics tm2964-001:dmi:*svnLENOVO:*:pvrThinkPadT440p*
LIBINPUT_MODEL_LENOVO_T450_TOUCHPAD=1
# T440s trackpoint
libinput:name:TPPS/2 IBM TrackPoint:dmi:*svnLENOVO:*:pvrThinkPadT440s*
LIBINPUT_ATTR_TRACKPOINT_RANGE=30
# T450s trackpoint
libinput:name:TPPS/2 IBM TrackPoint:dmi:*svnLENOVO:*:pvrThinkPadT450s*
LIBINPUT_ATTR_TRACKPOINT_RANGE=50
# Lenovo T450/T460 and all other Lenovos of the *50 and *60 generation,
# including the X1 Carbon 3rd gen
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO:*:pvrThinkPadP50*:
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO:*:pvrThinkPad??50*:
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO:*:pvrThinkPad??60*:
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO:*:pvrThinkPadX1Carbon3rd:*
LIBINPUT_MODEL_LENOVO_T450_TOUCHPAD=1
LIBINPUT_ATTR_PALM_PRESSURE_THRESHOLD=150
# Lenovo ThinkPad series
libinput:name:*Synaptics*:dmi:*svnLENOVO:*:pvrThinkPad*:*
LIBINPUT_ATTR_THUMB_PRESSURE_THRESHOLD=100
# Lenovo ThinkPad Compact USB Keyboard with TrackPoint
libinput:keyboard:input:b0003v17EFp6047*
LIBINPUT_ATTR_KEYBOARD_INTEGRATION=external
# Lenovo X280
libinput:name:*ALPS TrackPoint*:dmi:svnLENOVO:*:pvrThinkPadX280:*
LIBINPUT_ATTR_TRACKPOINT_RANGE=70
# Lenovo Thinkpad X1 Yoga disables the keyboard anyway but has the same device
# use a windows key on the screen and volume rocker on the side (#103749)
libinput:name:AT Translated Set 2 keyboard:dmi:*svnLENOVO:*pvrThinkPadX1Yoga1st:*
LIBINPUT_MODEL_TABLET_MODE_NO_SUSPEND=1
# Lenovo Carbon X1 6th gen (RMI4 only, PS/2 is broken on this device)
libinput:name:Synaptics TM3288-010:dmi:*svnLenovo:*pvrThinkPadX1Carbon6th:*
LIBINPUT_MODEL_LENOVO_CARBON_X1_6TH=1
##########################################
# Logitech
##########################################
libinput:name:*Logitech M570*:dmi:*
LIBINPUT_MODEL_TRACKBALL=1
# Logitech Marble Mouse trackball
libinput:mouse:input:b0003v046DpC408*
LIBINPUT_MODEL_LOGITECH_MARBLE_MOUSE=1
# Logitech K400
libinput:mouse:input:b0003v046Dp4024*
# Logitech K400r
libinput:mouse:input:b0003v046Dp404B*
# Logitech K830
libinput:mouse:input:b0003v046Dp404C*
# Logitech K400Plus
libinput:mouse:input:b0003v046Dp404D*
LIBINPUT_MODEL_BOUNCING_KEYS=1
# Logitech Wireless Touchpad
libinput:touchpad:input:b0003v046Dp4011*
LIBINPUT_ATTR_PALM_PRESSURE_THRESHOLD=400
##########################################
# Microsoft
##########################################
# Surface3 needs us to write the open lid switch event
libinput:name:*Lid Switch*:dmi:*svnMicrosoftCorporation:pnSurface3:*
LIBINPUT_ATTR_LID_SWITCH_RELIABILITY=write_open
# Surface 3 Type Cover keyboard
libinput:name:*Microsoft Surface Type Cover Keyboard*:dmi:*svnMicrosoftCorporation:pnSurface3:*
LIBINPUT_ATTR_KEYBOARD_INTEGRATION=internal
# Microsoft Microsoft® Nano Transceiver v2.0"
libinput:mouse:input:b0003v045Ep0800*
LIBINPUT_MODEL_BOUNCING_KEYS=1
##########################################
# Razer
##########################################
libinput:keyboard:input:b0003v1532p0220*
LIBINPUT_ATTR_KEYBOARD_INTEGRATION=internal
libinput:name:*Lid Switch*:dmi:*svnRazer:pnBlade*
LIBINPUT_ATTR_LID_SWITCH_RELIABILITY=write_open
##########################################
# Synaptics
##########################################
libinput:touchpad:input:b0011v0002p0007*
LIBINPUT_MODEL_SYNAPTICS_SERIAL_TOUCHPAD=1
##########################################
# System76
##########################################
# Bonobo Professional
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnSystem76*pvrbonp5*
LIBINPUT_MODEL_SYSTEM76_BONOBO=1
# Clevo
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*pnW740SU*rnW740SU*
LIBINPUT_MODEL_CLEVO_W740SU=1
# Galago Ultra Pro
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnSystem76*pvrgalu1*
LIBINPUT_MODEL_SYSTEM76_GALAGO=1
# Kudu Professional
libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnSystem76*pvrkudp1*
LIBINPUT_MODEL_SYSTEM76_KUDU=1
##########################################
# Wacom
##########################################
libinput:touchpad:input:b0003v056Ap*
LIBINPUT_MODEL_WACOM_TOUCHPAD=1
# Wacom Intuos Pro PTH-660
libinput:touchpad:input:b0003v056Ap0357*
LIBINPUT_ATTR_PALM_SIZE_THRESHOLD=5
##########################################
# Anything that has trackball in the name
##########################################
libinput:name:*Trackball*:dmi:*
LIBINPUT_MODEL_TRACKBALL=1
# Do not edit this file, it will be overwritten on update
#
# This file contains lookup rules for libinput model-specific quirks.
# The contents of this file are a contract between libinput, udev rules and
# the hwdb.
# IT IS NOT A STABLE API AND SUBJECT TO CHANGE AT ANY TIME
#
# The hwdb database is in:
# 90-libinput-model-quirks.hwdb
ACTION!="add|change", GOTO="libinput_model_quirks_end"
KERNEL!="event*", GOTO="libinput_model_quirks_end"
# libinput:touchpad:<modalias>
ENV{ID_INPUT_TOUCHPAD}=="1", \
IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:touchpad:"
# libinput:tablet:<modalias>
ENV{ID_INPUT_TABLET}=="1", \
IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:tablet:"
# libinput:mouse:<modalias>
ENV{ID_INPUT_MOUSE}=="1", \
IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:mouse:"
# libinput:pointingstick:<modalias>
ENV{ID_INPUT_POINTINGSTICK}=="1", \
IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:pointingstick:"
# libinput:touchpad:<modalias>
ENV{ID_INPUT_KEYBOARD}=="1", \
IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:keyboard:"
# libinput:name:<name>:dmi:<dmi string>
KERNELS=="input*", \
IMPORT{builtin}="hwdb 'libinput:name:$attr{name}:$attr{[dmi/id]modalias}'"
# libinput:name:<name>:dt:<device-tree string>
KERNELS=="input*", \
IMPORT{builtin}="hwdb 'libinput:name:$attr{name}:dt:$attr{[devicetree/base]model}'"
LABEL="libinput_model_quirks_end"
#!/usr/bin/env python3
# vim: set expandtab shiftwidth=4:
# -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */
#
# ANY MODIFICATIONS TO THIS FILE SHOULD BE MERGED INTO THE SYSTEMD UPSTREAM
#
# This file is part of systemd. It is distributed under the MIT license, see
# below.
#
# Copyright 2016 Zbigniew Jędrzejewski-Szmek
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import functools
import glob
import string
import sys
import os
try:
from pyparsing import (Word, White, Literal, ParserElement, Regex,
LineEnd, 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 = LineEnd()
COMMENTLINE = pythonStyleComment + EOL
INTEGER = Word(nums)
REAL = Combine((INTEGER + Optional('.' + Optional(INTEGER))) ^ ('.' + INTEGER))
UDEV_TAG = Word(string.ascii_uppercase, alphanums + '_')
TYPES = {
'libinput': ('name', 'touchpad', 'mouse', 'keyboard', 'tablet', 'pointingstick'),
}
@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(' ')
model_props = [
Regex(r'LIBINPUT_MODEL_[_0-9A-Z]+')('NAME') -
Suppress('=') - (Literal('1'))('VALUE')
]
dimension = INTEGER('X') + Suppress('x') + INTEGER('Y')
crange = INTEGER('X') + Suppress(':') + INTEGER('Y')
vprops = (
('LIBINPUT_ATTR_SIZE_HINT', Group(dimension('SETTINGS*'))),
('LIBINPUT_ATTR_RESOLUTION_HINT', Group(dimension('SETTINGS*'))),
('LIBINPUT_ATTR_PRESSURE_RANGE', Group(crange('SETTINGS*'))),
('LIBINPUT_ATTR_TOUCH_SIZE_RANGE', Group(crange('SETTINGS*'))),
('LIBINPUT_ATTR_TPKBCOMBO_LAYOUT', Or(('below'))),
('LIBINPUT_ATTR_LID_SWITCH_RELIABILITY', Or(('reliable', 'write_open'))),
('LIBINPUT_ATTR_KEYBOARD_INTEGRATION', Or(('internal', 'external'))),
('LIBINPUT_ATTR_TRACKPOINT_RANGE', INTEGER('Y')),
('LIBINPUT_ATTR_THUMB_PRESSURE_THRESHOLD', INTEGER('Y')),
)
value_props = [Literal(name)('NAME') - Suppress('=') - val('VALUE') for
name, val in vprops]
tprops = (
('LIBINPUT_ATTR_PALM_PRESSURE_THRESHOLD', INTEGER('X')),
('LIBINPUT_ATTR_PALM_SIZE_THRESHOLD', INTEGER('X')),
)
typed_props = [Literal(name)('NAME') - Suppress('=') - val
for name, val in tprops]
grammar = Or(model_props + value_props + typed_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