Android: Programmatically detect if device has hardware touchscreen connected

后端 未结 2 1757
北恋
北恋 2021-02-18 15:44

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

2条回答
  •  一个人的身影
    2021-02-18 16:16

    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 its sysfs location is /sys/bus/i2c/drivers/atmel_mxt_ts/1-004a/. There is a fw_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.

提交回复
热议问题