evdev: improve joystick and gamepad detection
authorJosé Expósito <jose.exposito89@gmail.com>
Tue, 23 Nov 2021 17:07:53 +0000 (18:07 +0100)
committerPeter Hutterer <peter.hutterer@who-t.net>
Fri, 3 Dec 2021 00:20:47 +0000 (00:20 +0000)
commit8dd8786c482b8811cf0628571e6724e540ce61d7
treefecb552fd896a5d7d99728e427702f49e4656a7b
parenta694a06b925009d836e5ba17cb73e29fdbcb188c
evdev: improve joystick and gamepad detection

The EVDEV_UDEV_TAG_JOYSTICK is set when a joystick or gamepad button
is found. However, it can not be used to identify joysticks or
gamepads because there are keyboards that also have it. Even worse,
many joysticks also map KEY_* and thus are tagged as keyboards.

In order to be able to detect joysticks and gamepads and
differentiate them from keyboards, apply the following rules:

  1. The device is tagged as joystick but not as tablet
  2. It has at least 2 joystick buttons
  3. It doesn't have 10 keyboard keys

Fix #701
Fix #415
Fix #703

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
src/evdev.c