我有一个光学 GreatEye Wheelmouse,它有 2 个滚轮和 5 个“按钮”(三个包括中间的第一个滚轮上的“点击”按钮)和左侧和右侧按钮(下图中的暗侧区域),尽管输出xinput --list-props
看起来正确两个都滚轮的行为相当于按钮 4 和 5,而不是第二个按钮作用于 6 和 7,这是为什么?我如何解决它(让第二个滚轮像水平滚轮一样工作)?
上图来自:A4科技网站
输出,xinput list-props #
其中 # 是正确的设备 ID:
Device 'ImExPS/2 Generic Explorer Mouse':
Device Enabled (142): 1
Coordinate Transformation Matrix (144): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
Device Accel Profile (269): 0
Device Accel Constant Deceleration (270): 1.000000
Device Accel Adaptive Deceleration (271): 1.000000
Device Accel Velocity Scaling (272): 10.000000
Device Product ID (261): 2, 6
Device Node (262): "/dev/input/event1"
Evdev Axis Inversion (273): 0, 0
Evdev Axes Swap (275): 0
Axis Labels (276): "Rel X" (152), "Rel Y" (153), "Rel Horiz Wheel" (267), "Rel Vert Wheel" (268)
Button Labels (277): "Button Left" (145), "Button Middle" (146), "Button Right" (147), "Button Wheel Up" (148), "Button Wheel Down" (149), "Button Horiz Wheel Left" (150), "Button Horiz Wheel Right" (151), "Button Side" (265), "Button Extra" (266), "Button Unknown" (264), "Button Unknown" (264), "Button Unknown" (264), "Button Unknown" (264)
Evdev Scrolling Distance (278): 1, 1, 1
Evdev Middle Button Emulation (279): 0
Evdev Middle Button Timeout (280): 50
Evdev Third Button Emulation (281): 0
Evdev Third Button Emulation Timeout (282): 1000
Evdev Third Button Emulation Button (283): 3
Evdev Third Button Emulation Threshold (284): 20
Evdev Wheel Emulation (285): 0
Evdev Wheel Emulation Axes (286): 0, 0, 4, 5
Evdev Wheel Emulation Inertia (287): 10
Evdev Wheel Emulation Timeout (288): 200
Evdev Wheel Emulation Button (289): 4
Evdev Drag Lock Buttons (290): 0
使用xev
我发现两个滚轮所看到的事件是相同的。对我来说,这表明这是一个内核/模块问题,我正在使用带有向后移植的 Debian“Jessie” - 后者意味着我当前正在使用,如下所示uname -a
:
Linux XXXXX 4.9.0-0.bpo.1-rt-amd64 #1 SMP PREEMPT RT Debian 4.9.2-2~bpo8+1 (2017-01-26) x86_64 GNU/Linux
作为一种推测性假设,我想知道(给出实际上拥有多于一只的老鼠的有限数量)真实的滚轮)这是否可能与内核实际相关 - 那么,作为补充答案,我可以从哪里开始寻找更多有关问题所在的信息?
更新:也许我错了,因为:
Evdev Wheel Emulation Axes (286): 0, 0, 4, 5
应该:
Evdev Wheel Emulation Axes (286): 6, 7, 4, 5
但只是用xinput set-props # 286 6 7 4 5
# 是正确的 ID 号来更改它本身并没有产生任何变化......
奇怪的是,grep
-ping 我的/var/log/Xorg.0.log
文件会产生:
[ 46.173] (II) config/udev: Adding input device ImExPS/2 Generic Explorer Mouse (/dev/input/event1)
[ 46.173] (**) ImExPS/2 Generic Explorer Mouse: Applying InputClass "evdev pointer catchall"
[ 46.173] (**) ImExPS/2 Generic Explorer Mouse: Applying InputClass "evdev pointer catchall"
[ 46.173] (II) Using input driver 'evdev' for 'ImExPS/2 Generic Explorer Mouse'
[ 46.173] (**) ImExPS/2 Generic Explorer Mouse: always reports core events
[ 46.173] (**) evdev: ImExPS/2 Generic Explorer Mouse: Device: "/dev/input/event1"
[ 46.173] (--) evdev: ImExPS/2 Generic Explorer Mouse: Vendor 0x2 Product 0x6
[ 46.173] (--) evdev: ImExPS/2 Generic Explorer Mouse: Found 9 mouse buttons
[ 46.173] (--) evdev: ImExPS/2 Generic Explorer Mouse: Found scroll wheel(s)
[ 46.173] (--) evdev: ImExPS/2 Generic Explorer Mouse: Found relative axes
[ 46.173] (--) evdev: ImExPS/2 Generic Explorer Mouse: Found x and y relative axes
[ 46.173] (II) evdev: ImExPS/2 Generic Explorer Mouse: Configuring as mouse
[ 46.173] (II) evdev: ImExPS/2 Generic Explorer Mouse: Adding scrollwheel support
[ 46.173] (**) evdev: ImExPS/2 Generic Explorer Mouse: YAxisMapping: buttons 4 and 5
[ 46.173] (**) evdev: ImExPS/2 Generic Explorer Mouse: EmulateWheelButton: 4, EmulateWheelInertia: 10, EmulateWheelTimeout: 200
[ 46.173] (II) XINPUT: Adding extended input device "ImExPS/2 Generic Explorer Mouse" (type: MOUSE, id 9)
[ 46.174] (II) evdev: ImExPS/2 Generic Explorer Mouse: initialized for relative axes.
[ 46.174] (**) ImExPS/2 Generic Explorer Mouse: (accel) keeping acceleration scheme 1
[ 46.174] (**) ImExPS/2 Generic Explorer Mouse: (accel) acceleration profile 0
[ 46.174] (**) ImExPS/2 Generic Explorer Mouse: (accel) acceleration factor: 2.000
[ 46.174] (**) ImExPS/2 Generic Explorer Mouse: (accel) acceleration threshold: 4
[ 46.174] (II) config/udev: Adding input device ImExPS/2 Generic Explorer Mouse (/dev/input/mouse0)
请注意,虽然有一行包含但YAxisMapping: buttons 4 and 5
没有对应的XAxisMapping: buttons 6 and 7
- 这是暗示性的......
笔记:(回应评论)它是一个 PS/2 连接器鼠标,因此 USB 相关的诊断可能不会有帮助。
安装该evtest
软件包后,我发现两个滚轮的事件具有相同的type 2 (EV_REL)
,code 8 (EV_WHEEL)
但第一个滚轮具有value 1
or -1
(用于在两个相反方向上移动),但第二个滚轮具有value 2
or -2
。有趣的是,我记得在使用中我注意到在某些应用程序中第二个滚轮产生滚动动作两次与第一个一样大 - 这开始听起来像是某些代码可能将值误解为移动量而不是“方向”!
答案1
似乎注意到了这一点十五几年前! Linux 内核邮件列表上几天(2002 年 7 月 17 日至 18 日)发布的一系列标题为“PS2 输入核心支持”的帖子表明,这是已知的,但因为有不止一种处理方法对于该特定产品,可能必须使用手动模块参数处理相同的数据。然而这似乎从未实现。详细信息最好参见这邮政:
...
问题是 A4Tech 驱动程序并不关心。它只是按照我描述的方式解释传入的数据:+-1 是垂直移动,+-2 是水平移动,0 是不移动,其他一切都被忽略......这是 A4Tech 对 ImPS/2 和 ExPS/2 协议的解释。
因此,我们可以假设(像 GPM 那样)滚轮移动只能是 +-1,因此我们可以安全地假设 +-2 是水平移动,然后一切都很好,或者我们需要一些会影响鼠标驱动程序的选项行为。
我所有的(A4Tech...)PS/2 滚轮鼠标即使在 10Hz 采样率下也仅报告滚轮移动 +-1,但我不认为我的鼠标是可用 ExPS/2 实现的代表性样本。
不,正常的 ImPS/2 和 ExPS/2 小鼠确实可以报告大于 1 的车轮运动值。
我们可以进行一些启发(曾经见过 3 的移动吗?如果是,那么它不是 A4Tech 鼠标...),或者使用命令行参数。
我想我会拿出一些 A4Tech 小鼠并折磨它们一下,看看它们是否会对某些序列做出反应......
另一件事是 USB A4Tech 鼠标,它使用按钮来区分滚轮,而 USB 规范规定鼠标上有两个滚轮:(。但这些至少是可以检测到的。
--
Vojtech Pavlik
SuSE 实验室
因此,我打算进行一些内核黑客攻击,添加一个模块参数来破坏从鼠标读取的数据,以便在启用./drivers/input/mouse/psmouse_base.c
时修复它。psmouse_type
PSMOUSE_IMEX
好吧,我现在有一些对我有用的东西,并将其发布到 Linux 内核输入组的区域:输入:psmouse - 修复 A4Tech 双滚轮鼠标上的第二个滚轮但由于它只对一小部分用户有用,我不确定它是否会加入。该补丁相当小,但因为它修改了与使用 PS/2 的其他鼠标不兼容的行为鼠标协议以更正常的方式默认不会激活。作为一个模块,它可以通过option psmouse a4tech_hack=1
inmodules.conf
或当今系统上使用的任何内容来启用 - 用于evtest
演示给出,首先禁用 hack:
stephen@Ripley:~$ sudo modprobe psmouse options a4tech_hack=0 stephen@Ripley:~$ sudo evtest --grab /dev/input/event1 Input driver version is 1.0.1 Input device ID: bus 0x11 vendor 0x2 product 0x6 version 0x0 Input device name: "ImExPS/2 Generic Explorer Mouse" Supported events: Event type 0 (EV_SYN) Event type 1 (EV_KEY) Event code 272 (BTN_LEFT) Event code 273 (BTN_RIGHT) Event code 274 (BTN_MIDDLE) Event code 275 (BTN_SIDE) Event code 276 (BTN_EXTRA) Event type 2 (EV_REL) Event code 0 (REL_X) Event code 1 (REL_Y) Event code 6 (REL_HWHEEL) Event code 8 (REL_WHEEL) Properties: Property type 0 (INPUT_PROP_POINTER) Testing ... (interrupt to exit) Event: time 1511190325.037494, type 2 (EV_REL), code 8 (REL_WHEEL), value -1 Event: time 1511190325.037494, -------------- SYN_REPORT ------------ Event: time 1511190325.069545, type 2 (EV_REL), code 8 (REL_WHEEL), value -1 Event: time 1511190325.069545, -------------- SYN_REPORT ------------ Event: time 1511190325.103279, type 2 (EV_REL), code 8 (REL_WHEEL), value -1 Event: time 1511190325.103279, -------------- SYN_REPORT ------------ Event: time 1511190325.360609, type 2 (EV_REL), code 8 (REL_WHEEL), value -1 Event: time 1511190325.360609, -------------- SYN_REPORT ------------ Event: time 1511190325.754597, type 2 (EV_REL), code 8 (REL_WHEEL), value -2 Event: time 1511190325.754597, -------------- SYN_REPORT ------------ Event: time 1511190326.226203, type 2 (EV_REL), code 8 (REL_WHEEL), value 2 Event: time 1511190326.226203, -------------- SYN_REPORT ------------ Event: time 1511190326.335886, type 2 (EV_REL), code 8 (REL_WHEEL), value -2 Event: time 1511190326.335886, -------------- SYN_REPORT ------------ Event: time 1511190326.420238, type 2 (EV_REL), code 8 (REL_WHEEL), value -2 Event: time 1511190326.420238, -------------- SYN_REPORT ------------ Event: time 1511190326.849670, type 2 (EV_REL), code 8 (REL_WHEEL), value -2 Event: time 1511190326.849670, -------------- SYN_REPORT ------------
然后启用它后,请注意值为 +/-2 的 REL_WHEEL 事件现在如何正确映射为 REL_HWHEEL 事件:
stephen@Ripley:~$ sudo modprobe -r psmouse stephen@Ripley:~$ sudo modprobe psmouse options a4tech_hack=1 stephen@Ripley:~$ sudo evtest --grab /dev/input/event1 Input driver version is 1.0.1 Input device ID: bus 0x11 vendor 0x2 product 0x6 version 0x0 Input device name: "ImExPS/2 Generic Explorer Mouse" Supported events: Event type 0 (EV_SYN) Event type 1 (EV_KEY) Event code 272 (BTN_LEFT) Event code 273 (BTN_RIGHT) Event code 274 (BTN_MIDDLE) Event code 275 (BTN_SIDE) Event code 276 (BTN_EXTRA) Event type 2 (EV_REL) Event code 0 (REL_X) Event code 1 (REL_Y) Event code 6 (REL_HWHEEL) Event code 8 (REL_WHEEL) Properties: Property type 0 (INPUT_PROP_POINTER) Testing ... (interrupt to exit) Event: time 1511190624.369531, type 2 (EV_REL), code 8 (REL_WHEEL), value 1 Event: time 1511190624.369531, -------------- SYN_REPORT ------------ Event: time 1511190625.580824, type 2 (EV_REL), code 8 (REL_WHEEL), value -1 Event: time 1511190625.580824, -------------- SYN_REPORT ------------ Event: time 1511190626.139235, type 2 (EV_REL), code 8 (REL_WHEEL), value 1 Event: time 1511190626.139235, -------------- SYN_REPORT ------------ Event: time 1511190626.419281, type 2 (EV_REL), code 8 (REL_WHEEL), value -1 Event: time 1511190626.419281, -------------- SYN_REPORT ------------ Event: time 1511190626.693413, type 2 (EV_REL), code 8 (REL_WHEEL), value 1 Event: time 1511190626.693413, -------------- SYN_REPORT ------------ Event: time 1511190628.506133, type 2 (EV_REL), code 6 (REL_HWHEEL), value 1 Event: time 1511190628.506133, -------------- SYN_REPORT ------------ Event: time 1511190628.669774, type 2 (EV_REL), code 6 (REL_HWHEEL), value -1 Event: time 1511190628.669774, -------------- SYN_REPORT ------------ Event: time 1511190628.921986, type 2 (EV_REL), code 6 (REL_HWHEEL), value 1 Event: time 1511190628.921986, -------------- SYN_REPORT ------------ Event: time 1511190628.970915, type 2 (EV_REL), code 6 (REL_HWHEEL), value 1 Event: time 1511190628.970915, -------------- SYN_REPORT ------------ Event: time 1511190629.235774, type 2 (EV_REL), code 6 (REL_HWHEEL), value -1 Event: time 1511190629.235774, -------------- SYN_REPORT ------------ Event: time 1511190629.425575, type 2 (EV_REL), code 6 (REL_HWHEEL), value 1 Event: time 1511190629.425575, -------------- SYN_REPORT ------------ Event: time 1511190629.475333, type 2 (EV_REL), code 6 (REL_HWHEEL), value 1 Event: time 1511190629.475333, -------------- SYN_REPORT ------------ Event: time 1511190629.668506, type 2 (EV_REL), code 6 (REL_HWHEEL), value -1 Event: time 1511190629.668506, -------------- SYN_REPORT ------------ Event: time 1511190629.730081, type 2 (EV_REL), code 6 (REL_HWHEEL), value -1 Event: time 1511190629.730081, -------------- SYN_REPORT ------------ Event: time 1511190629.862513, type 2 (EV_REL), code 6 (REL_HWHEEL), value 1 Event: time 1511190629.862513, -------------- SYN_REPORT ------------ Event: time 1511190629.909745, type 2 (EV_REL), code 6 (REL_HWHEEL), value 1 Event: time 1511190629.909745, -------------- SYN_REPORT ------------ Event: time 1511190630.139196, type 2 (EV_REL), code 6 (REL_HWHEEL), value -1 Event: time 1511190630.139196, -------------- SYN_REPORT ------------