我创建的设备可以将USB HID报告从设备发送到计算机。
if(toggled == 0x01){ // if in toggled state
if(currentMillis - previousMillis >= 40 && pending == 0x00){ // if 40 ms has passed since last key up hid report
USBD_HID_SendReport(&hUsbDeviceFS, &report, sizeof(report)); //send report
pending = 0x01;
}
if(currentMillis - previousMillis >= 70 && pending == 0x01 ){ // if 70 ms has passed since last key down hid report and key down report was sent
previousMillis = currentMillis; // reset timer
USBD_HID_SendReport(&hUsbDeviceFS, &testReportInactive, sizeof(report));
pending = 0x00;
}
}
这是将HID报告发送到计算机的代码。
在Windows 10 x64上,当更改切换状态时,计算机有时会认为该键仍然被按下并将重复打印该键的字符。在macOS上,它可以正常工作,并且计算机不认为该键仍然被按下。关于如何在Windows上解决此问题的任何想法?