X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/cd0adb7574525978f50eabd536f7563f2d9f9aa7..cf610c5c91c3eee02dec7ca848acc8da831ad98a:/Demos/Host/ClassDriver/MouseHost/MouseHost.c diff --git a/Demos/Host/ClassDriver/MouseHost/MouseHost.c b/Demos/Host/ClassDriver/MouseHost/MouseHost.c index b80a91c26..fbf35c0d6 100644 --- a/Demos/Host/ClassDriver/MouseHost/MouseHost.c +++ b/Demos/Host/ClassDriver/MouseHost/MouseHost.c @@ -47,13 +47,13 @@ USB_ClassInfo_HID_Host_t Mouse_HID_Interface = .DataINPipeNumber = 1, .DataOUTPipeNumber = 2, - .HIDInterfaceProtocol = 0x02, + .HIDInterfaceProtocol = HID_BOOT_MOUSE_PROTOCOL, }, }; /** Main program entry point. This routine configures the hardware required by the application, then - * starts the scheduler to run the application tasks. + * enters a loop to run the application tasks in sequence. */ int main(void) { @@ -99,7 +99,7 @@ int main(void) break; } - if (USB_HID_Host_SetBootProtocol(&Mouse_HID_Interface) != 0) + if (HID_Host_SetBootProtocol(&Mouse_HID_Interface) != 0) { printf("Could not Set Boot Protocol Mode.\r\n"); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -110,7 +110,33 @@ int main(void) printf("Mouse Enumerated.\r\n"); USB_HostState = HOST_STATE_Configured; break; - case HOST_STATE_Configured: + case HOST_STATE_Configured: + if (HID_Host_IsReportReceived(&Mouse_HID_Interface)) + { + uint8_t LEDMask = LEDS_NO_LEDS; + + USB_MouseReport_Data_t MouseReport; + HID_Host_ReceiveReport(&Mouse_HID_Interface, &MouseReport); + + printf_P(PSTR("dX:%2d dY:%2d Button:%d\r\n"), MouseReport.X, + MouseReport.Y, + MouseReport.Button); + if (MouseReport.X > 0) + LEDMask |= LEDS_LED1; + else if (MouseReport.X < 0) + LEDMask |= LEDS_LED2; + + if (MouseReport.Y > 0) + LEDMask |= LEDS_LED3; + else if (MouseReport.Y < 0) + LEDMask |= LEDS_LED4; + + if (MouseReport.Button) + LEDMask = LEDS_ALL_LEDS; + + LEDs_SetAllLEDs(LEDMask); + } + break; }