更改思路:
请修改TP 驱动以坐标方式上报··back ,menu key,如果直接在TP driver中去上报key, android framework`不会走震动
- static int tpd_touchinfo(struct TouchInfoT *cinfo, struct TouchInfoT *pinfo)
- {
- u32 retval;
- u8 key;
- u8 touchData = 0;
- //pinfo->count = cinfo->count;
- memcpy(pinfo, cinfo, sizeof(struct TouchInfoT));
- //add for sure addr correct
- //i2c_client->addr = 0x4c;
- retval = i2c_master_recv_ext(i2c_client, (u8 *)&TpdTouchData, sizeof(TpdTouchData));
- if(TpdTouchData.packet_id != 0x52 )
- {
- return 0;
- }
- /*touch*/
- if(TpdTouchData.packet_id == 0x52)
- {
- /*TPD_LOGV("----libin TpdTouchData.packet_id=%d,TpdTouchData.x_h_y_h=%d,TpdTouchData.x_l=%d,TpdTouchData.y_l=%d\n",
- TpdTouchData.packet_id,TpdTouchData.x_h_y_h,TpdTouchData.x_l,TpdTouchData.y_l);
- TPD_LOGV("----libin TpdTouchData.disx_h_disy_h=%d,TpdTouchData.disx_l=%d,TpdTouchData.disy_l=%d,TpdTouchData.checksum=%d\n",
- TpdTouchData.disx_h_disy_h,TpdTouchData.disx_l,TpdTouchData.disy_l,TpdTouchData.checksum); */
- TPD_LOGV("----libin TpdTouchData.x_h_y_h=%d,TpdTouchData.x_l=%d,TpdTouchData.y_l=%d,TpdTouchData.disx_h_disy_h=%d,TpdTouchData.disx_h_disy_h=%d\n",
- TpdTouchData.x_h_y_h,TpdTouchData.x_l,TpdTouchData.y_l,TpdTouchData.disx_h_disy_h);
- if(TpdTouchData.x_h_y_h == 0xFF
- && TpdTouchData.x_l == 0xFF
- && TpdTouchData.y_l == 0xFF
- && TpdTouchData.disx_h_disy_h == 0xFF
- )
- {
- TPD_LOGV("----libin 1\n");
- #if 1// def TPD_HAVE_BUTTON
- {
- U8 *p = &TpdTouchData;
- cinfo->key_value = 0;
- cinfo->key_value = *(p+5);
- TPD_LOGV("+++++++zym+++++++TPD_HAVE_BUTTON:(%d)\n",cinfo->key_value);
- {
- //tpd_button_msg213x(cinfo->key_value);
- //tpd_button(0,0,cinfo->key_value);
- if(cinfo->key_value == 1)
- {
- #ifdef HQ_A25_NANBO_CTP_MSG2133_KEY
- touchData = KEY_BACK;
- #else
- touchData = KEY_MENU;
- #endif
- }
- else if(cinfo->key_value == 2)
- {
- #ifdef HQ_CTP_MSG21XX_REVERT
- touchData = KEY_BACK;
- #elif defined(HQ_A25_NANBO_CTP_MSG2133_KEY)
- touchData = KEY_MENU;
- #elif defined(HQ_A25P_MUDONG_CTP_MSG2133_KEY)
- touchData = KEY_BACK;
- #else
- touchData = KEY_HOME;
- #endif
- }
- else if(cinfo->key_value == 4)
- {
- touchData = KEY_BACK;
- }
- else if(cinfo->key_value == 8)
- {
- touchData = KEY_SEARCH;
- }
- else
- {
- touchData = 0;
- }
- TPD_LOGV("[MSG2133]+++++++zym+++++++:(%d)\n",touchData);
- //libin add start 20121111
- if( KEY_MENU == touchData)
- {
- cinfo->x1 = 50;
- cinfo->y1 = 510;
- cinfo->x2 = 60;
- cinfo->y2 = 520;
- TPD_LOGV("[MSG2133]++++++++zym+++++++++ap1:x1 y1: (%3d,%3d)(%3d,%3d)\n",cinfo->x1,cinfo->y1,TPD_RES_X,TPD_RES_Y);
- TPD_LOGV("[MSG2133]++++++++zym+++++++++ap1:x2 y2: (%3d,%3d)(%3d,%3d)\n",cinfo->x2,cinfo->y2,TPD_RES_X,TPD_RES_Y);
- cinfo->pressure = 1;
- cinfo->count = 1;
- return 1;
- }
- else if( KEY_BACK == touchData)
- {
- cinfo->x1 = 210;
- cinfo->y1 = 510;
- cinfo->x2 = 220;
- cinfo->y2 = 520;
- TPD_LOGV("[MSG2133]++++++++zym+++++++++ap1:x1 y1: (%3d,%3d)(%3d,%3d)\n",cinfo->x1,cinfo->y1,TPD_RES_X,TPD_RES_Y);
- TPD_LOGV("[MSG2133]++++++++zym+++++++++ap1:x2 y2: (%3d,%3d)(%3d,%3d)\n",cinfo->x2,cinfo->y2,TPD_RES_X,TPD_RES_Y);
- cinfo->pressure = 1;
- cinfo->count = 1;
- return 1;
- }
- //libin add end
- /*libin del 20121011
- if(touchData)
- input_report_key(tpd->dev,touchData,1);
- else
- {
- input_report_key(tpd->dev,KEY_MENU,0);
- input_report_key(tpd->dev,KEY_HOME,0);
- input_report_key(tpd->dev,KEY_BACK,0);
- input_report_key(tpd->dev,KEY_SEARCH,0);
- }*/
- }
- }
- #endif
- cinfo->count = 0;
- }
- else if(TpdTouchData.disx_h_disy_h == 0
- && TpdTouchData.disx_l == 0
- && TpdTouchData.disy_l == 0)
- {
- TPD_LOGV("----libin 2\n");
- cinfo->count = 1;
- }
- else
- {
- TPD_LOGV("----libin 3\n");
- cinfo->count = 2;
- }
- TPD_LOGV("[MSG2133]cinfo: count=%d\n",cinfo->count);
- if(cinfo->count > 0)
- {
- int tmp_x,tmp_y;
- /*point1*/
- TPD_LOGV("----libin 4--------\n");
- cinfo->x1 = (((TpdTouchData.x_h_y_h&0xF0)<<4) | (TpdTouchData.x_l));
- cinfo->y1 = (((TpdTouchData.x_h_y_h&0x0F)<<8) | (TpdTouchData.y_l));
- TPD_LOGV("[MSG2133]+++zym+++(%3d,%3d)\n",cinfo->x1,cinfo->y1);
- if(cinfo->count >1)
- {
- /*point2*/
- short disx,disy;
- disx = (((TpdTouchData.disx_h_disy_h&0xF0)<<4) | (TpdTouchData.disx_l));
- disy = (((TpdTouchData.disx_h_disy_h&0x0F)<<8) | (TpdTouchData.disy_l));
- disy = (disy<<4);
- disy = disy/16;
- if(disx >= 2048)
- disx -= 4096;
- if(disy >= 2048)
- disy -= 4096;
- cinfo->x2 = cinfo->x1 + disx;
- cinfo->y2 = cinfo->y1 + disy;
- tmp_x = cinfo->x2;
- tmp_y = cinfo->y2;
- cinfo->y2 = tmp_x * (TPD_RES_Y - 1)/ 2047;
- cinfo->x2 = tmp_y * (TPD_RES_X - 1) / 2047;
- }
- tmp_x = cinfo->x1;
- tmp_y = cinfo->y1;
- cinfo->y1 = tmp_x * (TPD_RES_Y - 1) / 2047;
- cinfo->x1 = tmp_y * (TPD_RES_X - 1) / 2047;
- //add by zym 2012-04-16
- #ifdef HQ_CTP_MSG21XX_REVERT
- #else
- cinfo->x1 = TPD_RES_X -1 - cinfo->x1;
- cinfo->x2 = TPD_RES_X - 1 -cinfo->x2;
- #endif
- TPD_LOGV("[MSG2133]++++++++zym+++++++++bp1:x1 y1: (%3d,%3d)(%3d,%3d)\n",cinfo->x1,cinfo->y1,TPD_RES_X,TPD_RES_Y);
- TPD_LOGV("[MSG2133]++++++++zym+++++++++bp1:x2 y2: (%3d,%3d)(%3d,%3d)\n",cinfo->x2,cinfo->y2,TPD_RES_X,TPD_RES_Y);
- cinfo->pressure = 1;
- TPD_LOGV("[MSG2133]pressure: %d\n",cinfo->pressure);
- }
- }
- else
- {
- cinfo->count = 0;
- }
- /*ergate-012 start*/
- /*ergate-012 end*/
- return 1;
- }
static int tpd_touchinfo(struct TouchInfoT *cinfo, struct TouchInfoT *pinfo)
{
u32 retval;
u8 key;
u8 touchData = 0;
//pinfo->count = cinfo->count;
memcpy(pinfo, cinfo, sizeof(struct TouchInfoT));
//add for sure addr correct
//i2c_client->addr = 0x4c;
retval = i2c_master_recv_ext(i2c_client, (u8 *)&TpdTouchData, sizeof(TpdTouchData));
if(TpdTouchData.packet_id != 0x52 )
{
return 0;
}
/*touch*/
if(TpdTouchData.packet_id == 0x52)
{
/*TPD_LOGV("----libin TpdTouchData.packet_id=%d,TpdTouchData.x_h_y_h=%d,TpdTouchData.x_l=%d,TpdTouchData.y_l=%d\n",
TpdTouchData.packet_id,TpdTouchData.x_h_y_h,TpdTouchData.x_l,TpdTouchData.y_l);
TPD_LOGV("----libin TpdTouchData.disx_h_disy_h=%d,TpdTouchData.disx_l=%d,TpdTouchData.disy_l=%d,TpdTouchData.checksum=%d\n",
TpdTouchData.disx_h_disy_h,TpdTouchData.disx_l,TpdTouchData.disy_l,TpdTouchData.checksum); */
TPD_LOGV("----libin TpdTouchData.x_h_y_h=%d,TpdTouchData.x_l=%d,TpdTouchData.y_l=%d,TpdTouchData.disx_h_disy_h=%d,TpdTouchData.disx_h_disy_h=%d\n",
TpdTouchData.x_h_y_h,TpdTouchData.x_l,TpdTouchData.y_l,TpdTouchData.disx_h_disy_h);
if(TpdTouchData.x_h_y_h == 0xFF
&& TpdTouchData.x_l == 0xFF
&& TpdTouchData.y_l == 0xFF
&& TpdTouchData.disx_h_disy_h == 0xFF
)
{
TPD_LOGV("----libin 1\n");
#if 1// def TPD_HAVE_BUTTON
{
U8 *p = &TpdTouchData;
cinfo->key_value = 0;
cinfo->key_value = *(p+5);
TPD_LOGV("+++++++zym+++++++TPD_HAVE_BUTTON:(%d)\n",cinfo->key_value);
{
//tpd_button_msg213x(cinfo->key_value);
//tpd_button(0,0,cinfo->key_value);
if(cinfo->key_value == 1)
{
#ifdef HQ_A25_NANBO_CTP_MSG2133_KEY
touchData = KEY_BACK;
#else
touchData = KEY_MENU;
#endif
}
else if(cinfo->key_value == 2)
{
#ifdef HQ_CTP_MSG21XX_REVERT
touchData = KEY_BACK;
#elif defined(HQ_A25_NANBO_CTP_MSG2133_KEY)
touchData = KEY_MENU;
#elif defined(HQ_A25P_MUDONG_CTP_MSG2133_KEY)
touchData = KEY_BACK;
#else
touchData = KEY_HOME;
#endif
}
else if(cinfo->key_value == 4)
{
touchData = KEY_BACK;
}
else if(cinfo->key_value == 8)
{
touchData = KEY_SEARCH;
}
else
{
touchData = 0;
}
TPD_LOGV("[MSG2133]+++++++zym+++++++:(%d)\n",touchData);
//libin add start 20121111
if( KEY_MENU == touchData)
{
cinfo->x1 = 50;
cinfo->y1 = 510;
cinfo->x2 = 60;
cinfo->y2 = 520;
TPD_LOGV("[MSG2133]++++++++zym+++++++++ap1:x1 y1: (%3d,%3d)(%3d,%3d)\n",cinfo->x1,cinfo->y1,TPD_RES_X,TPD_RES_Y);
TPD_LOGV("[MSG2133]++++++++zym+++++++++ap1:x2 y2: (%3d,%3d)(%3d,%3d)\n",cinfo->x2,cinfo->y2,TPD_RES_X,TPD_RES_Y);
cinfo->pressure = 1;
cinfo->count = 1;
return 1;
}
else if( KEY_BACK == touchData)
{
cinfo->x1 = 210;
cinfo->y1 = 510;
cinfo->x2 = 220;
cinfo->y2 = 520;
TPD_LOGV("[MSG2133]++++++++zym+++++++++ap1:x1 y1: (%3d,%3d)(%3d,%3d)\n",cinfo->x1,cinfo->y1,TPD_RES_X,TPD_RES_Y);
TPD_LOGV("[MSG2133]++++++++zym+++++++++ap1:x2 y2: (%3d,%3d)(%3d,%3d)\n",cinfo->x2,cinfo->y2,TPD_RES_X,TPD_RES_Y);
cinfo->pressure = 1;
cinfo->count = 1;
return 1;
}
//libin add end
/*libin del 20121011
if(touchData)
input_report_key(tpd->dev,touchData,1);
else
{
input_report_key(tpd->dev,KEY_MENU,0);
input_report_key(tpd->dev,KEY_HOME,0);
input_report_key(tpd->dev,KEY_BACK,0);
input_report_key(tpd->dev,KEY_SEARCH,0);
}*/
}
}
#endif
cinfo->count = 0;
}
else if(TpdTouchData.disx_h_disy_h == 0
&& TpdTouchData.disx_l == 0
&& TpdTouchData.disy_l == 0)
{
TPD_LOGV("----libin 2\n");
cinfo->count = 1;
}
else
{
TPD_LOGV("----libin 3\n");
cinfo->count = 2;
}
TPD_LOGV("[MSG2133]cinfo: count=%d\n",cinfo->count);
if(cinfo->count > 0)
{
int tmp_x,tmp_y;
/*point1*/
TPD_LOGV("----libin 4--------\n");
cinfo->x1 = (((TpdTouchData.x_h_y_h&0xF0)<<4) | (TpdTouchData.x_l));
cinfo->y1 = (((TpdTouchData.x_h_y_h&0x0F)<<8) | (TpdTouchData.y_l));
TPD_LOGV("[MSG2133]+++zym+++(%3d,%3d)\n",cinfo->x1,cinfo->y1);
if(cinfo->count >1)
{
/*point2*/
short disx,disy;
disx = (((TpdTouchData.disx_h_disy_h&0xF0)<<4) | (TpdTouchData.disx_l));
disy = (((TpdTouchData.disx_h_disy_h&0x0F)<<8) | (TpdTouchData.disy_l));
disy = (disy<<4);
disy = disy/16;
if(disx >= 2048)
disx -= 4096;
if(disy >= 2048)
disy -= 4096;
cinfo->x2 = cinfo->x1 + disx;
cinfo->y2 = cinfo->y1 + disy;
tmp_x = cinfo->x2;
tmp_y = cinfo->y2;
cinfo->y2 = tmp_x * (TPD_RES_Y - 1)/ 2047;
cinfo->x2 = tmp_y * (TPD_RES_X - 1) / 2047;
}
tmp_x = cinfo->x1;
tmp_y = cinfo->y1;
cinfo->y1 = tmp_x * (TPD_RES_Y - 1) / 2047;
cinfo->x1 = tmp_y * (TPD_RES_X - 1) / 2047;
//add by zym 2012-04-16
#ifdef HQ_CTP_MSG21XX_REVERT
#else
cinfo->x1 = TPD_RES_X -1 - cinfo->x1;
cinfo->x2 = TPD_RES_X - 1 -cinfo->x2;
#endif
TPD_LOGV("[MSG2133]++++++++zym+++++++++bp1:x1 y1: (%3d,%3d)(%3d,%3d)\n",cinfo->x1,cinfo->y1,TPD_RES_X,TPD_RES_Y);
TPD_LOGV("[MSG2133]++++++++zym+++++++++bp1:x2 y2: (%3d,%3d)(%3d,%3d)\n",cinfo->x2,cinfo->y2,TPD_RES_X,TPD_RES_Y);
cinfo->pressure = 1;
TPD_LOGV("[MSG2133]pressure: %d\n",cinfo->pressure);
}
}
else
{
cinfo->count = 0;
}
/*ergate-012 start*/
/*ergate-012 end*/
return 1;
}