#include <HID.h>
static const uint8_t _hidReportDescriptor[] PROGMEM = {
0x05, 0x0c, // USAGE_PAGE (Consumer Page)
0x09, 0x01, // USAGE (Consumer Control)
0xa1, 0x01, // COLLECTION (Application)
0x85, 0x05, // REPORT_ID (5)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x09, 0xea, // USAGE (Volume Decrement)
0x09, 0xe9, // USAGE (Volume Increment)
0x09, 0xe2, // USAGE (Mute)
0x09, 0xcd, // USAGE (Play/Pause)
0x0a, 0x83, 0x01, //USAGE (Windows Media Player(0x183))
0x0a, 0x23, 0x02, //USAGE (AC Home(0x0223))
0x0a, 0x92, 0x01, //USAGE (AL Calculator(0x192))
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x95, 0x07, // REPORT_COUNT (7)
0x75, 0x01, // REPORT_SIZE (1)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
0xc0 // END_COLLECTION
};
//八位数据 每位的功能为
// 0 Volume Decrement
// 1 Volume Increment
// 3 Mute
// 4 Play/Pause
// 5 Windows Media Player(0x183)
// 6 AC Home(0x0223)
// 7 AL Calculator(0x192)
// 8
uint8_t report[1];
void setup()
{
// put your setup code here, to run once:
static HIDSubDescriptor node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
HID().AppendDescriptor(&node);
pinMode(4, INPUT);
Serial.begin(9600);
report[0] = 0x01;
}
void loop()
{
report[0] = 0x01;
HID().SendReport(5,report,1);//(data,len)
delay(100);
}