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 Remote Control 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_class_hid_remote_control.h" 31 #include "ux_host_stack.h" 32 33 34 /**************************************************************************/ 35 /* */ 36 /* FUNCTION RELEASE */ 37 /* */ 38 /* _ux_host_class_hid_remote_control_entry PORTABLE C */ 39 /* 6.1.10 */ 40 /* AUTHOR */ 41 /* */ 42 /* Chaoqiong Xiao, Microsoft Corporation */ 43 /* */ 44 /* DESCRIPTION */ 45 /* */ 46 /* This function is the entry point of the HID Remote Control client. */ 47 /* This function is called by the HID class after it has parsed a new */ 48 /* HID report descriptor and is searching for a HID client. */ 49 /* */ 50 /* INPUT */ 51 /* */ 52 /* command Pointer to command */ 53 /* */ 54 /* OUTPUT */ 55 /* */ 56 /* Completion Status */ 57 /* */ 58 /* CALLS */ 59 /* */ 60 /* _ux_host_class_hid_remote_control_activate */ 61 /* Activate HID RC class */ 62 /* _ux_host_class_hid_remote_control_deactivate */ 63 /* Deactivate HID RC class */ 64 /* */ 65 /* CALLED BY */ 66 /* */ 67 /* Host Stack */ 68 /* */ 69 /* RELEASE HISTORY */ 70 /* */ 71 /* DATE NAME DESCRIPTION */ 72 /* */ 73 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 74 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 75 /* resulting in version 6.1 */ 76 /* 01-31-2022 Chaoqiong Xiao Modified comment(s), */ 77 /* added standalone support, */ 78 /* resulting in version 6.1.10 */ 79 /* */ 80 /**************************************************************************/ _ux_host_class_hid_remote_control_entry(UX_HOST_CLASS_HID_CLIENT_COMMAND * command)81UINT _ux_host_class_hid_remote_control_entry(UX_HOST_CLASS_HID_CLIENT_COMMAND *command) 82 { 83 84 UINT status; 85 86 87 /* The command request will tell us we need to do here, either a enumeration 88 query, an activation or a deactivation. */ 89 switch (command -> ux_host_class_hid_client_command_request) 90 { 91 92 93 case UX_HOST_CLASS_COMMAND_QUERY: 94 95 /* The query command is used to let the HID class know if we want to own 96 this device or not */ 97 if ((command -> ux_host_class_hid_client_command_page == UX_HOST_CLASS_HID_PAGE_CONSUMER) && 98 (command -> ux_host_class_hid_client_command_usage == UX_HOST_CLASS_HID_CONSUMER_REMOTE_CONTROL)) 99 return(UX_SUCCESS); 100 else 101 return(UX_NO_CLASS_MATCH); 102 103 104 case UX_HOST_CLASS_COMMAND_ACTIVATE: 105 106 /* The activate command is used by the HID class to start the HID client. */ 107 status = _ux_host_class_hid_remote_control_activate(command); 108 109 /* Return completion status. */ 110 return(status); 111 112 113 case UX_HOST_CLASS_COMMAND_DEACTIVATE: 114 115 /* The deactivate command is used by the HID class when it received a deactivate 116 command from the USBX stack and there was a HID client attached to the HID instance */ 117 status = _ux_host_class_hid_remote_control_deactivate(command); 118 119 /* Return completion status. */ 120 return(status); 121 122 #if defined(UX_HOST_STANDALONE) 123 case UX_HOST_CLASS_COMMAND_ACTIVATE_WAIT: 124 125 /* Nothing to do, just next state. */ 126 return(UX_STATE_NEXT); 127 #endif 128 129 130 default: 131 break; 132 } 133 134 /* Return error status. */ 135 return(UX_ERROR); 136 } 137 138