mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Fix buffer size and check maxPacketSize #646
This commit is contained in:
parent
b6511306f1
commit
d3e306f5f9
1 changed files with 6 additions and 2 deletions
|
@ -582,14 +582,18 @@ uint8_t HIDBoot<BOOT_PROTOCOL>::Poll() {
|
|||
|
||||
// To-do: optimize manually, using the for loop only if needed.
|
||||
for(int i = 0; i < epMUL(BOOT_PROTOCOL); i++) {
|
||||
const uint16_t const_buff_len = 16;
|
||||
uint8_t buf[const_buff_len];
|
||||
const uint16_t const_buff_len = 64;
|
||||
|
||||
USBTRACE3("(hidboot.h) i=", i, 0x81);
|
||||
USBTRACE3("(hidboot.h) epInfo[epInterruptInIndex + i].epAddr=", epInfo[epInterruptInIndex + i].epAddr, 0x81);
|
||||
USBTRACE3("(hidboot.h) epInfo[epInterruptInIndex + i].maxPktSize=", epInfo[epInterruptInIndex + i].maxPktSize, 0x81);
|
||||
uint16_t read = (uint16_t)epInfo[epInterruptInIndex + i].maxPktSize;
|
||||
|
||||
if (read > const_buff_len)
|
||||
read = const_buff_len;
|
||||
|
||||
uint8_t buf[read];
|
||||
|
||||
rcode = pUsb->inTransfer(bAddress, epInfo[epInterruptInIndex + i].epAddr, &read, buf);
|
||||
// SOME buggy dongles report extra keys (like sleep) using a 2 byte packet on the wrong endpoint.
|
||||
// Since keyboard and mice must report at least 3 bytes, we ignore the extra data.
|
||||
|
|
Loading…
Reference in a new issue