From 205b35d131a1cc8196786de4370cb90fec17835e Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Wed, 2 Sep 2009 07:16:52 +0000 Subject: Add user-filtering to the HID report parser, so that the user code can decide which items are to be stored into the HID_ReportInfo_t structure and which should be discarded to save on RAM usage. --- .../LowLevel/KeyboardHostWithParser/HIDReport.c | 22 ++++++++++++++++++++ .../LowLevel/KeyboardHostWithParser/HIDReport.h | 2 ++ .../Host/LowLevel/MouseHostWithParser/HIDReport.c | 24 ++++++++++++++++++++++ .../Host/LowLevel/MouseHostWithParser/HIDReport.h | 2 ++ 4 files changed, 50 insertions(+) (limited to 'Demos/Host') diff --git a/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.c b/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.c index 6ac1f5a65..2623878d1 100644 --- a/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.c +++ b/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.c @@ -70,3 +70,25 @@ uint8_t GetHIDReportData(void) return ParseSuccessful; } +/** Callback for the HID Report Parser. This function is called each time the HID report parser is about to store + * an IN, OUT or FEATURE item into the HIDReportInfo structure. To save on RAM, we are able to filter out items + * we aren't interested in (preventing us from being able to extract them later on, but saving on the RAM they would + * have occupied). + * + * \param CurrentItemAttributes Pointer to the attrbutes of the item the HID report parser is currently working with + * + * \return Boolean true if the item should be stored into the HID report structure, false if it should be discarded + */ +bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_Attributes_t* CurrentItemAttributes) +{ + /* Check the attributes of the current item - see if we are interested in it or not */ + if (CurrentItemAttributes->Usage.Page == USAGE_PAGE_KEYBOARD) + { + /* Only store KEYBOARD usage page items into the Processed HID Report structure to save RAM */ + return true; + } + else + { + return false; + } +} diff --git a/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.h b/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.h index a141ffb8c..974cf72c7 100644 --- a/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.h +++ b/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.h @@ -76,5 +76,7 @@ /* Function Prototypes: */ uint8_t GetHIDReportData(void); + + bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_Attributes_t* CurrentItemAttributes); #endif diff --git a/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.c b/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.c index 4d895908e..41abcb221 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.c +++ b/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.c @@ -69,3 +69,27 @@ uint8_t GetHIDReportData(void) return ParseSuccessful; } + +/** Callback for the HID Report Parser. This function is called each time the HID report parser is about to store + * an IN, OUT or FEATURE item into the HIDReportInfo structure. To save on RAM, we are able to filter out items + * we aren't interested in (preventing us from being able to extract them later on, but saving on the RAM they would + * have occupied). + * + * \param CurrentItemAttributes Pointer to the attrbutes of the item the HID report parser is currently working with + * + * \return Boolean true if the item should be stored into the HID report structure, false if it should be discarded + */ +bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_Attributes_t* CurrentItemAttributes) +{ + /* Check the attributes of the current item - see if we are interested in it or not */ + if ((CurrentItemAttributes->Usage.Page == USAGE_PAGE_BUTTON) || + (CurrentItemAttributes->Usage.Page == USAGE_PAGE_GENERIC_DCTRL)) + { + /* Only store BUTTON and GENERIC_DESKTOP_CONTROL items into the Processed HID Report structure to save RAM */ + return true; + } + else + { + return false; + } +} diff --git a/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.h b/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.h index f5429f0a9..ae6871c57 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.h +++ b/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.h @@ -86,4 +86,6 @@ /* Function Prototypes: */ uint8_t GetHIDReportData(void); + bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_Attributes_t* CurrentItemAttributes); + #endif -- cgit v1.2.3