diff --git a/src/api/udev/JoystickUdev.cpp b/src/api/udev/JoystickUdev.cpp index c4df957b..3a026cdd 100644 --- a/src/api/udev/JoystickUdev.cpp +++ b/src/api/udev/JoystickUdev.cpp @@ -11,10 +11,12 @@ #include "log/Log.h" #include +#include #include #include #include #include +#include #include #include #include @@ -278,15 +280,18 @@ bool CJoystickUdev::GetProperties() } SetName(name); - // Don't worry about unref'ing the parent - struct udev_device* parent = udev_device_get_parent_with_subsystem_devtype(m_dev, "usb", "usb_device"); - - const char* buf; - if ((buf = udev_device_get_sysattr_value(parent, "idVendor")) != nullptr) - SetVendorID(strtol(buf, NULL, 16)); + unsigned short id[4] = {}; + char val[16] = {}; + if (ioctl(m_fd, EVIOCGID, id) == 0) + { + std::sprintf(val, "%x", id[ID_VENDOR]); + SetVendorID(strtol(val, NULL, 16)); + dsyslog("[udev] Joystick information vendorid=%s for %s", val, m_path.c_str()); - if ((buf = udev_device_get_sysattr_value(parent, "idProduct")) != nullptr) - SetProductID(strtol(buf, NULL, 16)); + std::sprintf(val, "%x", id[ID_PRODUCT]); + SetProductID(strtol(val, NULL, 16)); + dsyslog("[udev] Joystick information productid=%s for %s", val, m_path.c_str()); + } struct stat st; if (fstat(m_fd, &st) < 0)