on xenial help sign in
Fix and clean up InputInfo plugin

- QInputDeviceInfoPrivate::addDevice was bailing out before setting the device path, making it impossible for indexOf() to find the input device. This happens on a desktop/laptop as the user where unity8 runs cannot open input device files but it's still able to get info about it trough udev API - Removed a lot of unnecessary debug messages

commit2e417ea2fec2b4086538b290953b8fc460abc39f authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateWed 5 Aug 2015, 10:21 (11 years ago) parente949943
1 file changed+2−11
plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux.cpp+2−11
plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux.cpp+2−11
@@ -101,8 +101,6 @@ void QInputDeviceInfoPrivate::init()
101101 if (!iDevice)
102102 continue;
103103
104− qDebug() << "*** ADDING DEVICE" << eventPath;
105−
106104 iDevice->setTypes(getInputTypes(dev));
107105
108106 if (iDevice->switches().count() > 0 && iDevice->buttons().count() == 0)
@@ -125,12 +123,6 @@ void QInputDeviceInfoPrivate::init()
125123
126124QInputDeviceInfo::InputTypes QInputDeviceInfoPrivate::getInputTypes( struct udev_device *dev)
127125{
128− qDebug() << "******* have input type Keyboard" << udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD");
129− qDebug() << "******* have input type Mouse" << udev_device_get_property_value(dev, "ID_INPUT_MOUSE");
130− qDebug() << "******* have input type Touchpad" << udev_device_get_property_value(dev, "ID_INPUT_TOUCHPAD");
131− qDebug() << "******* have input type Touchscreen" << udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN");
132− qDebug() << "******* have input type Tablet" << udev_device_get_property_value(dev, "ID_INPUT_TABLET");
133− qDebug() << "******* have input type joystick" << udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK");
134126 QInputDeviceInfo::InputTypes types = QInputDeviceInfo::Unknown;
135127 if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD"), "1") == 0 )
136128 types |= QInputDeviceInfo::Keyboard;
@@ -151,6 +143,7 @@ QInputDeviceInfo::InputTypes QInputDeviceInfoPrivate::getInputTypes( struct udev
151143QInputDevice *QInputDeviceInfoPrivate::addDevice(const QString &path)
152144{
153145 QInputDevice *inputDevice = new QInputDevice(this);
146+ inputDevice->setDevicePath(path);
154147
155148 struct libevdev *dev = NULL;
156149 int fd;
@@ -158,17 +151,15 @@ QInputDevice *QInputDeviceInfoPrivate::addDevice(const QString &path)
158151 fd = open(path.toLatin1(), O_RDONLY|O_NONBLOCK);
159152
160153 if (fd == -1) {
161− qDebug() << "Failed to open";
162154 return inputDevice;
163155 }
164156 rc = libevdev_new_from_fd(fd, &dev);
165157 if (rc < 0) {
166− qDebug() << "Failed to init libevdev ("<< strerror(-rc) << ")";
158+ qWarning() << "Failed to init libevdev ("<< strerror(-rc) << ")";
167159 return inputDevice;
168160 }
169161
170162 inputDevice->setName(QString::fromLatin1(libevdev_get_name(dev)));
171− inputDevice->setDevicePath(path);
172163 for (int i = 0; i < EV_MAX; i++) {
173164 if (i == EV_KEY || i == EV_SW || i == EV_REL
174165 || i == EV_REL || i == EV_ABS) {