1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-20 14:54:31 +01:00

Merge branch 'pluggable_hid_impr' of https://github.com/cmaglie/Arduino

This commit is contained in:
Cristian Maglie 2015-09-28 12:06:35 +02:00
commit e4d63adf45
6 changed files with 15 additions and 30 deletions

View File

@ -61,7 +61,7 @@ int HID_GetDescriptor(int8_t t)
HIDDescriptorListNode* current = rootNode;
int total = 0;
while(current != NULL) {
total += USB_SendControl(TRANSFER_PGM,current->cb->descriptor,current->cb->length);
total += USB_SendControl(TRANSFER_PGM,current->data,current->length);
current = current->next;
}
return total;
@ -82,7 +82,7 @@ void HID_::AppendDescriptor(HIDDescriptorListNode *node)
current->next = node;
}
modules_count++;
sizeof_hidReportDescriptor += (uint16_t)node->cb->length;
sizeof_hidReportDescriptor += (uint16_t)node->length;
}
void HID_::SendReport(u8 id, const void* data, int len)

View File

@ -44,16 +44,13 @@
#define HID_REPORT_DESCRIPTOR_TYPE 0x22
#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23
typedef struct __attribute__((packed)) {
uint16_t length;
const void* descriptor;
} HID_Descriptor;
class HIDDescriptorListNode {
public:
HIDDescriptorListNode *next = NULL;
const HID_Descriptor * cb;
HIDDescriptorListNode(const HID_Descriptor *ncb) {cb = ncb;}
HIDDescriptorListNode(const void *d, uint16_t l) : data(d), length(l) { }
const void* data;
uint16_t length;
};
class HID_

View File

@ -68,7 +68,7 @@ int HID_GetDescriptor(int8_t t)
HIDDescriptorListNode* current = rootNode;
int total = 0;
while(current != NULL) {
total += USBD_SendControl(0,current->cb->descriptor,current->cb->length);
total += USBD_SendControl(0,current->data,current->length);
current = current->next;
}
return total;
@ -89,7 +89,7 @@ void HID_::AppendDescriptor(HIDDescriptorListNode *node)
current->next = node;
}
modules_count++;
sizeof_hidReportDescriptor += node->cb->length;
sizeof_hidReportDescriptor += node->length;
}
void HID_::SendReport(uint8_t id, const void* data, int len)
@ -165,4 +165,4 @@ HID_::HID_(void)
int HID_::begin(void)
{
return 0;
}
}

View File

@ -42,16 +42,12 @@
#define HID_REPORT_DESCRIPTOR_TYPE 0x22
#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23
typedef struct __attribute__((packed)) {
uint8_t length;
const void* descriptor;
} HID_Descriptor;
class HIDDescriptorListNode {
public:
HIDDescriptorListNode *next = NULL;
const HID_Descriptor * cb;
HIDDescriptorListNode(const HID_Descriptor *ncb) {cb = ncb;}
HIDDescriptorListNode(const void *d, uint16_t l) : data(d), length(l) { }
uint8_t length;
const void* data;
};
class HID_
@ -90,4 +86,4 @@ typedef struct
#define WEAK __attribute__ ((weak))
#endif
#endif

View File

@ -62,11 +62,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
Keyboard_::Keyboard_(void)
{
static HID_Descriptor cb = {
.length = sizeof(_hidReportDescriptor),
.descriptor = _hidReportDescriptor,
};
static HIDDescriptorListNode node(&cb);
static HIDDescriptorListNode node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
HID.AppendDescriptor(&node);
}

View File

@ -62,11 +62,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
Mouse_::Mouse_(void) : _buttons(0)
{
const static HID_Descriptor cb = {
.length = sizeof(_hidReportDescriptor),
.descriptor = _hidReportDescriptor,
};
static HIDDescriptorListNode node(&cb);
static HIDDescriptorListNode node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
HID.AppendDescriptor(&node);
}