Closed GoogleCodeExporter closed 9 years ago
Very good investigative work!
Spawning just one more grep process, the workaround could be as easy as:
grep -E 'Name|Handlers' /proc/bus/input/devices | grep -EA1 '[Kk]eyboard' |
grep -Eo 'event[0-9]+'
However, I would be very interested in your solution. :)
Original comment by kernc...@gmail.com
on 15 Aug 2010 at 6:20
Disregard that last part.
I am more than interested. :D
Original comment by kernc...@gmail.com
on 15 Aug 2010 at 6:23
Hello!
The attached file contains the code for a new device detection routine, which I
just finished writing.
Here is how it works:
- opens the file /proc/bus/input/devices
- scans for rows that begin with 'N' (name rows)
- checks if the name row contains text that indicates it's a keyboard (contains
"keyboard", "kbd", "hid", etc.)
- then scans for rows that begin with 'H' (handler rows)
- extracts the event number from the handler row
It has some features to try to make it robust. For example, if a keyboard
device is found but there is no handler row, then the code just continues
looking for the next keyboard device.
Also the code should be easy to modify to locate all keyboard devices (e.g.
return a std::vector<std::string> containing all input devices found). Right
now it stops when it finds the first one.
Finally, please note that I have only spent about 30 minutes testing this
routine. It seems to work properly on my machine, but bugs may turn up. :-)
Best regards,
Markus.
Original comment by msvil...@gmail.com
on 15 Aug 2010 at 6:47
Attachments:
Oops :-) I just noticed that my determine_input_device() function is missing
the following line at the very end:
return std::string();
If no keyboard devices are found, and a return statement is not there, then we
will get undefined behaviour.
Regards,
Markus.
Original comment by msvil...@gmail.com
on 15 Aug 2010 at 6:52
Device detection now parses 'Handlers' line and results in a vector since r74.
Original comment by kernc...@gmail.com
on 19 Aug 2010 at 5:58
Original issue reported on code.google.com by
msvil...@gmail.com
on 15 Aug 2010 at 5:48