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