aboutsummaryrefslogtreecommitdiff
path: root/libraries/HID/HID.h
diff options
context:
space:
mode:
authorMartino Facchin <m.facchin@arduino.cc>2015-07-02 12:12:15 +0200
committerCristian Maglie <c.maglie@arduino.cc>2015-07-16 13:13:52 +0200
commit3d61f6e37ef3084627cdeb2b81e1545fe7ef0271 (patch)
tree43aff6c389d61efe48e4104d9e6890d06b766024 /libraries/HID/HID.h
parentb0bdb476942ea105463fd8fdbc076d2b104a7176 (diff)
allow HID submodules to create runtime descriptors
with this PR you can add \#include Keyboard.h \#include Mouse.h \#include HID.h in the top of the sketch and you will expose a Mouse+Keyboard From the library pow, simply add static HID_Descriptor cb = { .length = sizeof(_hidReportDescriptor), .descriptor = _hidReportDescriptor, }; static HIDDescriptorListNode node(&cb); HID.AppendDescriptor(&node); in the class' constructor and you are done!
Diffstat (limited to 'libraries/HID/HID.h')
-rw-r--r--libraries/HID/HID.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/libraries/HID/HID.h b/libraries/HID/HID.h
index d3a9982..c7608eb 100644
--- a/libraries/HID/HID.h
+++ b/libraries/HID/HID.h
@@ -42,16 +42,27 @@
#define HID_REPORT_DESCRIPTOR_TYPE 0x22
#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23
+typedef struct __attribute__((packed)) {
+ u8 length;
+ const void* descriptor;
+} HID_Descriptor;
+
+class HIDDescriptorListNode {
+public:
+ HIDDescriptorListNode *next = NULL;
+ const HID_Descriptor * cb;
+ HIDDescriptorListNode(const HID_Descriptor *ncb) {cb = ncb;}
+};
+
class HID_
{
public:
HID_(void);
int begin(void);
void SendReport(uint8_t id, const void* data, int len);
+ void AppendDescriptor(HIDDescriptorListNode* node);
};
-extern HID_ HID;
-
typedef struct
{
u8 len; // 9
@@ -77,11 +88,6 @@ typedef struct
#define D_HIDREPORT(_descriptorLength) \
{ 9, 0x21, 0x1, 0x1, 0, 1, 0x22, _descriptorLength, 0 }
-extern const u8 _hidReportDescriptor[] PROGMEM;
-
-// MUST be declared by the module
-size_t getsizeof_hidReportDescriptor();
-
#define WEAK __attribute__ ((weak))
#endif