android 触摸屏检测,Android:以编程方式检测设备是否已连接硬件触摸屏

您可以将/ proc / bus / input / devices读取到

get details of your existing input devices。

根据您的硬件名称,您可以执行类似操作,并检查是否有任何输出:

cat /proc/bus/input/devices | grep "Name=" | grep "Touch"

这是/ proc / bus / input / devices的完整输出:

I: Bus=0011 Vendor=0002 Product=0008 Version=2222

N: Name="AlpsPS/2 ALPS DualPoint TouchPad"

P: Phys=isa0060/serio1/input0

S: Sysfs=/class/input/input2

H: Handlers=mouse1 event2 ts1

B: EV=f

B: KEY=420 0 70000 0 0 0 0 0 0 0 0

B: REL=3

B: ABS=1000003

[...] (blank line, next device)

The B in front stands for bitmap, N, P, S, U, H are simply first

letter in corresponding name value and I is for ID. In ordered

fashion:

I → @id: id of the device (struct input_id)

Bus → id.bustype

Vendor → id.vendor

Product → id.product

Version → id.version

N → name of the device

P → physical path to the device in the system hierarchy

S → sysfs path

U → unique identification code for the device (if device has it)

H → list of input handles associated with the device

B → bitmaps

PROP → device properties and quirks

EV → types of events supported by the device

KEY → keys/buttons this device has

MSC → miscellaneous events supported by the device

LED → leds present on the device

REL → relative address

ABS → absolute address

要测试设备是否实际连接,您可以尝试模拟事件,看看是否有任何错误:

input tap [x] [y]

Android comes with an input command-line tool that can simulate miscellaneous input events.

input → The command line tool to send events

tap → the action

[x] → X coordinate on the screen

[y] → Y coordinate on the screen

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值