I'm making a board with an atmega32u4 on it for the controller for a keyboard, and am having issues with telling the host computer that a key is pressed. I've modified the Keyboard demo supplied with the LUFA library, so that in theory I believe it should send the 'a' key constantly. Here's the relevant code from the source file:
int main(void)
{
_delay_ms(100);
SetupHardware();
GlobalInterruptEnable();
for (;;)
{
HID_Device_USBTask(&Keyboard_HID_Interface);
USB_USBTask();
}
}
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
uint8_t* const ReportID,
const uint8_t ReportType,
void* ReportData,
uint16_t* const ReportSize)
{
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;
uint8_t UsedKeyCodes = 0;
KeyboardReport->KeyCode[UsedKeyCodes++] = HID_KEYBOARD_SC_A;
*ReportSize = sizeof(USB_KeyboardReport_Data_t);
return true;
}
When I flash this code onto my board and plug it in to my computer, I get nothing (except, interestingly, the num lock led on my actual keyboard turns off and back on, no idea why). So, I decided to use wireshark to determine if anything at all is being sent between the computer and the microcontroller, and in fact a lot of messages are.
USB address 3.72.1, in this case, is referring to my microcontroller board, which I confirmed with the lsusb
command. I was surprised to see that the 'a' key is in fact being continuously sent to the host, and even more confused as to why the computer isn't registering that these keys are pressed. I've tried a few different things, such as returning true or false from the CreateHIDReport function, and using some logic to only send an 'a' key report every other call to CreateHIDReport, but none of these ideas helped.
Any idea how the computer can be picking up on these key reports, but not registering them as actual key presses?