From c2de01b66186f8f195b6d19c311a67d1aede6d57 Mon Sep 17 00:00:00 2001
From: Dean Camera <dean@fourwalledcubicle.com>
Date: Wed, 24 Mar 2010 05:58:20 +0000
Subject: [PATCH] Fixed incorrect definition of HID_ALIGN_DATA() causing
 incorrect HID report item data alignment.

---
 LUFA/Drivers/USB/Class/Host/HIDParser.h | 2 +-
 LUFA/ManPages/ChangeLog.txt             | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/LUFA/Drivers/USB/Class/Host/HIDParser.h b/LUFA/Drivers/USB/Class/Host/HIDParser.h
index b96989393..6b6549b51 100644
--- a/LUFA/Drivers/USB/Class/Host/HIDParser.h
+++ b/LUFA/Drivers/USB/Class/Host/HIDParser.h
@@ -137,7 +137,7 @@
 		 *
 		 *  \return Left-aligned data of the given report item's pre-retrived value for the given datatype
 		 */
-		#define HID_ALIGN_DATA(reportitem, type) ((type)(reportitem->Value << (sizeof(type) - reportitem->Attributes.BitSize)))
+		#define HID_ALIGN_DATA(reportitem, type) ((type)(reportitem->Value << ((8 * sizeof(type)) - reportitem->Attributes.BitSize)))
 
 	/* Public Interface - May be used in end-application: */
 		/* Enums: */			
diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt
index 520ef2feb..ecb83bbd3 100644
--- a/LUFA/ManPages/ChangeLog.txt
+++ b/LUFA/ManPages/ChangeLog.txt
@@ -31,6 +31,7 @@
   *    U4 series USB AVR parts
   *  - Fixed LowLevel MassStorage demo broken on the U2 AVRs due to double-banked endpoints
   *  - Fixed compilation error in the AudioInput demos when MICROPHONE_BIASED_TO_HALF_RAIL is defined (thanks to C. Scott Ananian)
+  *  - Fixed incorrect definition of HID_ALIGN_DATA() causing incorrect HID report item data alignment
   *
   *  \section Sec_ChangeLog100219 Version 100219
   *
-- 
GitLab