forked from bsiever/microbit-pxt-blehid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMediaReporter.cpp
55 lines (48 loc) · 1.67 KB
/
MediaReporter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "MicroBitConfig.h"
#if CONFIG_ENABLED(DEVICE_BLE)
#include "MediaReporter.h"
#include "debug.h"
// From: https://notes.iopush.net/blog/2016/custom-usb-hid-device-descriptor-media-keyboard/
static const uint8_t mediaReportMap[] =
{
0x05, 0x0C, // Usage Page (Consumer)
0x09, 0x01, // Usage (Consumer Control)
0xA1, 0x01, // Collection (Application)
0x85, 0x00, // Report ID Offset 7
0x05, 0x0C, // Usage Page (Consumer)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x75, 0x01, // Report Size (1)
0x95, 0x08, // Report Count (7)
0x09, 0xB5, // Usage (Scan Next Track)
0x09, 0xB6, // Usage (Scan Previous Track)
0x09, 0xB7, // Usage (Stop)
0x09, 0xB8, // Usage (Eject)
0x09, 0xCD, // Usage (Play/Pause)
0x09, 0xE2, // Usage (Mute)
0x09, 0xE9, // Usage (Volume Increment)
0x09, 0xEA, // Usage (Volume Decrement)
0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0xC0, // End Collection
};
MediaReporter *MediaReporter::reporter = NULL; // Singleton reference to the service
/**
*/
MediaReporter *MediaReporter::getInstance()
{
if (reporter == NULL)
{
reporter = new MediaReporter();
}
return reporter;
}
MediaReporter::MediaReporter() :
HIDReporter("Media", 1, mediaReportMap, sizeof(mediaReportMap), 7, 108) // Name and report size
{
}
void MediaReporter::sendCode(uint8_t code) {
memset(report, 0, reportSize);
report[0] = code;
sendReport();
}
#endif