1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** USBX Component */ 17 /** */ 18 /** HID Class */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 24 /* Include necessary system files. */ 25 26 #define UX_SOURCE_CODE 27 28 #include "ux_api.h" 29 #include "ux_host_class_hid.h" 30 #include "ux_host_stack.h" 31 32 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _ux_host_class_hid_report_item_analyse PORTABLE C */ 38 /* 6.1 */ 39 /* AUTHOR */ 40 /* */ 41 /* Chaoqiong Xiao, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function gets the report descriptor and analyzes it. */ 46 /* */ 47 /* INPUT */ 48 /* */ 49 /* descriptor Pointer to descriptor */ 50 /* item Pointer to item */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* Completion Status */ 55 /* */ 56 /* CALLS */ 57 /* */ 58 /* None */ 59 /* */ 60 /* CALLED BY */ 61 /* */ 62 /* HID Class */ 63 /* */ 64 /* RELEASE HISTORY */ 65 /* */ 66 /* DATE NAME DESCRIPTION */ 67 /* */ 68 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 69 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 70 /* resulting in version 6.1 */ 71 /* */ 72 /**************************************************************************/ _ux_host_class_hid_report_item_analyse(UCHAR * descriptor,UX_HOST_CLASS_HID_ITEM * item)73UINT _ux_host_class_hid_report_item_analyse(UCHAR *descriptor, UX_HOST_CLASS_HID_ITEM *item) 74 { 75 76 UCHAR item_byte; 77 78 79 /* Get the first byte from the descriptor. */ 80 item_byte = *descriptor; 81 82 /* We need to determine if this is a short or long item. 83 For long items, the tag is always 1111. */ 84 if ((item_byte & UX_HOST_CLASS_HID_ITEM_TAG_MASK) == UX_HOST_CLASS_HID_ITEM_TAG_LONG) 85 { 86 87 /* We have a long item, mark its format. */ 88 item -> ux_host_class_hid_item_report_format = UX_HOST_CLASS_HID_ITEM_TAG_LONG; 89 90 /* Set the type. */ 91 item -> ux_host_class_hid_item_report_type = (item_byte >> 2) & 3; 92 93 /* Get its length (byte 1). */ 94 item -> ux_host_class_hid_item_report_length = (USHORT) *(descriptor + 1); 95 96 /* Then the tag (byte 2). */ 97 item -> ux_host_class_hid_item_report_tag = *(descriptor + 2); 98 } 99 else 100 { 101 102 /* We have a short item. Mark its format */ 103 item -> ux_host_class_hid_item_report_format = UX_HOST_CLASS_HID_ITEM_TAG_SHORT; 104 105 /* Get the length of the item. */ 106 switch (item_byte & UX_HOST_CLASS_HID_ITEM_LENGTH_MASK) 107 { 108 109 case 3: 110 111 item -> ux_host_class_hid_item_report_length = 4; 112 break; 113 114 default: 115 116 item -> ux_host_class_hid_item_report_length = item_byte & UX_HOST_CLASS_HID_ITEM_LENGTH_MASK; 117 break; 118 } 119 120 /* Set the type. */ 121 item -> ux_host_class_hid_item_report_type = (item_byte >> 2) & 3; 122 123 /* Set the tag. */ 124 item -> ux_host_class_hid_item_report_tag = item_byte >> 4; 125 } 126 127 /* Return successful completion. */ 128 return(UX_SUCCESS); 129 } 130 131