mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 08:00:08 +01:00
evdev: refactor joystick/gamepad detection
Move the logic to detect joysticks and gamepads to its own function. Refactor, no functional changes. Signed-off-by: José Expósito <jose.exposito89@gmail.com>
This commit is contained in:
parent
fbe5d35dca
commit
a694a06b92
1 changed files with 14 additions and 2 deletions
16
src/evdev.c
16
src/evdev.c
|
|
@ -1850,6 +1850,18 @@ evdev_disable_accelerometer_axes(struct evdev_device *device)
|
|||
libevdev_disable_event_code(evdev, EV_ABS, REL_Z);
|
||||
}
|
||||
|
||||
static bool
|
||||
evdev_device_is_joystick_or_gamepad(struct evdev_device *device)
|
||||
{
|
||||
enum evdev_device_udev_tags udev_tags;
|
||||
|
||||
udev_tags = evdev_device_get_udev_tags(device, device->udev_device);
|
||||
if (udev_tags == (EVDEV_UDEV_TAG_INPUT|EVDEV_UDEV_TAG_JOYSTICK))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static struct evdev_dispatch *
|
||||
evdev_configure_device(struct evdev_device *device)
|
||||
{
|
||||
|
|
@ -1893,9 +1905,9 @@ evdev_configure_device(struct evdev_device *device)
|
|||
evdev_disable_accelerometer_axes(device);
|
||||
}
|
||||
|
||||
if (udev_tags == (EVDEV_UDEV_TAG_INPUT|EVDEV_UDEV_TAG_JOYSTICK)) {
|
||||
if (evdev_device_is_joystick_or_gamepad(device)) {
|
||||
evdev_log_info(device,
|
||||
"device is a joystick, ignoring\n");
|
||||
"device is a joystick or a gamepad, ignoring\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue