mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Merge pull request #647 from tmk/upstream_fix_hidboot_buff
hidboot: Fix buffer size and check maxPacketSize #646
This commit is contained in:
commit
395fca4aac
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.
|
// To-do: optimize manually, using the for loop only if needed.
|
||||||
for(int i = 0; i < epMUL(BOOT_PROTOCOL); i++) {
|
for(int i = 0; i < epMUL(BOOT_PROTOCOL); i++) {
|
||||||
const uint16_t const_buff_len = 16;
|
const uint16_t const_buff_len = 64;
|
||||||
uint8_t buf[const_buff_len];
|
|
||||||
|
|
||||||
USBTRACE3("(hidboot.h) i=", i, 0x81);
|
USBTRACE3("(hidboot.h) i=", i, 0x81);
|
||||||
USBTRACE3("(hidboot.h) epInfo[epInterruptInIndex + i].epAddr=", epInfo[epInterruptInIndex + i].epAddr, 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);
|
USBTRACE3("(hidboot.h) epInfo[epInterruptInIndex + i].maxPktSize=", epInfo[epInterruptInIndex + i].maxPktSize, 0x81);
|
||||||
uint16_t read = (uint16_t)epInfo[epInterruptInIndex + i].maxPktSize;
|
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);
|
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.
|
// 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.
|
// Since keyboard and mice must report at least 3 bytes, we ignore the extra data.
|
||||||
|
|
Loading…
Reference in a new issue