Could not read from input device: No such device
-
I have a Qt application that's been built to run on Embedded Linux platform (i.Mx.6). My application should support both touch screen as primary input device and an optional USB keyboard if connected. So for now, I have configured to be launched as mentioned below:
my-qt-app -plugin tslib:/dev/input/event0 -plugin evdevkeyboard:/dev/input/event1
My application is able to detect the touchscreen and keyboard properly, BUT, I am noticing a problem if I unplug the keyboard while my application is still running, I see the below error on the console:
Could not read from input device: No such device
And my Qt application is lagging and is very slow in responding to the touch screen. Looking at the above error message it seems my application is still expecting some sort of data from the keyboard ?
Can somebody help me to recover from this error please, also if there is a way that I can detect the keyboard presence runtime so that I no need to pass -plugin evdevkeyboard as command line argument to my GUI application.
-
Hi and welcome to devnet,
One thing that might be happening: when you plug your device back it doesn't get the same device id assigned.
That's one thing you should check.
You can try to add a rule to udev that will always give the same name to your keyboard device or make a symbolic link to it.
One last thing that could be interesting is to check whether there's a module providing a device like mousedev but for keyboard (see here
-
Hi SGaist,
Thank you for the reply. After spending some time to learn about this issue, I found there are two problems that I need to resolve: The first one is as you pointed out:
- I need to fix the mapping of devices so that the are not being assigned eventx locations dynamically and that I need to set same name for keyboard and mouse and find a way to pass this to my startup script so that my-qt-app detects the right device.
- The deletion/reinsertion of the usb keyboard after boot – that trigger the never ending stream of error message " Could not read from input device: No such device" that looks like a Qt issue as the keyboard is not being remapped to a different eventx
Am still trying to fix the point (1), because am pretty new to Linux, and my target uses mdev. And my target board has only one USB port and am using an USB hub to which I am connecting USB Keyboard and USB Mouse - it is just working fine If I connect the devices to the same port and if devices are present on bootup.
-
Currently if I have all input devices (Keyboard, mouse and touchscreen) connected/configured on bootup to my target. And then launch my qt application with command line parameters passing the plugin information as below:
my-qt-app -plugin tslib:/dev/input/event2 -plugin evdevmouse:/dev/input/event1 -plugin evdevkeyboard:/dev/input/event0 &
My application works fine. There are two important things I need to get it done first:
- I need same name for each input device all the time irrespective of whether the devices are plugged on bootup or after bootup. That way my Qt application is aware that touchscreen is always /dev/input/event2 (for example).
- And if the input device is removed/unplugged my Qt application should stop expecting some information from the device and should not produce the error message am observing. And that, if the device is connected back it should detect and work normally.
Please advise, thanks in advance.
-
The probably most useful option would be to implement hot plug handling,
-
My Qt application used a QML item
TextField { }
using which am my application would receive the data from USB keyboard. I have built this simple Qt application to run on Android smart phone and on iMx6 based device running Embedded Linux on it.
My Qt Application on android smart phone was able to get the inputs from USB Keyboard the moment I connect the keyboard to the smart phone. But, If I do the same on the iMx6 based target I have to pass -plugin evdevkeyboar:/dev/input/eventx , maybe because our Kernel doesn't support detecting hot pluggable devices and pass it on to the Qt application like Android does.
I am pretty new to Linux world, so am still trying to figure out what I need do so that my Qt application on iMx6 based target would work same as how it was working on Android smart phone.
-
AFAIK, if you have udev, you should get device detection for your application.