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 |
|
|
extern UX_HOST_CLASS_HID_KEYBOARD_LAYOUT ux_host_class_hid_keyboard_layout; |
34 |
|
|
|
35 |
|
|
/**************************************************************************/ |
36 |
|
|
/* */ |
37 |
|
|
/* FUNCTION RELEASE */ |
38 |
|
|
/* */ |
39 |
|
|
/* _ux_host_class_hid_keyboard_ioctl PORTABLE C */ |
40 |
|
|
/* 6.1 */ |
41 |
|
|
/* AUTHOR */ |
42 |
|
|
/* */ |
43 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
44 |
|
|
/* */ |
45 |
|
|
/* DESCRIPTION */ |
46 |
|
|
/* */ |
47 |
|
|
/* This function is the ioctl entry point for the application to */ |
48 |
|
|
/* configure the HID keyboard device. */ |
49 |
|
|
/* */ |
50 |
|
|
/* INPUT */ |
51 |
|
|
/* */ |
52 |
|
|
/* keyboard_instance Pointer to hid keyboard */ |
53 |
|
|
/* ioctl_function ioctl function */ |
54 |
|
|
/* parameter pointer to parameter/structure */ |
55 |
|
|
/* */ |
56 |
|
|
/* OUTPUT */ |
57 |
|
|
/* */ |
58 |
|
|
/* Completion Status */ |
59 |
|
|
/* */ |
60 |
|
|
/* CALLS */ |
61 |
|
|
/* */ |
62 |
|
|
/* */ |
63 |
|
|
/* */ |
64 |
|
|
/* CALLED BY */ |
65 |
|
|
/* */ |
66 |
|
|
/* HID Keyboard Client */ |
67 |
|
|
/* */ |
68 |
|
|
/**************************************************************************/ |
69 |
|
6 |
UINT _ux_host_class_hid_keyboard_ioctl(UX_HOST_CLASS_HID_KEYBOARD *keyboard_instance, |
70 |
|
|
ULONG ioctl_function, VOID *parameter) |
71 |
|
|
{ |
72 |
|
|
|
73 |
|
6 |
UINT status = UX_SUCCESS; |
74 |
|
|
|
75 |
|
|
|
76 |
✓✓✓✓
|
6 |
switch(ioctl_function) |
77 |
|
|
{ |
78 |
|
|
|
79 |
|
2 |
case UX_HID_KEYBOARD_IOCTL_SET_LAYOUT: |
80 |
|
|
|
81 |
|
|
/* Change the keyboard layout setting. */ |
82 |
|
2 |
keyboard_instance -> ux_host_class_hid_keyboard_layout = (parameter == UX_NULL) ? |
83 |
✓✓ |
2 |
&ux_host_class_hid_keyboard_layout : |
84 |
|
|
(UX_HOST_CLASS_HID_KEYBOARD_LAYOUT *) parameter; |
85 |
|
|
|
86 |
|
2 |
break; |
87 |
|
|
|
88 |
|
2 |
case UX_HID_KEYBOARD_IOCTL_DISABLE_KEYS_DECODE: |
89 |
|
|
|
90 |
|
|
/* Disable the keys decode setting. */ |
91 |
|
2 |
keyboard_instance -> ux_host_class_hid_keyboard_keys_decode_disable = UX_TRUE; |
92 |
|
|
|
93 |
|
2 |
break; |
94 |
|
|
|
95 |
|
1 |
case UX_HID_KEYBOARD_IOCTL_ENABLE_KEYS_DECODE: |
96 |
|
|
|
97 |
|
|
/* Enable the keys decode setting. */ |
98 |
|
1 |
keyboard_instance -> ux_host_class_hid_keyboard_keys_decode_disable = UX_FALSE; |
99 |
|
|
|
100 |
|
1 |
break; |
101 |
|
|
|
102 |
|
1 |
default: |
103 |
|
|
|
104 |
|
|
/* Error trap. */ |
105 |
|
1 |
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_FUNCTION_NOT_SUPPORTED); |
106 |
|
|
|
107 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
108 |
|
|
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_FUNCTION_NOT_SUPPORTED, 0, 0, 0, UX_TRACE_ERRORS, 0, 0) |
109 |
|
|
|
110 |
|
|
/* Function not supported. Return an error. */ |
111 |
|
1 |
status = UX_FUNCTION_NOT_SUPPORTED; |
112 |
|
|
|
113 |
|
|
} |
114 |
|
|
|
115 |
|
|
/* Return status to caller. */ |
116 |
|
6 |
return(status); |
117 |
|
|
} |
118 |
|
|
|
119 |
|
|
/**************************************************************************/ |
120 |
|
|
/* */ |
121 |
|
|
/* FUNCTION RELEASE */ |
122 |
|
|
/* */ |
123 |
|
|
/* _uxe_host_class_hid_keyboard_ioctl PORTABLE C */ |
124 |
|
|
/* 6.3.0 */ |
125 |
|
|
/* AUTHOR */ |
126 |
|
|
/* */ |
127 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
128 |
|
|
/* */ |
129 |
|
|
/* DESCRIPTION */ |
130 |
|
|
/* */ |
131 |
|
|
/* This function checks errors in HID keyboard ioctl function call. */ |
132 |
|
|
/* */ |
133 |
|
|
/* INPUT */ |
134 |
|
|
/* */ |
135 |
|
|
/* keyboard_instance Pointer to hid keyboard */ |
136 |
|
|
/* ioctl_function IOCTL function */ |
137 |
|
|
/* parameter Pointer to parameter/structure */ |
138 |
|
|
/* */ |
139 |
|
|
/* OUTPUT */ |
140 |
|
|
/* */ |
141 |
|
|
/* Status */ |
142 |
|
|
/* */ |
143 |
|
|
/* CALLS */ |
144 |
|
|
/* */ |
145 |
|
|
/* _ux_host_class_hid_keyboard_ioctl IOCTL function */ |
146 |
|
|
/* */ |
147 |
|
|
/* CALLED BY */ |
148 |
|
|
/* */ |
149 |
|
|
/* Application */ |
150 |
|
|
/* */ |
151 |
|
|
/**************************************************************************/ |
152 |
|
|
UINT _uxe_host_class_hid_keyboard_ioctl(UX_HOST_CLASS_HID_KEYBOARD *keyboard_instance, |
153 |
|
|
ULONG ioctl_function, VOID *parameter) |
154 |
|
|
{ |
155 |
|
|
|
156 |
|
|
/* Sanity checks. */ |
157 |
|
|
if (keyboard_instance == UX_NULL) |
158 |
|
|
return(UX_INVALID_PARAMETER); |
159 |
|
|
|
160 |
|
|
/* Invoke report ID get function. */ |
161 |
|
|
return(_ux_host_class_hid_keyboard_ioctl(keyboard_instance, ioctl_function, parameter)); |
162 |
|
|
} |