热度 26
2012-4-18 10:31
32384 次阅读|
1 个评论
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 = {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 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 0x0F)8 | (s16)buf ; event-y5 = (s16)(buf 0x0F)8 | (s16)buf ; case 4: event-x4 = (s16)(buf 0x0F)8 | (s16)buf ; event-y4 = (s16)(buf 0x0F)8 | (s16)buf ; case 3: event-x3 = (s16)(buf 0x0F)8 | (s16)buf ; event-y3 = (s16)(buf 0x0F)8 | (s16)buf ; case 2: event-x2 = (s16)(buf 0x0F)8 | (s16)buf ; event-y2 = (s16)(buf 0x0F)8 | (s16)buf ; case 1: event-x1 = (s16)(buf 0x0F)8 | (s16)buf ; event-y1 = (s16)(buf 0x0F)8 | (s16)buf ; break; default: return -1; } #else if (event-touch_point == 1) { event-x1 = (s16)(buf 0x0F)8 | (s16)buf ; event-y1 = (s16)(buf 0x0F)8 | (s16)buf ; } #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); //摘自:http://blog.csdn.net/sunsea1026/article/details/7415803