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_position_get PORTABLE C */
39 /* 6.1 */
40 /* AUTHOR */
41 /* */
42 /* Chaoqiong Xiao, Microsoft Corporation */
43 /* */
44 /* DESCRIPTION */
45 /* */
46 /* This function reads the mouse position and reports it to the user. */
47 /* We have the X and Y coordinates passed by the application. */
48 /* */
49 /* INPUT */
50 /* */
51 /* mouse_instance Pointer to mouse instance */
52 /* mouse_x_position Current Mouse X Position */
53 /* mouse_y_position Current Mouse Y Position */
54 /* */
55 /* OUTPUT */
56 /* */
57 /* Completion Status */
58 /* */
59 /* CALLS */
60 /* */
61 /* None */
62 /* */
63 /* CALLED BY */
64 /* */
65 /* HID Mouse 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 /* */
75 /**************************************************************************/
_ux_host_class_hid_mouse_position_get(UX_HOST_CLASS_HID_MOUSE * mouse_instance,SLONG * mouse_x_position,SLONG * mouse_y_position)76 UINT _ux_host_class_hid_mouse_position_get(UX_HOST_CLASS_HID_MOUSE *mouse_instance,
77 SLONG *mouse_x_position,
78 SLONG *mouse_y_position)
79 {
80
81 UX_HOST_CLASS_HID *hid;
82
83 /* Get the HID class associated with the HID client. */
84 hid = mouse_instance -> ux_host_class_hid_mouse_hid;
85
86 /* Ensure the instance is valid. */
87 if (_ux_host_stack_class_instance_verify(_ux_system_host_class_hid_name, (VOID *) hid) != UX_SUCCESS)
88 {
89
90 /* Error trap. */
91 _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_HOST_CLASS_INSTANCE_UNKNOWN);
92
93 /* If trace is enabled, insert this event into the trace buffer. */
94 UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_INSTANCE_UNKNOWN, hid, 0, 0, UX_TRACE_ERRORS, 0, 0)
95
96 return(UX_HOST_CLASS_INSTANCE_UNKNOWN);
97 }
98
99 /* Report the mouse X position. */
100 *mouse_x_position = mouse_instance -> ux_host_class_hid_mouse_x_position;
101
102 /* Report the mouse Y position. */
103 *mouse_y_position = mouse_instance -> ux_host_class_hid_mouse_y_position;
104
105 /* The status will tell the application there is something valid in the usage/value. */
106 return(UX_SUCCESS);
107 }
108
109