Tlsr8258开发-在鼠标工程上改touch screen实现单点

1.在app.c中修改广播包数据

const u8	tbl_advData[] = {
	 0x05, 0x09, 'V', 'H', 'I', 'D',
	 0x02, 0x01, 0x05, 							// BLE limited discoverable mode and BR/EDR not supported
	 0x03, 0x19, 0xC5, 0x03, 					// 384, Generic Remote Control, Generic category
	 0x05, 0x02, 0x12, 0x18, 0x0F, 0x18,		// incomplete list of service class UUIDs (0x1812, 0x180F)
};

2.修改报告描述符

static const u8 reportMap[] =
{
	0x05, 0x0D  ,   //  Usage Page (Digitizer)
	0x09, 0x04  ,   //  Usage (Touch Screen)
	0xA1, 0x01  ,   //  Collection (Application)
	0x85, 0x04  ,   //      Report ID (4)
	0x09, 0x22  ,   //      Usage (Finger)
	0xA1, 0x02  ,   //      Collection (Logical)
	0x05, 0x0D  ,   //          Usage Page (Digitizer)
	0x95, 0x01  ,   //          Report Count (1)
	0x75, 0x06  ,   //          Report Size (6)
	0x09, 0x51  ,   //          Usage (Contact Identifier)
	0x15, 0x00  ,   //          Logical Minimum (0)
	0x25, 0x3F  ,   //          Logical Maximum (63)
	0x81, 0x02  ,   //          Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
	0x09, 0x42  ,   //          Usage (Tip Switch)
	0x25, 0x01  ,   //          Logical Maximum (1)
	0x75, 0x01  ,   //          Report Size (1)
	0x95, 0x01  ,   //          Report Count (1)
	0x81, 0x02  ,   //          Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
	0x75, 0x01  ,   //          Report Size (1)
	0x95, 0x01  ,   //          Report Count (1)
	0x81, 0x03  ,   //          Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
	0x05, 0x01  ,   //          Usage Page (Generic Desktop)
	0x75, 0x10  ,   //          Report Size (16)
	0x55, 0x0E  ,   //          Unit Exponent (-2)
	0x65, 0x11  ,   //          Unit (SI Lin: Length (cm))
	0x09, 0x30  ,   //          Usage (X)
	0x26, 0x00,0x40,    //          Logical Maximum (16384)
	0x35, 0x00, //          Physical Minimum (0)
	0x46, 0xC6,0x11,    //          Physical Maximum (4550)
	0x81, 0x42, //          Input (Data,Var,Abs,NWrp,Lin,Pref,Null,Bit)
	0x09, 0x31, //          Usage (Y)
	0x26, 0x00,0x40,    //          Logical Maximum (16384)
	0x46, 0x00,0x0A,    //          Physical Maximum (2560)
	0x81, 0x42  ,   //          Input (Data,Var,Abs,NWrp,Lin,Pref,Null,Bit)
	0xC0,       //      End Collection
	0xc0
};

3.报告描述符的report id这两个位置要一致

 这里实现的是单点,多点目前还在研究

int key_event(void)
{
#if 1
	u8 arr[] = {0x41,0x0a,0x0a,0x0a,0x0a};
#else
	u8 arr[] = {
		0x40, 0x10, 0x24, 0x10, 0x24,
		0x41, 0x0a, 0x0a, 0x0a, 0x0a,
		//0, 0, 0, 0, 0,
		0, 0, 0, 0, 0,
		0, 0, 0, 0, 0,
		0, 0, 0, 0, 0,
		0, 0, 0, 0, 0,
		0, 0, 0, 0, 0,
		2
		};
#endif

	if(key(KEY2) == 2)
	{
		static u8 count = 0;
		count++;
		if(count < 5)return 0;
		count = 0;
		LOG_INFO("key2 press\r\n");

		LOG_INFO("ble state = %d\r\n",bls_att_pushNotifyData (HID_MOUSE_REPORT_INPUT_DP_H, arr, sizeof(arr)));

	}
	if(key(KEY3) == 1)
	{
		u8 arr1[] = {0x41,0x3a,0x0a,0x3a,0x0a};
		LOG_INFO("key3 press\r\n");
		u8 arr[] = {0x41,0x0a,0x0a,0x0a,0x2a};
		LOG_INFO("ble state = %d\r\n",bls_att_pushNotifyData (HID_MOUSE_REPORT_INPUT_DP_H, arr1, sizeof(arr)));
	}
	if(key(KEY4) == 1)
	{
		u8 arr2[] = {0x41,0x2a,0x0a,0x2a,0x1a};
		LOG_INFO("key4 press\r\n");
		LOG_INFO("ble state = %d\r\n",bls_att_pushNotifyData (HID_MOUSE_REPORT_INPUT_DP_H, arr2, sizeof(arr)));
	}
#if 1
	if(key(KEY5) == 1)
	{
		u8 arr3[] = {0x41,0x1a,0x1a,0x1a,0x0a};
		LOG_INFO("key5 press\r\n");
		LOG_INFO("ble state = %d\r\n",bls_att_pushNotifyData (HID_MOUSE_REPORT_INPUT_DP_H, arr3, sizeof(arr)));
	}
#endif
	return 0;
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

入门->放弃

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值