1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
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 |
|
|
/**************************************************************************/ |
70 |
|
52 |
UINT _ux_host_class_hid_remote_control_entry(UX_HOST_CLASS_HID_CLIENT_COMMAND *command) |
71 |
|
|
{ |
72 |
|
|
|
73 |
|
|
UINT status; |
74 |
|
|
|
75 |
|
|
|
76 |
|
|
/* The command request will tell us we need to do here, either a enumeration |
77 |
|
|
query, an activation or a deactivation. */ |
78 |
✓✓✓✓
|
52 |
switch (command -> ux_host_class_hid_client_command_request) |
79 |
|
|
{ |
80 |
|
|
|
81 |
|
|
|
82 |
|
21 |
case UX_HOST_CLASS_COMMAND_QUERY: |
83 |
|
|
|
84 |
|
|
/* The query command is used to let the HID class know if we want to own |
85 |
|
|
this device or not */ |
86 |
✓✓ |
21 |
if ((command -> ux_host_class_hid_client_command_page == UX_HOST_CLASS_HID_PAGE_CONSUMER) && |
87 |
✓✓ |
20 |
(command -> ux_host_class_hid_client_command_usage == UX_HOST_CLASS_HID_CONSUMER_REMOTE_CONTROL)) |
88 |
|
19 |
return(UX_SUCCESS); |
89 |
|
|
else |
90 |
|
2 |
return(UX_NO_CLASS_MATCH); |
91 |
|
|
|
92 |
|
|
|
93 |
|
19 |
case UX_HOST_CLASS_COMMAND_ACTIVATE: |
94 |
|
|
|
95 |
|
|
/* The activate command is used by the HID class to start the HID client. */ |
96 |
|
19 |
status = _ux_host_class_hid_remote_control_activate(command); |
97 |
|
|
|
98 |
|
|
/* Return completion status. */ |
99 |
|
19 |
return(status); |
100 |
|
|
|
101 |
|
|
|
102 |
|
11 |
case UX_HOST_CLASS_COMMAND_DEACTIVATE: |
103 |
|
|
|
104 |
|
|
/* The deactivate command is used by the HID class when it received a deactivate |
105 |
|
|
command from the USBX stack and there was a HID client attached to the HID instance */ |
106 |
|
11 |
status = _ux_host_class_hid_remote_control_deactivate(command); |
107 |
|
|
|
108 |
|
|
/* Return completion status. */ |
109 |
|
11 |
return(status); |
110 |
|
|
|
111 |
|
|
#if defined(UX_HOST_STANDALONE) |
112 |
|
|
case UX_HOST_CLASS_COMMAND_ACTIVATE_WAIT: |
113 |
|
|
|
114 |
|
|
/* Nothing to do, just next state. */ |
115 |
|
|
return(UX_STATE_NEXT); |
116 |
|
|
#endif |
117 |
|
|
|
118 |
|
|
|
119 |
|
1 |
default: |
120 |
|
1 |
break; |
121 |
|
|
} |
122 |
|
|
|
123 |
|
|
/* Return error status. */ |
124 |
|
1 |
return(UX_ERROR); |
125 |
|
|
} |
126 |
|
|
|