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