[cpp] view plaincopyprint?
static void ft5x0x_ts_release(void)
{
struct ft5x0x_ts_data *data = i2c_get_clientdata(this_client);
#ifdef FT5X0X_MULTI_TOUCH
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, 0);
input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 0);
input_report_key(data->input_dev, BTN_TOUCH, 0);
#else
input_report_abs(data->input_dev, ABS_PRESSURE, 0);
input_report_key(data->input_dev, BTN_TOUCH, 0);
#endif
input_sync(data->input_dev);
}
static int ft5x0x_read_data(void)
{
struct ft5x0x_ts_data *data = i2c_get_clientdata(this_client);
struct ts_event *event = &data->event;
u32 buf[32] = {0};
int ret = -1;
#ifdef FT5X0X_MULTI_TOUCH
ret = ft5x0x_i2c_rxdata(buf, 31);
#else
ret = ft5x0x_i2c_rxdata(buf, 7);
#endif
if (ret < 0) {
printk("%s read_data i2c_rxdata failed: %d\n", __func__, ret);
}
memset(event, 0, sizeof(struct ts_event));
event->touch_point = buf[2] & 0x07;
if (event->touch_point == 0) {
ft5x0x_ts_release();
return 1;
}
#ifdef FT5X0X_MULTI_TOUCH
switch (event->touch_point) {
case 5:
event->x5 = (s16)(buf[0x1b] & 0x0F)<<8 | (s16)buf[0x1c];
event->y5 = (s16)(buf[0x1d] & 0x0F)<<8 | (s16)buf[0x1e];
case 4:
event->x4 = (s16)(buf[0x15] & 0x0F)<<8 | (s16)buf[0x16];
event->y4 = (s16)(buf[0x17] & 0x0F)<<8 | (s16)buf[0x18];
case 3:
event->x3 = (s16)(buf[0x0f] & 0x0F)<<8 | (s16)buf[0x10];
event->y3 = (s16)(buf[0x11] & 0x0F)<<8 | (s16)buf[0x12];
case 2:
event->x2 = (s16)(buf[9] & 0x0F)<<8 | (s16)buf[10];
event->y2 = (s16)(buf[11] & 0x0F)<<8 | (s16)buf[12];
case 1:
event->x1 = (s16)(buf[3] & 0x0F)<<8 | (s16)buf[4];
event->y1 = (s16)(buf[5] & 0x0F)<<8 | (s16)buf[6];
break;
default:
return -1;
}
#else
if (event->touch_point == 1) {
event->x1 = (s16)(buf[3] & 0x0F)<<8 | (s16)buf[4];
event->y1 = (s16)(buf[5] & 0x0F)<<8 | (s16)buf[6];
}
#endif
event->pressure = 200;
return 0;
}
static void ft5x0x_reprot_value(void)
{
struct ft5x0x_ts_data *data = i2c_get_clientdata(this_client);
struct ts_event *event = &data->event;
#ifdef FT5X0X_MULTI_TOUCH
switch(event->touch_point) {
case 5:
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, event->pressure);
input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->x5);
input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->y5);
input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, event->pressure);
input_mt_sync(data->input_dev);
case 4:
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, event->pressure);
input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->x4);
input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->y4);
input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, event->pressure);
input_mt_sync(data->input_dev);
case 3:
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, event->pressure);
input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->x3);
input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->y3);
input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, event->pressure);
input_mt_sync(data->input_dev);
case 2:
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, event->pressure);
input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->x2);
input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->y2);
input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, event->pressure);
input_mt_sync(data->input_dev);
case 1:
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, event->pressure);
input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->x1);
input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->y1);
input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, event->pressure);
input_mt_sync(data->input_dev);
break;
default:
break;
}
#else
if (event->touch_point == 1) {
input_report_abs(data->input_dev, ABS_X, event->x1);
input_report_abs(data->input_dev, ABS_Y, event->y1);
input_report_abs(data->input_dev, ABS_PRESSURE, event->pressure);
}
input_report_key(data->input_dev, BTN_TOUCH, 1);
#endif
input_sync(data->input_dev);
用户1057999 2015-11-23 11:52