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 Keyboard Client */ |
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_keyboard.h" |
30 |
|
|
#include "ux_host_stack.h" |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
/**************************************************************************/ |
34 |
|
|
/* */ |
35 |
|
|
/* FUNCTION RELEASE */ |
36 |
|
|
/* */ |
37 |
|
|
/* _ux_host_class_hid_keyboard_deactivate PORTABLE C */ |
38 |
|
|
/* 6.3.0 */ |
39 |
|
|
/* AUTHOR */ |
40 |
|
|
/* */ |
41 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
42 |
|
|
/* */ |
43 |
|
|
/* DESCRIPTION */ |
44 |
|
|
/* */ |
45 |
|
|
/* This function performs the deactivation of a HID Keyboard Client. */ |
46 |
|
|
/* */ |
47 |
|
|
/* INPUT */ |
48 |
|
|
/* */ |
49 |
|
|
/* command Pointer to command */ |
50 |
|
|
/* */ |
51 |
|
|
/* OUTPUT */ |
52 |
|
|
/* */ |
53 |
|
|
/* Completion Status */ |
54 |
|
|
/* */ |
55 |
|
|
/* CALLS */ |
56 |
|
|
/* */ |
57 |
|
|
/* _ux_host_class_hid_periodic_report_stop */ |
58 |
|
|
/* Stop periodic report */ |
59 |
|
|
/* _ux_utility_memory_free Release memory block */ |
60 |
|
|
/* _ux_host_semaphore_delete Delete semaphore */ |
61 |
|
|
/* _ux_utility_thread_delete Delete thread */ |
62 |
|
|
/* */ |
63 |
|
|
/* CALLED BY */ |
64 |
|
|
/* */ |
65 |
|
|
/* HID Class */ |
66 |
|
|
/* */ |
67 |
|
|
/* RELEASE HISTORY */ |
68 |
|
|
/* */ |
69 |
|
|
/* DATE NAME DESCRIPTION */ |
70 |
|
|
/* */ |
71 |
|
|
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ |
72 |
|
|
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ |
73 |
|
|
/* resulting in version 6.1 */ |
74 |
|
|
/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */ |
75 |
|
|
/* added standalone support, */ |
76 |
|
|
/* resulting in version 6.1.10 */ |
77 |
|
|
/* 04-25-2022 Chaoqiong Xiao Modified comment(s), */ |
78 |
|
|
/* internal clean up, */ |
79 |
|
|
/* resulting in version 6.1.11 */ |
80 |
|
|
/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */ |
81 |
|
|
/* improved unload sequence, */ |
82 |
|
|
/* resulting in version 6.3.0 */ |
83 |
|
|
/* */ |
84 |
|
|
/**************************************************************************/ |
85 |
|
76 |
UINT _ux_host_class_hid_keyboard_deactivate(UX_HOST_CLASS_HID_CLIENT_COMMAND *command) |
86 |
|
|
{ |
87 |
|
|
|
88 |
|
|
UX_HOST_CLASS_HID *hid; |
89 |
|
|
UX_HOST_CLASS_HID_CLIENT *hid_client; |
90 |
|
|
UX_HOST_CLASS_HID_KEYBOARD *keyboard_instance; |
91 |
|
76 |
UINT status = UX_SUCCESS; |
92 |
|
|
|
93 |
|
|
|
94 |
|
|
/* Get the instance to the HID class. */ |
95 |
|
76 |
hid = command -> ux_host_class_hid_client_command_instance; |
96 |
|
|
|
97 |
|
|
/* Stop the periodic report. */ |
98 |
|
76 |
_ux_host_class_hid_periodic_report_stop(hid); |
99 |
|
|
|
100 |
|
|
/* Get the HID client pointer. */ |
101 |
|
76 |
hid_client = hid -> ux_host_class_hid_client; |
102 |
|
|
|
103 |
|
|
/* Get the remote control local instance. */ |
104 |
|
76 |
keyboard_instance = (UX_HOST_CLASS_HID_KEYBOARD *) hid_client -> ux_host_class_hid_client_local_instance; |
105 |
|
|
|
106 |
|
|
#if !defined(UX_HOST_STANDALONE) |
107 |
|
|
|
108 |
|
|
/* Stop the semaphore. */ |
109 |
|
76 |
status = _ux_host_semaphore_delete(&keyboard_instance -> ux_host_class_hid_keyboard_semaphore); |
110 |
|
|
|
111 |
|
|
/* Terminate the thread. */ |
112 |
|
76 |
_ux_utility_thread_delete(&keyboard_instance -> ux_host_class_hid_keyboard_thread); |
113 |
|
|
#endif |
114 |
|
|
|
115 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
116 |
|
|
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_CLASS_HID_KEYBOARD_DEACTIVATE, hid, keyboard_instance, 0, 0, UX_TRACE_HOST_CLASS_EVENTS, 0, 0) |
117 |
|
|
|
118 |
|
|
/* We may need to inform the application |
119 |
|
|
if a function has been programmed in the system structure. */ |
120 |
✓✓ |
76 |
if (_ux_system_host -> ux_system_host_change_function != UX_NULL) |
121 |
|
|
{ |
122 |
|
|
|
123 |
|
|
/* Call system change function. */ |
124 |
|
74 |
_ux_system_host -> ux_system_host_change_function(UX_HID_CLIENT_REMOVAL, hid -> ux_host_class_hid_class, (VOID *) hid_client); |
125 |
|
|
} |
126 |
|
|
|
127 |
|
|
#if !defined(UX_HOST_STANDALONE) |
128 |
|
|
|
129 |
|
|
/* Return to the pool the thread stack. */ |
130 |
|
76 |
_ux_utility_memory_free(keyboard_instance -> ux_host_class_hid_keyboard_thread_stack); |
131 |
|
|
#endif |
132 |
|
|
|
133 |
|
|
/* Free memory for key states. */ |
134 |
|
76 |
_ux_utility_memory_free(keyboard_instance -> ux_host_class_hid_keyboard_key_state); |
135 |
|
|
|
136 |
|
|
/* Unload all the memory used by the keyboard client. */ |
137 |
|
76 |
_ux_utility_memory_free(keyboard_instance -> ux_host_class_hid_keyboard_usage_array); |
138 |
|
|
|
139 |
|
|
/* Now free the instance memory. */ |
140 |
|
76 |
_ux_utility_memory_free(hid_client -> ux_host_class_hid_client_local_instance); |
141 |
|
|
|
142 |
|
|
/* Return completion status. */ |
143 |
|
76 |
return(status); |
144 |
|
|
} |
145 |
|
|
|