1 /*************************************************************************** 2 * Copyright (c) 2024 Microsoft Corporation 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the MIT License which is available at 6 * https://opensource.org/licenses/MIT. 7 * 8 * SPDX-License-Identifier: MIT 9 **************************************************************************/ 10 11 12 /**************************************************************************/ 13 /**************************************************************************/ 14 /** */ 15 /** USBX Component */ 16 /** */ 17 /** HID Class */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 23 /* Include necessary system files. */ 24 25 #define UX_SOURCE_CODE 26 27 #include "ux_api.h" 28 #include "ux_host_class_hid.h" 29 #include "ux_host_stack.h" 30 31 32 /**************************************************************************/ 33 /* */ 34 /* FUNCTION RELEASE */ 35 /* */ 36 /* _ux_host_class_hid_item_data_get PORTABLE C */ 37 /* 6.1 */ 38 /* AUTHOR */ 39 /* */ 40 /* Chaoqiong Xiao, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This function returns a data from the descriptor based on its size, */ 45 /* format and whether it is signed or not. */ 46 /* */ 47 /* INPUT */ 48 /* */ 49 /* descriptor Pointer to descriptor */ 50 /* item Pointer to item */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* ULONG data value */ 55 /* */ 56 /* CALLS */ 57 /* */ 58 /* _ux_utility_short_get Get 16-bit value */ 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_item_data_get(UCHAR * descriptor,UX_HOST_CLASS_HID_ITEM * item)73ULONG _ux_host_class_hid_item_data_get(UCHAR *descriptor, UX_HOST_CLASS_HID_ITEM *item) 74 { 75 76 ULONG value; 77 78 79 /* Get the length of the item. */ 80 switch (item -> ux_host_class_hid_item_report_length) 81 { 82 83 case 1: 84 85 value = (ULONG) *descriptor; 86 break; 87 88 89 case 2: 90 91 value = (ULONG) _ux_utility_short_get(descriptor); 92 break; 93 94 95 case 4: 96 97 value = (ULONG) _ux_utility_long_get(descriptor); 98 break; 99 100 101 default: 102 103 return(0); 104 } 105 106 /* Return the value. */ 107 return(value); 108 } 109 110