diff options
Diffstat (limited to 'Demos')
3 files changed, 15 insertions, 37 deletions
diff --git a/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c b/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c index bf39420ee..24701087b 100644 --- a/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c +++ b/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c @@ -132,15 +132,14 @@ int main(void) {
HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];
+ /* Update the report item value if it is contained within the current report */
+ if (!(USB_GetHIDReportItemInfo(JoystickReport, ReportItem)))
+ continue;
+
+ /* Determine what report item is being tested, process updated value as needed */
if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) &&
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))
{
- /* Get the joystick button value if it is contained within the current report, if not,
- * skip to the next item in the parser list
- */
- if (!(USB_GetHIDReportItemInfo(JoystickReport, ReportItem)))
- continue;
-
if (ReportItem->Value)
LEDMask = LEDS_ALL_LEDS;
}
@@ -149,12 +148,6 @@ int main(void) (ReportItem->Attributes.Usage.Usage == USAGE_Y)) &&
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))
{
- /* Get the joystick relative position value if it is contained within the current
- * report, if not, skip to the next item in the parser list
- */
- if (!(USB_GetHIDReportItemInfo(JoystickReport, ReportItem)))
- continue;
-
int16_t DeltaMovement = (int16_t)(ReportItem->Value << (16 - ReportItem->Attributes.BitSize));
if (ReportItem->Attributes.Usage.Usage == USAGE_X)
diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c index 8fe3edefe..78ec56aa3 100644 --- a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c +++ b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c @@ -130,18 +130,16 @@ int main(void) {
HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];
- /* Check if the current report item is a keyboard scancode */
+ /* Update the report item value if it is contained within the current report */
+ if (!(USB_GetHIDReportItemInfo(KeyboardReport, ReportItem)))
+ continue;
+
+ /* Determine what report item is being tested, process updated value as needed */
if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_KEYBOARD) &&
(ReportItem->Attributes.BitSize == 8) &&
(ReportItem->Attributes.Logical.Maximum > 1) &&
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))
{
- /* Retrieve the keyboard scancode from the report data retrieved from the device if it is
- * contained within the current report, if not, skip to the next item in the parser list
- */
- if (!(USB_GetHIDReportItemInfo(KeyboardReport, ReportItem)))
- continue;
-
/* Key code is an unsigned char in length, cast to the appropriate type */
uint8_t KeyCode = (uint8_t)ReportItem->Value;
diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c index db176e580..b6411858a 100644 --- a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c +++ b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c @@ -132,15 +132,14 @@ int main(void) {
HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];
+ /* Update the report item value if it is contained within the current report */
+ if (!(USB_GetHIDReportItemInfo(MouseReport, ReportItem)))
+ continue;
+
+ /* Determine what report item is being tested, process updated value as needed */
if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) &&
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))
{
- /* Get the mouse button value if it is contained within the current report, if not,
- * skip to the next item in the parser list
- */
- if (!(USB_GetHIDReportItemInfo(MouseReport, ReportItem)))
- continue;
-
if (ReportItem->Value)
LEDMask = LEDS_ALL_LEDS;
}
@@ -148,12 +147,6 @@ int main(void) (ReportItem->Attributes.Usage.Usage == USAGE_SCROLL_WHEEL) &&
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))
{
- /* Get the mouse wheel value if it is contained within the current
- * report, if not, skip to the next item in the parser list
- */
- if (!(USB_GetHIDReportItemInfo(MouseReport, ReportItem)))
- continue;
-
int16_t WheelDelta = (int16_t)(ReportItem->Value << (16 - ReportItem->Attributes.BitSize));
if (WheelDelta)
@@ -164,12 +157,6 @@ int main(void) (ReportItem->Attributes.Usage.Usage == USAGE_Y)) &&
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))
{
- /* Get the mouse relative position value if it is contained within the current
- * report, if not, skip to the next item in the parser list
- */
- if (!(USB_GetHIDReportItemInfo(MouseReport, ReportItem)))
- continue;
-
int16_t DeltaMovement = (int16_t)(ReportItem->Value << (16 - ReportItem->Attributes.BitSize));
if (ReportItem->Attributes.Usage.Usage == USAGE_X)
|