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 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 |
|
|
/**************************************************************************/ |
68 |
|
81 |
UINT _ux_host_class_hid_mouse_position_get(UX_HOST_CLASS_HID_MOUSE *mouse_instance, |
69 |
|
|
SLONG *mouse_x_position, |
70 |
|
|
SLONG *mouse_y_position) |
71 |
|
|
{ |
72 |
|
|
|
73 |
|
|
UX_HOST_CLASS_HID *hid; |
74 |
|
|
|
75 |
|
|
/* Get the HID class associated with the HID client. */ |
76 |
|
81 |
hid = mouse_instance -> ux_host_class_hid_mouse_hid; |
77 |
|
|
|
78 |
|
|
/* Ensure the instance is valid. */ |
79 |
✓✓ |
81 |
if (_ux_host_stack_class_instance_verify(_ux_system_host_class_hid_name, (VOID *) hid) != UX_SUCCESS) |
80 |
|
|
{ |
81 |
|
|
|
82 |
|
|
/* Error trap. */ |
83 |
|
1 |
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_HOST_CLASS_INSTANCE_UNKNOWN); |
84 |
|
|
|
85 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
86 |
|
|
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_INSTANCE_UNKNOWN, hid, 0, 0, UX_TRACE_ERRORS, 0, 0) |
87 |
|
|
|
88 |
|
1 |
return(UX_HOST_CLASS_INSTANCE_UNKNOWN); |
89 |
|
|
} |
90 |
|
|
|
91 |
|
|
/* Report the mouse X position. */ |
92 |
|
80 |
*mouse_x_position = mouse_instance -> ux_host_class_hid_mouse_x_position; |
93 |
|
|
|
94 |
|
|
/* Report the mouse Y position. */ |
95 |
|
80 |
*mouse_y_position = mouse_instance -> ux_host_class_hid_mouse_y_position; |
96 |
|
|
|
97 |
|
|
/* The status will tell the application there is something valid in the usage/value. */ |
98 |
|
80 |
return(UX_SUCCESS); |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
/**************************************************************************/ |
102 |
|
|
/* */ |
103 |
|
|
/* FUNCTION RELEASE */ |
104 |
|
|
/* */ |
105 |
|
|
/* _uxe_host_class_hid_mouse_position_get PORTABLE C */ |
106 |
|
|
/* 6.3.0 */ |
107 |
|
|
/* AUTHOR */ |
108 |
|
|
/* */ |
109 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
110 |
|
|
/* */ |
111 |
|
|
/* DESCRIPTION */ |
112 |
|
|
/* */ |
113 |
|
|
/* This function checks errors in HID mouse position get function call.*/ |
114 |
|
|
/* */ |
115 |
|
|
/* INPUT */ |
116 |
|
|
/* */ |
117 |
|
|
/* mouse_instance Pointer to mouse instance */ |
118 |
|
|
/* mouse_x_position Current Mouse X Position */ |
119 |
|
|
/* mouse_y_position Current Mouse Y Position */ |
120 |
|
|
/* */ |
121 |
|
|
/* OUTPUT */ |
122 |
|
|
/* */ |
123 |
|
|
/* Status */ |
124 |
|
|
/* */ |
125 |
|
|
/* CALLS */ |
126 |
|
|
/* */ |
127 |
|
|
/* _ux_host_class_hid_mouse_position_get Get mouse position */ |
128 |
|
|
/* */ |
129 |
|
|
/* CALLED BY */ |
130 |
|
|
/* */ |
131 |
|
|
/* Application */ |
132 |
|
|
/* */ |
133 |
|
|
/**************************************************************************/ |
134 |
|
|
UINT _uxe_host_class_hid_mouse_position_get(UX_HOST_CLASS_HID_MOUSE *mouse_instance, |
135 |
|
|
SLONG *mouse_x_position, |
136 |
|
|
SLONG *mouse_y_position) |
137 |
|
|
{ |
138 |
|
|
|
139 |
|
|
/* Sanity checks. */ |
140 |
|
|
if ((mouse_instance == UX_NULL) || |
141 |
|
|
(mouse_x_position == UX_NULL) || (mouse_y_position == UX_NULL) || |
142 |
|
|
(mouse_x_position == mouse_y_position)) |
143 |
|
|
{ |
144 |
|
|
return(UX_INVALID_PARAMETER); |
145 |
|
|
} |
146 |
|
|
|
147 |
|
|
/* Invoke position get function. */ |
148 |
|
|
return(_ux_host_class_hid_mouse_position_get(mouse_instance, |
149 |
|
|
mouse_x_position, mouse_y_position)); |
150 |
|
|
} |