From 51566d1a811f43dc39f38cb597de44ba9363d974 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 20 Sep 2009 12:01:25 +0000 Subject: 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. --- Demos/Device/ClassDriver/GenericHID/Descriptors.c | 2 +- Demos/Device/ClassDriver/Joystick/Descriptors.c | 2 +- Demos/Device/ClassDriver/Keyboard/Descriptors.c | 2 +- .../Device/ClassDriver/KeyboardMouse/Descriptors.c | 4 +-- Demos/Device/ClassDriver/Mouse/Descriptors.c | 2 +- Demos/Host/ClassDriver/MouseHost/MouseHost.c | 35 ++++++++++++++++++++-- Demos/Host/ClassDriver/MouseHost/makefile | 1 + 7 files changed, 40 insertions(+), 8 deletions(-) (limited to 'Demos') diff --git a/Demos/Device/ClassDriver/GenericHID/Descriptors.c b/Demos/Device/ClassDriver/GenericHID/Descriptors.c index a2bea6dd7..e937973fa 100644 --- a/Demos/Device/ClassDriver/GenericHID/Descriptors.c +++ b/Demos/Device/ClassDriver/GenericHID/Descriptors.c @@ -123,7 +123,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .Class = 0x03, .SubClass = 0x00, - .Protocol = 0x00, + .Protocol = HID_NON_BOOT_PROTOCOL, .InterfaceStrIndex = NO_DESCRIPTOR }, diff --git a/Demos/Device/ClassDriver/Joystick/Descriptors.c b/Demos/Device/ClassDriver/Joystick/Descriptors.c index 74ab7d969..8f4177e07 100644 --- a/Demos/Device/ClassDriver/Joystick/Descriptors.c +++ b/Demos/Device/ClassDriver/Joystick/Descriptors.c @@ -133,7 +133,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .Class = 0x03, .SubClass = 0x00, - .Protocol = 0x00, + .Protocol = HID_NON_BOOT_PROTOCOL, .InterfaceStrIndex = NO_DESCRIPTOR }, diff --git a/Demos/Device/ClassDriver/Keyboard/Descriptors.c b/Demos/Device/ClassDriver/Keyboard/Descriptors.c index adc62103e..12d896264 100644 --- a/Demos/Device/ClassDriver/Keyboard/Descriptors.c +++ b/Demos/Device/ClassDriver/Keyboard/Descriptors.c @@ -140,7 +140,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .Class = 0x03, .SubClass = 0x01, - .Protocol = 0x01, + .Protocol = HID_BOOT_KEYBOARD_PROTOCOL, .InterfaceStrIndex = NO_DESCRIPTOR }, diff --git a/Demos/Device/ClassDriver/KeyboardMouse/Descriptors.c b/Demos/Device/ClassDriver/KeyboardMouse/Descriptors.c index 114d86357..520d57d8a 100644 --- a/Demos/Device/ClassDriver/KeyboardMouse/Descriptors.c +++ b/Demos/Device/ClassDriver/KeyboardMouse/Descriptors.c @@ -173,7 +173,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .Class = 0x03, .SubClass = 0x01, - .Protocol = 0x01, + .Protocol = HID_BOOT_KEYBOARD_PROTOCOL, .InterfaceStrIndex = NO_DESCRIPTOR }, @@ -210,7 +210,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .Class = 0x03, .SubClass = 0x01, - .Protocol = 0x02, + .Protocol = HID_BOOT_MOUSE_PROTOCOL, .InterfaceStrIndex = NO_DESCRIPTOR }, diff --git a/Demos/Device/ClassDriver/Mouse/Descriptors.c b/Demos/Device/ClassDriver/Mouse/Descriptors.c index 7161da134..f6d6e8944 100644 --- a/Demos/Device/ClassDriver/Mouse/Descriptors.c +++ b/Demos/Device/ClassDriver/Mouse/Descriptors.c @@ -133,7 +133,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .Class = 0x03, .SubClass = 0x01, - .Protocol = 0x02, + .Protocol = HID_BOOT_MOUSE_PROTOCOL, .InterfaceStrIndex = NO_DESCRIPTOR }, 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.) -- cgit v1.2.3