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