1 Star 0 Fork 8

xiaojiuwo/libinput

forked from src-anolis-os/libinput 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0004-Revert-tools-switch-measure-fuzz-to-use-python-libev.patch 3.19 KB
一键复制 编辑 原始数据 按行查看 历史
geliwei 提交于 2021-06-16 18:28 . update to libinput-1.16.3-1.el8.src.rpm
From 2f294e771a5e9cdeedff4627905634b9daac9bec Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue, 3 Nov 2020 15:30:18 +1000
Subject: [PATCH libinput 4/4] Revert "tools: switch measure-fuzz to use
python-libevdev"
This reverts commit 795c08eb44fca078fa9935fdc5b8482bb7b43413.
---
tools/libinput-measure-fuzz.py | 40 ++++++++++++++++++++++++----------
1 file changed, 29 insertions(+), 11 deletions(-)
diff --git a/tools/libinput-measure-fuzz.py b/tools/libinput-measure-fuzz.py
index c392d74a..f539fe23 100755
--- a/tools/libinput-measure-fuzz.py
+++ b/tools/libinput-measure-fuzz.py
@@ -29,7 +29,8 @@ import sys
import argparse
import subprocess
try:
- import libevdev
+ import evdev
+ import evdev.ecodes
import pyudev
except ModuleNotFoundError as e:
print('Error: {}'.format(str(e)), file=sys.stderr)
@@ -74,15 +75,15 @@ class InvalidDeviceError(Exception):
pass
-class Device(libevdev.Device):
+class Device(object):
def __init__(self, path):
if path is None:
self.path = self.find_touch_device()
else:
self.path = path
- fd = open(self.path, 'rb')
- super().__init__(fd)
+ self.device = evdev.InputDevice(self.path)
+ self.name = self.device.name
context = pyudev.Context()
self.udev_device = pyudev.Devices.from_device_file(context, self.path)
@@ -137,18 +138,35 @@ class Device(libevdev.Device):
Returns a tuple of (xfuzz, yfuzz) with the fuzz as set on the device
axis. Returns None if no fuzz is set.
'''
- if not self.has(libevdev.EV_ABS.ABS_X) or not self.has(libevdev.EV_ABS.ABS_Y):
+ # capabilities returns a dict with the EV_* codes as key,
+ # each of which is a list of tuples of (code, AbsInfo)
+ #
+ # Get the abs list first (or empty list if missing),
+ # then extract the touch major absinfo from that
+ caps = self.device.capabilities(absinfo=True).get(evdev.ecodes.EV_ABS, [])
+ codes = [cap[0] for cap in caps]
+
+ if evdev.ecodes.ABS_X not in codes or evdev.ecodes.ABS_Y not in codes:
raise InvalidDeviceError('device does not have x/y axes')
- if self.has(libevdev.EV_ABS.ABS_MT_POSITION_X) != self.has(libevdev.EV_ABS.ABS_MT_POSITION_Y):
+ if (evdev.ecodes.ABS_MT_POSITION_X in codes) != (evdev.ecodes.ABS_MT_POSITION_Y in codes):
raise InvalidDeviceError('device does not have both multitouch axes')
- xfuzz = (self.absinfo[libevdev.EV_ABS.ABS_X].fuzz or
- self.absinfo[libevdev.EV_ABS.ABS_MT_POSITION_X].fuzz)
- yfuzz = (self.absinfo[libevdev.EV_ABS.ABS_Y].fuzz or
- self.absinfo[libevdev.EV_ABS.ABS_MT_POSITION_Y].fuzz)
+ axes = {
+ 0x00: None,
+ 0x01: None,
+ 0x35: None,
+ 0x36: None,
+ }
- if xfuzz == 0 and yfuzz == 0:
+ for c in caps:
+ if c[0] in axes.keys():
+ axes[c[0]] = c[1].fuzz
+
+ xfuzz = axes[0x35] or axes[0x00]
+ yfuzz = axes[0x36] or axes[0x01]
+
+ if xfuzz is None and yfuzz is None:
return None
return (xfuzz, yfuzz)
--
2.28.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fang-guoyong/libinput.git
git@gitee.com:fang-guoyong/libinput.git
fang-guoyong
libinput
libinput
a8

搜索帮助

0d507c66 1850385 C8b1a773 1850385