Is there a way to read contents /proc/bus/input/devices
programmatically using some sysfs
structures ?
I know I can parse the file and get values. But I am looking if there is a better method.
There is. You can use libsysfs
. Here is paper from IBM about it's API etc. - Libsysfs - a programming interface to gather device information in Linux
That being said, it is discouraged by Linux kernel developers - Rules on how to access information in the Linux kernel sysfs
Do not use libsysfs It makes assumptions about sysfs which are not true. Its API does not offer any abstraction, it exposes all the kernel driver-core implementation details in its own API. Therefore it is not better than reading directories and opening the files yourself. Also, it is not actively maintained, in the sense of reflecting the current kernel development. The goal of providing a stable interface to sysfs has failed; it causes more problems than it solves. It violates many of the rules in this document.