Added new Pipe_IsFrozen() macro to determine if the currently selected pipe is frozen.
[pub/lufa.git] / Demos / Host / ClassDriver / MouseHost / MouseHost.c
index b80a91c..ead2961 100644 (file)
@@ -47,7 +47,7 @@ USB_ClassInfo_HID_Host_t Mouse_HID_Interface =
                                .DataINPipeNumber       = 1,\r
                                .DataOUTPipeNumber      = 2,\r
                                \r
-                               .HIDInterfaceProtocol   = 0x02,\r
+                               .HIDInterfaceProtocol   = HID_BOOT_MOUSE_PROTOCOL,\r
                        },\r
        };\r
 \r
@@ -110,7 +110,38 @@ int main(void)
                                printf("Mouse Enumerated.\r\n");\r
                                USB_HostState = HOST_STATE_Configured;\r
                                break;\r
-                       case HOST_STATE_Configured:                     \r
+                       case HOST_STATE_Configured:\r
+                               if (HID_Host_IsReportReceived(&Mouse_HID_Interface))\r
+                               {\r
+                                       USB_MouseReport_Data_t MouseReport;\r
+                                       uint8_t ReportID = 0;\r
+                                       uint8_t LEDMask = LEDS_NO_LEDS;\r
+                               \r
+                                       HID_Host_ReceiveReport(&Mouse_HID_Interface, false, &ReportID, &MouseReport);\r
+                                       \r
+                                       /* Alter status LEDs according to mouse X movement */\r
+                                       if (MouseReport.X > 0)\r
+                                         LEDMask |= LEDS_LED1;\r
+                                       else if (MouseReport.X < 0)\r
+                                         LEDMask |= LEDS_LED2;\r
+                                               \r
+                                       /* Alter status LEDs according to mouse Y movement */\r
+                                       if (MouseReport.Y > 0)\r
+                                         LEDMask |= LEDS_LED3;\r
+                                       else if (MouseReport.Y < 0)\r
+                                         LEDMask |= LEDS_LED4;\r
+\r
+                                       /* Alter status LEDs according to mouse button position */\r
+                                       if (MouseReport.Button)\r
+                                         LEDMask  = LEDS_ALL_LEDS;\r
+                                       \r
+                                       LEDs_SetAllLEDs(LEDMask);\r
+                               }\r
+                               else\r
+                               {\r
+                                       LEDs_SetAllLEDs(LEDS_NO_LEDS);\r
+                               }\r
+                               \r
                                break;\r
                }\r
        \r