From cf610c5c91c3eee02dec7ca848acc8da831ad98a Mon Sep 17 00:00:00 2001
From: Dean Camera <dean@fourwalledcubicle.com>
Date: Mon, 26 Oct 2009 05:27:59 +0000
Subject: [PATCH] Make HID device class driver reselect the correct endpoint
 after the user callbacks have fired.

---
 LUFA/Drivers/USB/Class/Device/HID.c | 3 +++
 LUFA/ManPages/ChangeLog.txt         | 1 +
 LUFA/ManPages/FutureChanges.txt     | 1 -
 LUFA/ManPages/LibraryResources.txt  | 1 +
 LUFA/makefile                       | 2 +-
 5 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/LUFA/Drivers/USB/Class/Device/HID.c b/LUFA/Drivers/USB/Class/Device/HID.c
index a99c2647c..403d494dc 100644
--- a/LUFA/Drivers/USB/Class/Device/HID.c
+++ b/LUFA/Drivers/USB/Class/Device/HID.c
@@ -56,6 +56,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter
 				CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID,
 				                                    HIDInterfaceInfo->Config.PrevReportINBuffer, &ReportINSize);
 
+				Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
 				Endpoint_Write_Control_Stream_LE(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize);
 				Endpoint_ClearOUT();
 			}
@@ -167,6 +168,8 @@ void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)
 		{
 			HIDInterfaceInfo->State.IdleMSRemaining = HIDInterfaceInfo->State.IdleCount;
 
+			Endpoint_SelectEndpoint(HIDInterfaceInfo->Config.ReportINEndpointNumber);
+
 			if (ReportID)
 			  Endpoint_Write_Byte(ReportID);
 
diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt
index fd70eb09c..7b50da95e 100644
--- a/LUFA/ManPages/ChangeLog.txt
+++ b/LUFA/ManPages/ChangeLog.txt
@@ -34,6 +34,7 @@
   *  - Fixed ClassDriver AudioOutput device demo not selecting an audio output mode
   *  - Fixed incorrect SampleFrequencyType value in the AudioInput and AudioOutput ClassDriver demos' descriptors
   *  - Fixed incorrect event name rule in demo/project/bootloader makefiles
+  *  - Fixed HID device class driver not reselecting the correct endpoint once the user callback routines have been called
   *
   *  \section Sec_ChangeLog090924 Version 090924
   *
diff --git a/LUFA/ManPages/FutureChanges.txt b/LUFA/ManPages/FutureChanges.txt
index ea93258ba..f1f2a8c7e 100644
--- a/LUFA/ManPages/FutureChanges.txt
+++ b/LUFA/ManPages/FutureChanges.txt
@@ -21,7 +21,6 @@
   *  - Add detailed overviews of how each demo works
   *  - Master LUFA include file rather than per-module includes
   *  - Change makefiles to allow for absolute LUFA location to be used
-  *  - Abstract out the physical media from the Mass Storage device demos
   *  - Add RNDIS Host Class driver
   *  - Add unit testing to APIs
   *  - Make new demos
diff --git a/LUFA/ManPages/LibraryResources.txt b/LUFA/ManPages/LibraryResources.txt
index a1005d401..759a8c0ef 100644
--- a/LUFA/ManPages/LibraryResources.txt
+++ b/LUFA/ManPages/LibraryResources.txt
@@ -11,6 +11,7 @@
  *  Development Blog: http://www.fourwalledcubicle.com/blog \n
  *  Discussion Group: http://groups.google.com/group/myusb-support-list \n
  *  SVN Access, Bug Reports and Feature Requests: http://code.google.com/p/lufa-lib/ \n
+ *  Git Access: http://github.com/abcminiuser/lufa-lib
  *  Author's Website: http://www.fourwalledcubicle.com \n
  *
  *  WinAVR Website: http://winavr.sourceforge.net \n
diff --git a/LUFA/makefile b/LUFA/makefile
index 4e9b8ca19..c668399d4 100644
--- a/LUFA/makefile
+++ b/LUFA/makefile
@@ -38,7 +38,7 @@ LUFA_Events.lst:
 	@echo Generating LUFA event name list...
 	@$(shell) cat `find ./ -name "*.h"` | grep -E "EVENT_[^\(]*\(" | \
 	              sed -n -e 's/^.*EVENT_/EVENT_/p' | \
-	              cut -d'(' -f1 | sort | uniq > LUFA_Events.lst
+	              cut -d'(' -f1 | sort | uniq | tee LUFA_Events.lst
 				  
 all: LUFA_Events.lst
 
-- 
GitLab