Debian

為什麼我的雙滾輪滑鼠只表現得好像它只有一個滾輪?

  • November 20, 2017

我有一個光學 GreatEye Wheelmouse,它有 2 個滾輪和 5 個“按鈕”(三個包括中間作為第一個滾輪上的“點擊”)和左右側按鈕(下圖中的暗側區域),儘管輸出看起來xinput --list-props都正確滾輪的行為是按鈕 4 和 5,而不是第二個在 6 和 7 上工作,這是為什麼以及如何修復它(讓第二個滾輪像水平滾輪一樣工作)?

A4Tech Optical GreatEye Wheelmouse 製造商產品圖片

上圖來自:A4Tech網站

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 1or -1(用於兩個相反方向的移動),而第二個滾輪有value 2or -2。有趣的是,我記得在使用中我注意到在某些應用程序中,第二個滾輪產生的滾動動作與第一個滾輪一樣大——這聽起來像是一些程式碼可能將值誤解為移動量而不是“方向” !

好像十五年前就注意到了!幾天(2002/07/17-18)在 Linux Kernel Mailing List 上的一系列文章,標題為“PS2 Input Core Support”表明這是眾所周知的,但因為有不止一種處理方式可能必須使用手動模組參數處理此特定產品的相同數據。然而,這似乎從未實現。可以在這篇文章中最好地看到詳細資訊:

> > … > > > 問題是 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_typePSMOUSE_IMEX

好吧,我現在有一些對我有用的東西,並將其作為輸入發佈到 Linux 核心輸入組的區域:psmouse - 修復 A4Tech 雙滾輪滑鼠上的第二個滾輪,但它只對非常小的滑鼠有用使用者組我不確定它是否會進入。更新檔相當小,但因為它修改了與以更正常方式使用 PS/2 滑鼠協議的其他滑鼠不兼容的行為,它不會被啟動預設情況下。作為一個模組,它將由option psmouse a4tech_hack=1inmodules.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 ------------

引用自:https://unix.stackexchange.com/questions/348712