1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
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 /*  RELEASE HISTORY                                                       */
69 /*                                                                        */
70 /*    DATE              NAME                      DESCRIPTION             */
71 /*                                                                        */
72 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
73 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
74 /*                                            resulting in version 6.1    */
75 /*                                                                        */
76 /**************************************************************************/
_ux_host_class_hid_keyboard_ioctl(UX_HOST_CLASS_HID_KEYBOARD * keyboard_instance,ULONG ioctl_function,VOID * parameter)77 UINT _ux_host_class_hid_keyboard_ioctl(UX_HOST_CLASS_HID_KEYBOARD *keyboard_instance,
78                                         ULONG ioctl_function, VOID *parameter)
79 {
80 
81 UINT status = UX_SUCCESS;
82 
83 
84     switch(ioctl_function)
85     {
86 
87     case UX_HID_KEYBOARD_IOCTL_SET_LAYOUT:
88 
89         /* Change the keyboard layout setting.  */
90         keyboard_instance -> ux_host_class_hid_keyboard_layout = (parameter == UX_NULL) ?
91                                                                     &ux_host_class_hid_keyboard_layout :
92                                                                     (UX_HOST_CLASS_HID_KEYBOARD_LAYOUT *) parameter;
93 
94         break;
95 
96     case UX_HID_KEYBOARD_IOCTL_DISABLE_KEYS_DECODE:
97 
98         /* Disable the keys decode setting.  */
99         keyboard_instance -> ux_host_class_hid_keyboard_keys_decode_disable = UX_TRUE;
100 
101         break;
102 
103     case UX_HID_KEYBOARD_IOCTL_ENABLE_KEYS_DECODE:
104 
105         /* Enable the keys decode setting.  */
106         keyboard_instance -> ux_host_class_hid_keyboard_keys_decode_disable = UX_FALSE;
107 
108         break;
109 
110     default:
111 
112         /* Error trap. */
113         _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_FUNCTION_NOT_SUPPORTED);
114 
115         /* If trace is enabled, insert this event into the trace buffer.  */
116         UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_FUNCTION_NOT_SUPPORTED, 0, 0, 0, UX_TRACE_ERRORS, 0, 0)
117 
118         /* Function not supported. Return an error.  */
119         status =  UX_FUNCTION_NOT_SUPPORTED;
120 
121     }
122 
123     /* Return status to caller.  */
124     return(status);
125 }
126 
127