diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-09-20 12:01:25 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-09-20 12:01:25 +0000 |
commit | 51566d1a811f43dc39f38cb597de44ba9363d974 (patch) | |
tree | 9dc1b20907accffd98fecec2f0e034331fa41b2d /Demos/Host | |
parent | cd0adb7574525978f50eabd536f7563f2d9f9aa7 (diff) | |
download | lufa-51566d1a811f43dc39f38cb597de44ba9363d974.tar.gz lufa-51566d1a811f43dc39f38cb597de44ba9363d974.tar.bz2 lufa-51566d1a811f43dc39f38cb597de44ba9363d974.zip |
Added new Pipe_IsFrozen() macro to determine if the currently selected pipe is frozen.
Added new USB_GetHIDReportSize() function to the HID report parser to retrieve the size of a given report by its ID.
More additions to the unfinished HID Host Class Driver.
Diffstat (limited to 'Demos/Host')
-rw-r--r-- | Demos/Host/ClassDriver/MouseHost/MouseHost.c | 35 | ||||
-rw-r--r-- | Demos/Host/ClassDriver/MouseHost/makefile | 1 |
2 files changed, 34 insertions, 2 deletions
diff --git a/Demos/Host/ClassDriver/MouseHost/MouseHost.c b/Demos/Host/ClassDriver/MouseHost/MouseHost.c index b80a91c26..ead296102 100644 --- a/Demos/Host/ClassDriver/MouseHost/MouseHost.c +++ b/Demos/Host/ClassDriver/MouseHost/MouseHost.c @@ -47,7 +47,7 @@ USB_ClassInfo_HID_Host_t Mouse_HID_Interface = .DataINPipeNumber = 1,
.DataOUTPipeNumber = 2,
- .HIDInterfaceProtocol = 0x02,
+ .HIDInterfaceProtocol = HID_BOOT_MOUSE_PROTOCOL,
},
};
@@ -110,7 +110,38 @@ 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))
+ {
+ USB_MouseReport_Data_t MouseReport;
+ uint8_t ReportID = 0;
+ uint8_t LEDMask = LEDS_NO_LEDS;
+
+ HID_Host_ReceiveReport(&Mouse_HID_Interface, false, &ReportID, &MouseReport);
+
+ /* Alter status LEDs according to mouse X movement */
+ if (MouseReport.X > 0)
+ LEDMask |= LEDS_LED1;
+ else if (MouseReport.X < 0)
+ LEDMask |= LEDS_LED2;
+
+ /* Alter status LEDs according to mouse Y movement */
+ if (MouseReport.Y > 0)
+ LEDMask |= LEDS_LED3;
+ else if (MouseReport.Y < 0)
+ LEDMask |= LEDS_LED4;
+
+ /* Alter status LEDs according to mouse button position */
+ if (MouseReport.Button)
+ LEDMask = LEDS_ALL_LEDS;
+
+ LEDs_SetAllLEDs(LEDMask);
+ }
+ else
+ {
+ LEDs_SetAllLEDs(LEDS_NO_LEDS);
+ }
+
break;
}
diff --git a/Demos/Host/ClassDriver/MouseHost/makefile b/Demos/Host/ClassDriver/MouseHost/makefile index 5d1d95319..f0df3cc35 100644 --- a/Demos/Host/ClassDriver/MouseHost/makefile +++ b/Demos/Host/ClassDriver/MouseHost/makefile @@ -136,6 +136,7 @@ SRC = $(TARGET).c \ $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c \
$(LUFA_PATH)/LUFA/Drivers/USB/Class/Device/HID.c \
$(LUFA_PATH)/LUFA/Drivers/USB/Class/Host/HID.c \
+ $(LUFA_PATH)/LUFA/Drivers/USB/Class/Host/HIDParser.c \
# List C++ source files here. (C dependencies are automatically generated.)
|