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 Mouse Client 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_mouse.h"
31 #include "ux_host_stack.h"
32
33
34 /**************************************************************************/
35 /* */
36 /* FUNCTION RELEASE */
37 /* */
38 /* _ux_host_class_hid_mouse_buttons_get PORTABLE C */
39 /* 6.1 */
40 /* AUTHOR */
41 /* */
42 /* Chaoqiong Xiao, Microsoft Corporation */
43 /* */
44 /* DESCRIPTION */
45 /* */
46 /* This function reads the mouse buttons and reports it to the user. */
47 /* */
48 /* INPUT */
49 /* */
50 /* mouse_instance Pointer to mouse instance */
51 /* mouse_buttons Current Mouse Buttons */
52 /* */
53 /* OUTPUT */
54 /* */
55 /* Completion Status */
56 /* */
57 /* CALLS */
58 /* */
59 /* _ux_host_stack_class_instance_verify Verify instance */
60 /* */
61 /* CALLED BY */
62 /* */
63 /* HID Mouse Class */
64 /* */
65 /* RELEASE HISTORY */
66 /* */
67 /* DATE NAME DESCRIPTION */
68 /* */
69 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
70 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
71 /* resulting in version 6.1 */
72 /* */
73 /**************************************************************************/
_ux_host_class_hid_mouse_buttons_get(UX_HOST_CLASS_HID_MOUSE * mouse_instance,ULONG * mouse_buttons)74 UINT _ux_host_class_hid_mouse_buttons_get(UX_HOST_CLASS_HID_MOUSE *mouse_instance,
75 ULONG *mouse_buttons)
76 {
77
78 UX_HOST_CLASS_HID *hid;
79
80 /* Get the HID class associated with the HID client. */
81 hid = mouse_instance -> ux_host_class_hid_mouse_hid;
82
83 /* Ensure the instance is valid. */
84 if (_ux_host_stack_class_instance_verify(_ux_system_host_class_hid_name, (VOID *) hid) != UX_SUCCESS)
85 {
86
87 /* Error trap. */
88 _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_HOST_CLASS_INSTANCE_UNKNOWN);
89
90 /* If trace is enabled, insert this event into the trace buffer. */
91 UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_INSTANCE_UNKNOWN, hid, 0, 0, UX_TRACE_ERRORS, 0, 0)
92
93 return(UX_HOST_CLASS_INSTANCE_UNKNOWN);
94 }
95
96 /* Report the mouse buttons. */
97 *mouse_buttons = mouse_instance -> ux_host_class_hid_mouse_buttons;
98
99 /* The status will tell the application there is something valid in the usage/value. */
100 return(UX_SUCCESS);
101 }
102
103