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