mtk android tp 触感震动无效的更改

更改思路:

请修改TP 驱动以坐标方式上报··back ,menu key,如果直接在TP driver中去上报key, android framework`不会走震动

  1. static int tpd_touchinfo(struct TouchInfoT *cinfo, struct TouchInfoT *pinfo) 
  2.     u32 retval; 
  3.     u8 key; 
  4.     u8 touchData = 0; 
  5.      
  6.     //pinfo->count = cinfo->count; 
  7.     memcpy(pinfo, cinfo, sizeof(struct TouchInfoT)); 
  8.      
  9.     //add for sure addr correct 
  10.     //i2c_client->addr = 0x4c; 
  11.     retval = i2c_master_recv_ext(i2c_client, (u8 *)&TpdTouchData, sizeof(TpdTouchData)); 
  12.  
  13.     if(TpdTouchData.packet_id != 0x52 ) 
  14.        { 
  15.         return 0; 
  16.        } 
  17.     /*touch*/ 
  18.     if(TpdTouchData.packet_id == 0x52) 
  19.     { 
  20.  
  21. /*TPD_LOGV("----libin TpdTouchData.packet_id=%d,TpdTouchData.x_h_y_h=%d,TpdTouchData.x_l=%d,TpdTouchData.y_l=%d\n",
  22.     TpdTouchData.packet_id,TpdTouchData.x_h_y_h,TpdTouchData.x_l,TpdTouchData.y_l);
  23. TPD_LOGV("----libin TpdTouchData.disx_h_disy_h=%d,TpdTouchData.disx_l=%d,TpdTouchData.disy_l=%d,TpdTouchData.checksum=%d\n",
  24.     TpdTouchData.disx_h_disy_h,TpdTouchData.disx_l,TpdTouchData.disy_l,TpdTouchData.checksum);  */ 
  25.  
  26. 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"
  27.     TpdTouchData.x_h_y_h,TpdTouchData.x_l,TpdTouchData.y_l,TpdTouchData.disx_h_disy_h);  
  28.  
  29.         if(TpdTouchData.x_h_y_h == 0xFF  
  30.             && TpdTouchData.x_l == 0xFF  
  31.             && TpdTouchData.y_l == 0xFF  
  32.             && TpdTouchData.disx_h_disy_h == 0xFF  
  33.           ) 
  34.         { 
  35.         TPD_LOGV("----libin  1\n"); 
  36. #if 1// def TPD_HAVE_BUTTON 
  37.          { 
  38.             U8 *p = &TpdTouchData; 
  39.             cinfo->key_value = 0; 
  40.             cinfo->key_value = *(p+5);            
  41.             TPD_LOGV("+++++++zym+++++++TPD_HAVE_BUTTON:(%d)\n",cinfo->key_value); 
  42.             { 
  43.                 //tpd_button_msg213x(cinfo->key_value); 
  44.                 //tpd_button(0,0,cinfo->key_value); 
  45.                 if(cinfo->key_value == 1) 
  46.                 { 
  47. #ifdef HQ_A25_NANBO_CTP_MSG2133_KEY 
  48.                              touchData = KEY_BACK;   
  49. #else   
  50.                              touchData = KEY_MENU; 
  51. #endif 
  52.                 } 
  53.                 else if(cinfo->key_value == 2) 
  54.                 { 
  55. #ifdef HQ_CTP_MSG21XX_REVERT 
  56.                     touchData = KEY_BACK; 
  57. #elif defined(HQ_A25_NANBO_CTP_MSG2133_KEY) 
  58.                                         touchData = KEY_MENU; 
  59. #elif defined(HQ_A25P_MUDONG_CTP_MSG2133_KEY) 
  60.                                          touchData = KEY_BACK; 
  61. #else 
  62.                     touchData = KEY_HOME; 
  63. #endif 
  64.                 } 
  65.                 else if(cinfo->key_value == 4) 
  66.                 { 
  67.                     touchData = KEY_BACK; 
  68.                 } 
  69.                 else if(cinfo->key_value == 8) 
  70.                 { 
  71.                     touchData = KEY_SEARCH; 
  72.                 } 
  73.                 else 
  74.                 { 
  75.                     touchData = 0; 
  76.                 } 
  77.                 TPD_LOGV("[MSG2133]+++++++zym+++++++:(%d)\n",touchData); 
  78.  
  79.                   
  80.             //libin add start 20121111 
  81.             if( KEY_MENU == touchData) 
  82.                 { 
  83.             cinfo->x1 = 50; 
  84.             cinfo->y1 = 510; 
  85.  
  86.             cinfo->x2 = 60; 
  87.             cinfo->y2 = 520; 
  88.  
  89.  
  90.             TPD_LOGV("[MSG2133]++++++++zym+++++++++ap1:x1 y1: (%3d,%3d)(%3d,%3d)\n",cinfo->x1,cinfo->y1,TPD_RES_X,TPD_RES_Y); 
  91.             TPD_LOGV("[MSG2133]++++++++zym+++++++++ap1:x2 y2: (%3d,%3d)(%3d,%3d)\n",cinfo->x2,cinfo->y2,TPD_RES_X,TPD_RES_Y); 
  92.              
  93.                   cinfo->pressure = 1; 
  94.                   cinfo->count =  1; 
  95.                   return 1; 
  96.                 } 
  97.             else if( KEY_BACK == touchData) 
  98.                 { 
  99.             cinfo->x1 = 210; 
  100.             cinfo->y1 = 510; 
  101.  
  102.             cinfo->x2 = 220; 
  103.             cinfo->y2 = 520; 
  104.  
  105.  
  106.             TPD_LOGV("[MSG2133]++++++++zym+++++++++ap1:x1 y1: (%3d,%3d)(%3d,%3d)\n",cinfo->x1,cinfo->y1,TPD_RES_X,TPD_RES_Y); 
  107.             TPD_LOGV("[MSG2133]++++++++zym+++++++++ap1:x2 y2: (%3d,%3d)(%3d,%3d)\n",cinfo->x2,cinfo->y2,TPD_RES_X,TPD_RES_Y); 
  108.              
  109.                   cinfo->pressure = 1; 
  110.                   cinfo->count =  1; 
  111.                   return 1; 
  112.                 } 
  113.             //libin add end 
  114.                 /*libin del 20121011
  115.                 if(touchData)
  116.                     input_report_key(tpd->dev,touchData,1);
  117.                 else
  118.                 {
  119.                     input_report_key(tpd->dev,KEY_MENU,0);
  120.                     input_report_key(tpd->dev,KEY_HOME,0);
  121.                     input_report_key(tpd->dev,KEY_BACK,0);
  122.                     input_report_key(tpd->dev,KEY_SEARCH,0);
  123.                 }*/ 
  124.             } 
  125.          } 
  126. #endif 
  127.             cinfo->count =  0;  
  128.               
  129.         } 
  130.         else if(TpdTouchData.disx_h_disy_h == 0 
  131.             && TpdTouchData.disx_l == 0  
  132.             && TpdTouchData.disy_l == 0) 
  133.             { 
  134.              TPD_LOGV("----libin  2\n"); 
  135.             cinfo->count = 1; 
  136.             } 
  137.         else 
  138.             { 
  139.              TPD_LOGV("----libin  3\n"); 
  140.             cinfo->count = 2; 
  141.             } 
  142.          
  143.         TPD_LOGV("[MSG2133]cinfo: count=%d\n",cinfo->count); 
  144.         if(cinfo->count > 0)    
  145.         { 
  146.             int tmp_x,tmp_y; 
  147.             /*point1*/ 
  148.              TPD_LOGV("----libin  4--------\n"); 
  149.              
  150.             cinfo->x1 = (((TpdTouchData.x_h_y_h&0xF0)<<4) | (TpdTouchData.x_l)); 
  151.             cinfo->y1 = (((TpdTouchData.x_h_y_h&0x0F)<<8) | (TpdTouchData.y_l)); 
  152.             TPD_LOGV("[MSG2133]+++zym+++(%3d,%3d)\n",cinfo->x1,cinfo->y1); 
  153.  
  154.             if(cinfo->count >1) 
  155.             {    
  156.                 /*point2*/ 
  157.                 short disx,disy; 
  158.      
  159.                 disx = (((TpdTouchData.disx_h_disy_h&0xF0)<<4) | (TpdTouchData.disx_l)); 
  160.                 disy = (((TpdTouchData.disx_h_disy_h&0x0F)<<8) | (TpdTouchData.disy_l)); 
  161.                 disy = (disy<<4); 
  162.                 disy = disy/16; 
  163.                 if(disx >= 2048) 
  164.                     disx -= 4096; 
  165.                 if(disy >= 2048) 
  166.                     disy -= 4096; 
  167.                 cinfo->x2 = cinfo->x1 + disx; 
  168.                 cinfo->y2 = cinfo->y1 + disy;              
  169.  
  170.                 tmp_x = cinfo->x2; 
  171.                 tmp_y = cinfo->y2; 
  172.                 cinfo->y2 = tmp_x * (TPD_RES_Y - 1)/ 2047; 
  173.                 cinfo->x2 = tmp_y * (TPD_RES_X - 1) / 2047;       
  174.             } 
  175.             tmp_x = cinfo->x1; 
  176.             tmp_y = cinfo->y1; 
  177.             cinfo->y1 = tmp_x * (TPD_RES_Y - 1) / 2047; 
  178.             cinfo->x1 = tmp_y * (TPD_RES_X - 1) / 2047; 
  179.              
  180.             //add by zym 2012-04-16 
  181.             #ifdef HQ_CTP_MSG21XX_REVERT 
  182.             #else 
  183.             cinfo->x1 = TPD_RES_X -1 - cinfo->x1; 
  184.             cinfo->x2 = TPD_RES_X - 1 -cinfo->x2; 
  185.             #endif 
  186.             TPD_LOGV("[MSG2133]++++++++zym+++++++++bp1:x1 y1: (%3d,%3d)(%3d,%3d)\n",cinfo->x1,cinfo->y1,TPD_RES_X,TPD_RES_Y); 
  187.             TPD_LOGV("[MSG2133]++++++++zym+++++++++bp1:x2 y2: (%3d,%3d)(%3d,%3d)\n",cinfo->x2,cinfo->y2,TPD_RES_X,TPD_RES_Y); 
  188.  
  189.             cinfo->pressure = 1; 
  190.             TPD_LOGV("[MSG2133]pressure: %d\n",cinfo->pressure); 
  191.         } 
  192.     } 
  193.     else 
  194.     { 
  195.         cinfo->count = 0; 
  196.     } 
  197.  
  198.     /*ergate-012 start*/ 
  199.     /*ergate-012 end*/ 
  200.  
  201.     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;
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值