I need to write a script to detect if the physical touchscreen is connected to my Android device at boot time.
I tried to list the content of the folder /dev/input
via adb and I obtain the following output:
root@q88:/dev/input # ls
event0
event1
event2
event3
event4
mice
If I am not mistaken, event0
identifies the touchscreen, but it is visible in both case the touchscreen is connected or not.
Is there a way to detect if the touchscreen is connected to the device?
Thanks in advance.
You can read
/proc/bus/input/devices
to get details of your existing input devices.Depending on your hardware's name, you could do something like that and check if there is any output:
This is the full output of
/proc/bus/input/devices
:To test if the device is actually attached, you can try simulating events and see if you get any errors:
Find a driver name for the touch controller of your device. Then check its
sysfs
location. There will be few files mapped to the internal variables which were populated with data read from the physical touchscreen device during its initialization. For example most touchscreen controllers have updateable firmware and provide a way to query its current version.One of my devices uses
atmel_mxt_ts
touchscreen controller and itssysfs
location is/sys/bus/i2c/drivers/atmel_mxt_ts/1-004a/
. There is afw_version
file in that folder. If the physical touchscreen is connected that file would contain the current firmware label. The empty file would mean that there is no touchscreen.