@@ -153,9 +153,22 @@ function makePointingDevice(pointingDeviceLines) {
153
153
//assuming that N: & P: always appear at lines 2 and 3 respectively
154
154
if ( pointingDeviceLines [ 1 ] . startsWith ( 'N: Name=' ) &&
155
155
pointingDeviceLines [ 2 ] . startsWith ( 'P: Phys=' ) ) {
156
+
157
+ let name = pointingDeviceLines [ 1 ] . split ( '"' ) [ 1 ] ;
158
+ let phys = pointingDeviceLines [ 2 ] . split ( '=' ) [ 1 ] ;
159
+
160
+ // Ignore i2c mouse devices: they are ephemeral.
161
+ // See https://askubuntu.com/q/1280003
162
+ // WARNING: don't make check for 'touchpad' device!
163
+ // Related (to be tested) issues: #40, #61, #64 and maybe #67
164
+ // TODO: How can we check in a clean way not hardcoded?
165
+ if ( name . toLowerCase ( ) . indexOf ( "mouse" ) !== - 1 && phys . toLowerCase ( ) . startsWith ( "i2c" ) ) {
166
+ return ;
167
+ }
168
+
156
169
let pointingDevice = { } ;
157
- pointingDevice . name = pointingDeviceLines [ 1 ] . split ( '"' ) [ 1 ] ;
158
- pointingDevice . phys = pointingDeviceLines [ 2 ] . split ( '=' ) [ 1 ] ;
170
+ pointingDevice . name = name ;
171
+ pointingDevice . phys = phys ;
159
172
pointingDevice . type = 'mouse' ; //default
160
173
for ( let type in ALL_TYPES ) {
161
174
if ( ALL_TYPES [ type ] . some ( ( t ) => {
@@ -175,7 +188,7 @@ function listPointingDevices() {
175
188
let comp = executeCmdSync ( 'cat /proc/bus/input/devices' ) ;
176
189
let allDeviceChunks = comp [ 1 ] . split ( '\n\n' ) ;
177
190
for ( let x = 0 ; x < allDeviceChunks . length ; x ++ ) {
178
- if ( allDeviceChunks [ x ] . indexOf ( 'mouse' ) !== - 1 ) {
191
+ if ( allDeviceChunks [ x ] . toLowerCase ( ) . indexOf ( 'mouse' ) !== - 1 ) {
179
192
let pointingDeviceLines = allDeviceChunks [ x ] . split ( '\n' ) ;
180
193
let pointingDevice = makePointingDevice ( pointingDeviceLines ) ;
181
194
if ( pointingDevice !== undefined ) {
0 commit comments