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_usage_get PORTABLE C */ |
38 |
|
|
/* 6.1 */ |
39 |
|
|
/* AUTHOR */ |
40 |
|
|
/* */ |
41 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
42 |
|
|
/* */ |
43 |
|
|
/* DESCRIPTION */ |
44 |
|
|
/* */ |
45 |
|
|
/* This function reads the usage and value from the remote control */ |
46 |
|
|
/* round-robin buffer. */ |
47 |
|
|
/* */ |
48 |
|
|
/* INPUT */ |
49 |
|
|
/* */ |
50 |
|
|
/* remote_control_instance Pointer to remote control */ |
51 |
|
|
/* usage Pointer to usage */ |
52 |
|
|
/* value Pointer to value */ |
53 |
|
|
/* */ |
54 |
|
|
/* OUTPUT */ |
55 |
|
|
/* */ |
56 |
|
|
/* Completion Status */ |
57 |
|
|
/* */ |
58 |
|
|
/* CALLS */ |
59 |
|
|
/* */ |
60 |
|
|
/* None */ |
61 |
|
|
/* */ |
62 |
|
|
/* CALLED BY */ |
63 |
|
|
/* */ |
64 |
|
|
/* HID Remote Control Class */ |
65 |
|
|
/* */ |
66 |
|
|
/* RELEASE HISTORY */ |
67 |
|
|
/* */ |
68 |
|
|
/* DATE NAME DESCRIPTION */ |
69 |
|
|
/* */ |
70 |
|
|
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ |
71 |
|
|
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ |
72 |
|
|
/* resulting in version 6.1 */ |
73 |
|
|
/* */ |
74 |
|
|
/**************************************************************************/ |
75 |
|
707 |
UINT _ux_host_class_hid_remote_control_usage_get(UX_HOST_CLASS_HID_REMOTE_CONTROL *remote_control_instance, ULONG *usage, ULONG *value) |
76 |
|
|
{ |
77 |
|
|
|
78 |
|
|
ULONG *array_head; |
79 |
|
|
ULONG *array_tail; |
80 |
|
|
ULONG *array_end; |
81 |
|
|
ULONG *array_start; |
82 |
|
|
UX_HOST_CLASS_HID *hid; |
83 |
|
|
|
84 |
|
|
/* Get the HID class associated with the HID client. */ |
85 |
|
707 |
hid = remote_control_instance -> ux_host_class_hid_remote_control_hid; |
86 |
|
|
|
87 |
|
|
/* Ensure the instance is valid. */ |
88 |
✓✓ |
707 |
if (_ux_host_stack_class_instance_verify(_ux_system_host_class_hid_name, (VOID *) hid) != UX_SUCCESS) |
89 |
|
|
{ |
90 |
|
|
|
91 |
|
|
/* Error trap. */ |
92 |
|
1 |
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_HOST_CLASS_INSTANCE_UNKNOWN); |
93 |
|
|
|
94 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
95 |
|
|
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_INSTANCE_UNKNOWN, hid, 0, 0, UX_TRACE_ERRORS, 0, 0) |
96 |
|
|
|
97 |
|
1 |
return(UX_HOST_CLASS_INSTANCE_UNKNOWN); |
98 |
|
|
} |
99 |
|
|
|
100 |
|
|
/* Load the remote control usage/value array info. */ |
101 |
|
706 |
array_start = remote_control_instance -> ux_host_class_hid_remote_control_usage_array; |
102 |
|
706 |
array_end = array_start + UX_HOST_CLASS_HID_REMOTE_CONTROL_USAGE_ARRAY_LENGTH; |
103 |
|
706 |
array_head = remote_control_instance -> ux_host_class_hid_remote_control_usage_array_head; |
104 |
|
706 |
array_tail = remote_control_instance -> ux_host_class_hid_remote_control_usage_array_tail; |
105 |
|
|
|
106 |
|
|
/* We want to extract a usage/value from the circular queue of the remote control instance. */ |
107 |
✓✓ |
706 |
if (array_tail == array_head) |
108 |
|
260 |
return(UX_ERROR); |
109 |
|
|
|
110 |
|
|
/* Get the usage/value from the current tail. */ |
111 |
|
446 |
*usage = *array_tail; |
112 |
|
446 |
*value = *(array_tail + 1); |
113 |
|
|
|
114 |
|
|
/* Now we need to update the tail value. Are we at the end of the array? */ |
115 |
✓✓ |
446 |
if ((array_tail+2) >= array_end) |
116 |
|
13 |
array_tail = array_start; |
117 |
|
|
else |
118 |
|
433 |
array_tail += 2; |
119 |
|
|
|
120 |
|
|
/* Set the tail pointer. */ |
121 |
|
446 |
remote_control_instance -> ux_host_class_hid_remote_control_usage_array_tail = array_tail; |
122 |
|
|
|
123 |
|
|
/* The status will tell the application there is something valid in the usage/value. */ |
124 |
|
446 |
return(UX_SUCCESS); |
125 |
|
|
} |
126 |
|
|
|
127 |
|
|
/**************************************************************************/ |
128 |
|
|
/* */ |
129 |
|
|
/* FUNCTION RELEASE */ |
130 |
|
|
/* */ |
131 |
|
|
/* _uxe_host_class_hid_remote_control_usage_get PORTABLE C */ |
132 |
|
|
/* 6.3.0 */ |
133 |
|
|
/* AUTHOR */ |
134 |
|
|
/* */ |
135 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
136 |
|
|
/* */ |
137 |
|
|
/* DESCRIPTION */ |
138 |
|
|
/* */ |
139 |
|
|
/* This function checks errors in HID remote control get function call.*/ |
140 |
|
|
/* */ |
141 |
|
|
/* INPUT */ |
142 |
|
|
/* */ |
143 |
|
|
/* remote_control_instance Pointer to remote control */ |
144 |
|
|
/* usage Pointer to usage */ |
145 |
|
|
/* value Pointer to value */ |
146 |
|
|
/* */ |
147 |
|
|
/* OUTPUT */ |
148 |
|
|
/* */ |
149 |
|
|
/* Status */ |
150 |
|
|
/* */ |
151 |
|
|
/* CALLS */ |
152 |
|
|
/* */ |
153 |
|
|
/* _ux_host_class_hid_remote_control_usage_get */ |
154 |
|
|
/* Get remote control usage */ |
155 |
|
|
/* */ |
156 |
|
|
/* CALLED BY */ |
157 |
|
|
/* */ |
158 |
|
|
/* Application */ |
159 |
|
|
/* */ |
160 |
|
|
/* RELEASE HISTORY */ |
161 |
|
|
/* */ |
162 |
|
|
/* DATE NAME DESCRIPTION */ |
163 |
|
|
/* */ |
164 |
|
|
/* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */ |
165 |
|
|
/* */ |
166 |
|
|
/**************************************************************************/ |
167 |
|
|
UINT _uxe_host_class_hid_remote_control_usage_get( |
168 |
|
|
UX_HOST_CLASS_HID_REMOTE_CONTROL *remote_control_instance, |
169 |
|
|
ULONG *usage, ULONG *value) |
170 |
|
|
{ |
171 |
|
|
|
172 |
|
|
/* Sanity checks. */ |
173 |
|
|
if ((remote_control_instance == UX_NULL) || |
174 |
|
|
(usage == UX_NULL) || (value == UX_NULL) || |
175 |
|
|
(usage == value)) |
176 |
|
|
return(UX_INVALID_PARAMETER); |
177 |
|
|
|
178 |
|
|
/* Invoke remote control get function. */ |
179 |
|
|
return(_ux_host_class_hid_remote_control_usage_get(remote_control_instance, usage, value)); |
180 |
|
|
} |