projects
/
pub
/
USBasp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove USB_MODE_* macros, replace with a semantically linked USB_Modes_t enum.
[pub/USBasp.git]
/
LUFA
/
Drivers
/
USB
/
Class
/
Host
/
HIDParser.c
diff --git
a/LUFA/Drivers/USB/Class/Host/HIDParser.c
b/LUFA/Drivers/USB/Class/Host/HIDParser.c
index
7116ed8
..
c5d5f94
100644
(file)
--- a/
LUFA/Drivers/USB/Class/Host/HIDParser.c
+++ b/
LUFA/Drivers/USB/Class/Host/HIDParser.c
@@
-34,7
+34,9
@@
#include "HIDParser.h"
#include "HIDParser.h"
-uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID_ReportInfo_t* const ParserData)
+uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
+ uint16_t ReportSize,
+ HID_ReportInfo_t* const ParserData)
{
HID_StateTable_t StateTable[HID_STATETABLE_STACK_DEPTH];
HID_StateTable_t* CurrStateTable = &StateTable[0];
{
HID_StateTable_t StateTable[HID_STATETABLE_STACK_DEPTH];
HID_StateTable_t* CurrStateTable = &StateTable[0];
@@
-147,9
+149,9
@@
uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t));
}
}
memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t));
}
}
-
- ParserData->UsingReportIDs = true;
-
+
+ ParserData->UsingReportIDs = true;
+
CurrReportIDInfo->ReportID = CurrStateTable->ReportID;
break;
case (TYPE_LOCAL | TAG_LOCAL_USAGE):
CurrReportIDInfo->ReportID = CurrStateTable->ReportID;
break;
case (TYPE_LOCAL | TAG_LOCAL_USAGE):
@@
-174,7
+176,7
@@
uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
HID_CollectionPath_t* ParentCollectionPath = CurrCollectionPath;
CurrCollectionPath = &ParserData->CollectionPaths[1];
HID_CollectionPath_t* ParentCollectionPath = CurrCollectionPath;
CurrCollectionPath = &ParserData->CollectionPaths[1];
-
+
while (CurrCollectionPath->Parent != NULL)
{
if (CurrCollectionPath == &ParserData->CollectionPaths[HID_MAX_COLLECTIONS - 1])
while (CurrCollectionPath->Parent != NULL)
{
if (CurrCollectionPath == &ParserData->CollectionPaths[HID_MAX_COLLECTIONS - 1])
@@
-182,7
+184,7
@@
uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
CurrCollectionPath++;
}
CurrCollectionPath++;
}
-
+
CurrCollectionPath->Parent = ParentCollectionPath;
}
CurrCollectionPath->Parent = ParentCollectionPath;
}
@@
-220,15
+222,15
@@
uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
memcpy(&NewReportItem.Attributes,
&CurrStateTable->Attributes,
sizeof(HID_ReportItem_Attributes_t));
memcpy(&NewReportItem.Attributes,
&CurrStateTable->Attributes,
sizeof(HID_ReportItem_Attributes_t));
-
+
NewReportItem.ItemFlags = ReportItemData;
NewReportItem.CollectionPath = CurrCollectionPath;
NewReportItem.ReportID = CurrStateTable->ReportID;
NewReportItem.ItemFlags = ReportItemData;
NewReportItem.CollectionPath = CurrCollectionPath;
NewReportItem.ReportID = CurrStateTable->ReportID;
-
+
if (UsageListSize)
{
NewReportItem.Attributes.Usage.Usage = UsageList[0];
if (UsageListSize)
{
NewReportItem.Attributes.Usage.Usage = UsageList[0];
-
+
for (uint8_t i = 0; i < UsageListSize; i++)
UsageList[i] = UsageList[i + 1];
for (uint8_t i = 0; i < UsageListSize; i++)
UsageList[i] = UsageList[i + 1];
@@
-240,23
+242,23
@@
uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
}
uint8_t ItemTag = (HIDReportItem & TAG_MASK);
}
uint8_t ItemTag = (HIDReportItem & TAG_MASK);
-
+
if (ItemTag == TAG_MAIN_INPUT)
if (ItemTag == TAG_MAIN_INPUT)
- NewReportItem.ItemType =
REPORT_ITEM_TYPE
_In;
+ NewReportItem.ItemType =
HID_REPORT_ITEM
_In;
else if (ItemTag == TAG_MAIN_OUTPUT)
else if (ItemTag == TAG_MAIN_OUTPUT)
- NewReportItem.ItemType =
REPORT_ITEM_TYPE
_Out;
+ NewReportItem.ItemType =
HID_REPORT_ITEM
_Out;
else
else
- NewReportItem.ItemType =
REPORT_ITEM_TYPE
_Feature;
+ NewReportItem.ItemType =
HID_REPORT_ITEM
_Feature;
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType];
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType];
-
+
CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType] += CurrStateTable->Attributes.BitSize;
CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType] += CurrStateTable->Attributes.BitSize;
-
+
if (ParserData->LargestReportSizeBits < NewReportItem.BitOffset)
ParserData->LargestReportSizeBits = NewReportItem.BitOffset;
if (!(ReportItemData & IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem))
if (ParserData->LargestReportSizeBits < NewReportItem.BitOffset)
ParserData->LargestReportSizeBits = NewReportItem.BitOffset;
if (!(ReportItemData & IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem))
- {
+ {
if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS)
return HID_PARSE_InsufficientReportItems;
if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS)
return HID_PARSE_InsufficientReportItems;
@@
-274,7
+276,7
@@
uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
{
UsageMinMax.Minimum = 0;
UsageMinMax.Maximum = 0;
{
UsageMinMax.Minimum = 0;
UsageMinMax.Maximum = 0;
- UsageListSize = 0;
+ UsageListSize
= 0;
}
}
}
}
@@
-284,23
+286,24
@@
uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
return HID_PARSE_Successful;
}
return HID_PARSE_Successful;
}
-bool USB_GetHIDReportItemInfo(const uint8_t* ReportData, HID_ReportItem_t* const ReportItem)
+bool USB_GetHIDReportItemInfo(const uint8_t* ReportData,
+ HID_ReportItem_t* const ReportItem)
{
uint16_t DataBitsRem = ReportItem->Attributes.BitSize;
uint16_t CurrentBit = ReportItem->BitOffset;
uint32_t BitMask = (1 << 0);
{
uint16_t DataBitsRem = ReportItem->Attributes.BitSize;
uint16_t CurrentBit = ReportItem->BitOffset;
uint32_t BitMask = (1 << 0);
-
- ReportItem->PreviousValue = ReportItem->Value;
- ReportItem->Value = 0;
if (ReportItem->ReportID)
{
if (ReportItem->ReportID != ReportData[0])
return false;
if (ReportItem->ReportID)
{
if (ReportItem->ReportID != ReportData[0])
return false;
-
+
ReportData++;
}
ReportData++;
}
-
+
+ ReportItem->PreviousValue = ReportItem->Value;
+ ReportItem->Value = 0;
+
while (DataBitsRem--)
{
if (ReportData[CurrentBit / 8] & (1 << (CurrentBit % 8)))
while (DataBitsRem--)
{
if (ReportData[CurrentBit / 8] & (1 << (CurrentBit % 8)))
@@
-313,31
+316,34
@@
bool USB_GetHIDReportItemInfo(const uint8_t* ReportData, HID_ReportItem_t* const
return true;
}
return true;
}
-void USB_SetHIDReportItemInfo(uint8_t* ReportData, HID_ReportItem_t* const ReportItem)
+void USB_SetHIDReportItemInfo(uint8_t* ReportData,
+ HID_ReportItem_t* const ReportItem)
{
uint16_t DataBitsRem = ReportItem->Attributes.BitSize;
uint16_t CurrentBit = ReportItem->BitOffset;
uint32_t BitMask = (1 << 0);
{
uint16_t DataBitsRem = ReportItem->Attributes.BitSize;
uint16_t CurrentBit = ReportItem->BitOffset;
uint32_t BitMask = (1 << 0);
-
+
if (ReportItem->ReportID)
{
ReportData[0] = ReportItem->ReportID;
ReportData++;
}
if (ReportItem->ReportID)
{
ReportData[0] = ReportItem->ReportID;
ReportData++;
}
-
+
ReportItem->PreviousValue = ReportItem->Value;
ReportItem->PreviousValue = ReportItem->Value;
-
+
while (DataBitsRem--)
{
if (ReportItem->Value & (1 << (CurrentBit % 8)))
ReportData[CurrentBit / 8] |= BitMask;
while (DataBitsRem--)
{
if (ReportItem->Value & (1 << (CurrentBit % 8)))
ReportData[CurrentBit / 8] |= BitMask;
-
+
CurrentBit++;
BitMask <<= 1;
}
}
CurrentBit++;
BitMask <<= 1;
}
}
-uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData, const uint8_t ReportID, const uint8_t ReportType)
+uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData,
+ const uint8_t ReportID,
+ const uint8_t ReportType)
{
for (uint8_t i = 0; i < HID_MAX_REPORT_IDS; i++)
{
{
for (uint8_t i = 0; i < HID_MAX_REPORT_IDS; i++)
{