1.触摸屏属于input设备,住、主设备号是固定是13,但是次设备号,应该不是固定。
2.android会遍历/dev/input, 进行ioctl,读取设备的信息,来判断是不是触摸屏设备。
位置frameworks/base/services/input/EventHub.cpp
status_t EventHub::openDeviceLocked(const char *devicePath)
// Figure out the kinds of events the device reports.读取设备的信息
ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(device->keyBitmask)), device->keyBitmask);
ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(device->absBitmask)), device->absBitmask);
ioctl(fd, EVIOCGBIT(EV_REL, sizeof(device->relBitmask)), device->relBitmask);
ioctl(fd, EVIOCGBIT(EV_SW, sizeof(device->swBitmask)), device->swBitmask);
ioctl(fd, EVIOCGBIT(EV_LED, sizeof(device->ledBitmask)), device->ledBitmask);
ioctl(fd, EVIOCGBIT(EV_FF, sizeof(device->ffBitmask)), device->ffBitmask);
ioctl(fd, EVIOCGPROP(sizeof(device->propBitmask)), device->propBitmask);
内核实现的ioctl
omap/drivers/input/evdev.c
static int handle_eviocgbit(struct input_dev *dev,
unsigned int type, unsigned int size,
void __user *p, int compat_mode)
drivers/input/touchscreen/wacom_w8001.c
static int w8001_setup(struct w8001 *w8001)
input_set_abs_params(dev, ABS_MT_POSITION_X,
0, touch.x, 0, 0);
input_set_abs_params(dev, ABS_MT_POSITION_Y,
0, touch.y, 0, 0);
input_set_abs_params(dev, ABS_MT_TOOL_TYPE,
0, MT_TOOL_MAX, 0, 0);
cat /proc/bus/input/devices 可以看input设备的属性。
getevent /dev/input/event0 可以看触摸屏的坐标数据。