lhchen922 发表于 2013-10-30 14:12
本人参考圈圈兄的书,复合了鼠标,键盘,和触摸屏,目前基本功能OK,,,还有点小小问题在修复。 ...
***********************键盘
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x06, // USAGE (Keyboard)
0xa1, 0x01, // COLLECTION (Application)
0x85,0x01,
0x05, 0x07, // USAGE_PAGE (Keyboard/Keypad)
0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x95, 0x08, // REPORT_COUNT (8)
0x75, 0x01, // REPORT_SIZE (1)
0x81, 0x02, // INPUT (Data,Var,Abs)
//-------------------------输入第一字节
0x95, 0x01, // REPORT_COUNT (1)
0x75,0x08, //REPORT_SIZE(8)
0x81,0x03, //INPUT(CnstVarAbs)
//----------------------------输入第二字节
0x95,0x06,
0x75,0x08,
0x15,0x00,
0x25,0xff,
0x05,0x07,
0x19,0x00,
0x29,0x65,
0x81,0x00,
//---------------------------------输入第3到第8字节
0x95,0x05,
0x75,0x01,
0x05,0x08,
0x19,0x01,
0x29,0x05,
0x91,0x02,//OUT PUT
0x95,0x01,
0x75,0x03,
0x91,0x03,//output
//---------------------------输出第一字节
0xc0
/************************USB鼠标部分报告描述符**********************/
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x02, // USAGE (Mouse)
0xa1, 0x01, // COLLECTION (Application)
0x85, 0x02, //Report ID (2)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x03, // USAGE_MAXIMUM (Button 3)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x95, 0x03, // REPORT_COUNT (3)
0x75, 0x01, // REPORT_SIZE (1)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x05, // REPORT_SIZE (5)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x09, 0x38, // USAGE (Wheel)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x03, // REPORT_COUNT (3)
0x81, 0x06, // INPUT (Data,Var,Rel)
0xc0, // END_COLLECTION
0xc0 // END_COLLECTION
上面是键盘和鼠标的 descriptor 下面是给电脑发送键盘的传送数据 但是这样就是不行 鼠标键盘分开就可以
void Joystick_Send(u8 Keys)//键盘发送
{
u8 Buffer_Scan1[8] = {0, 0, 0, 0, 0, 0, 0, 0};
Buffer_Scan1[3]=Keys;
USB_SIL_Write(EP1_IN, Buffer_Scan1, 8);
SetEPTxValid(ENDP1);
}
/*******************************************************************************/
void Joystick_Send2(u8 buf0,u8 buf1,u8 buf2,u8 buf3) //鼠标发送
{
u8 Mouse_Buffer[4] = {0, 0, 0, 0};
Mouse_Buffer[0]=buf0;
Mouse_Buffer[1]=buf1;
Mouse_Buffer[2]=buf2;
Mouse_Buffer[3]=buf3;
UserToPMABufferCopy(Mouse_Buffer, GetEPTxAddr(ENDP2), 4);
SetEPTxValid(ENDP2);
}
麻烦你帮我看下 是不是那里搞错了唉~!菜鸟一个
|