1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** USBX Component                                                        */
16 /**                                                                       */
17 /**   HID Mouse Client Class                                              */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 
23 /**************************************************************************/
24 /*                                                                        */
25 /*  COMPONENT DEFINITION                                   RELEASE        */
26 /*                                                                        */
27 /*    ux_host_class_hid_mouse.h                           PORTABLE C      */
28 /*                                                           6.1.11       */
29 /*  AUTHOR                                                                */
30 /*                                                                        */
31 /*    Chaoqiong Xiao, Microsoft Corporation                               */
32 /*                                                                        */
33 /*  DESCRIPTION                                                           */
34 /*                                                                        */
35 /*    This file contains all the header and extern functions used by the  */
36 /*    USBX HID mouse class.                                               */
37 /*                                                                        */
38 /*  RELEASE HISTORY                                                       */
39 /*                                                                        */
40 /*    DATE              NAME                      DESCRIPTION             */
41 /*                                                                        */
42 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
43 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
44 /*                                            resulting in version 6.1    */
45 /*  08-02-2021     Wen Wang                 Modified comment(s),          */
46 /*                                            added extern "C" keyword    */
47 /*                                            for compatibility with C++, */
48 /*                                            resulting in version 6.1.8  */
49 /*  01-31-2022     Chaoqiong Xiao           Modified comment(s),          */
50 /*                                            added standalone support,   */
51 /*                                            resulting in version 6.1.10 */
52 /*  04-25-2022     Chaoqiong Xiao           Modified comment(s),          */
53 /*                                            fixed clients management,   */
54 /*                                            resulting in version 6.1.11 */
55 /*                                                                        */
56 /**************************************************************************/
57 
58 #ifndef UX_HOST_CLASS_HID_MOUSE_H
59 #define UX_HOST_CLASS_HID_MOUSE_H
60 
61 /* Determine if a C++ compiler is being used.  If so, ensure that standard
62    C is used to process the API information.  */
63 
64 #ifdef   __cplusplus
65 
66 /* Yes, C++ compiler is present.  Use standard C.  */
67 extern   "C" {
68 
69 #endif
70 
71 
72 /* Internal option: enable the basic USBX error checking. This define is typically used
73    while debugging application.  */
74 #if defined(UX_ENABLE_ERROR_CHECKING) && !defined(UX_DEVICE_CLASS_HID_MOUSE_ENABLE_ERROR_CHECKING)
75 #define UX_DEVICE_CLASS_HID_MOUSE_ENABLE_ERROR_CHECKING
76 #endif
77 
78 
79 /* Define HID Mouse Class constants.  */
80 
81 #define UX_HOST_CLASS_HID_MOUSE_BUFFER_LENGTH                   128
82 #define UX_HOST_CLASS_HID_MOUSE_USAGE_ARRAY_LENGTH              64
83 
84 #define UX_HOST_CLASS_HID_MOUSE_BUTTON_1                        0x00090001
85 #define UX_HOST_CLASS_HID_MOUSE_BUTTON_2                        0x00090002
86 #define UX_HOST_CLASS_HID_MOUSE_BUTTON_3                        0x00090003
87 
88 #define UX_HOST_CLASS_HID_MOUSE_AXIS_X                          0x00010030
89 #define UX_HOST_CLASS_HID_MOUSE_AXIS_Y                          0x00010031
90 
91 
92 #define UX_HOST_CLASS_HID_MOUSE_BUTTON_1_PRESSED                0x01
93 #define UX_HOST_CLASS_HID_MOUSE_BUTTON_2_PRESSED                0x02
94 #define UX_HOST_CLASS_HID_MOUSE_BUTTON_3_PRESSED                0x04
95 
96 #define UX_HOST_CLASS_HID_MOUSE_WHEEL                           0x00010038
97 
98 /* Define HID Mouse Class structure.  */
99 
100 typedef struct UX_HOST_CLASS_HID_MOUSE_STRUCT
101 {
102 
103     ULONG           ux_host_class_hid_mouse_state;
104     UX_HOST_CLASS_HID   *ux_host_class_hid_mouse_hid;
105     USHORT          ux_host_class_hid_mouse_id;
106     SLONG           ux_host_class_hid_mouse_x_position;
107     SLONG           ux_host_class_hid_mouse_y_position;
108     ULONG           ux_host_class_hid_mouse_buttons;
109     SLONG           ux_host_class_hid_mouse_wheel;
110 #if defined(UX_HOST_STANDALONE)
111     UINT            ux_host_class_hid_mouse_enum_state;
112     UINT            ux_host_class_hid_mouse_status;
113 #endif
114 
115 } UX_HOST_CLASS_HID_MOUSE;
116 
117 typedef struct UX_HOST_CLASS_HID_CLIENT_MOUSE_STRUCT
118 {
119     UX_HOST_CLASS_HID_MOUSE     ux_host_class_hid_client_mouse_mouse;
120     UX_HOST_CLASS_HID_CLIENT    ux_host_class_hid_client_mouse_client;
121 } UX_HOST_CLASS_HID_CLIENT_MOUSE;
122 
123 /* Define HID Mouse Class function prototypes.  */
124 
125 UINT    _ux_host_class_hid_mouse_activate(UX_HOST_CLASS_HID_CLIENT_COMMAND *command);
126 VOID    _ux_host_class_hid_mouse_callback(UX_HOST_CLASS_HID_REPORT_CALLBACK *callback);
127 UINT    _ux_host_class_hid_mouse_deactivate(UX_HOST_CLASS_HID_CLIENT_COMMAND  *command);
128 UINT    _ux_host_class_hid_mouse_entry(UX_HOST_CLASS_HID_CLIENT_COMMAND *command);
129 UINT    _ux_host_class_hid_mouse_buttons_get(UX_HOST_CLASS_HID_MOUSE *mouse_instance,
130                                             ULONG *mouse_buttons);
131 UINT    _ux_host_class_hid_mouse_position_get(UX_HOST_CLASS_HID_MOUSE *mouse_instance,
132                                             SLONG *mouse_x_position,
133                                             SLONG *mouse_y_position);
134 UINT    _ux_host_class_hid_mouse_wheel_get(UX_HOST_CLASS_HID_MOUSE *mouse_instance,
135                                             SLONG *mouse_wheel_movement);
136 
137 UINT    _uxe_host_class_hid_mouse_buttons_get(UX_HOST_CLASS_HID_MOUSE *mouse_instance,
138                                             ULONG *mouse_buttons);
139 UINT    _uxe_host_class_hid_mouse_position_get(UX_HOST_CLASS_HID_MOUSE *mouse_instance,
140                                             SLONG *mouse_x_position,
141                                             SLONG *mouse_y_position);
142 UINT    _uxe_host_class_hid_mouse_wheel_get(UX_HOST_CLASS_HID_MOUSE *mouse_instance,
143                                             SLONG *mouse_wheel_movement);
144 
145 
146 /* Define HID Mouse Class API prototypes.  */
147 
148 #define ux_host_class_hid_mouse_entry                       _ux_host_class_hid_mouse_entry
149 
150 #if defined(UX_DEVICE_CLASS_HID_MOUSE_ENABLE_ERROR_CHECKING)
151 
152 #define ux_host_class_hid_mouse_buttons_get                 _uxe_host_class_hid_mouse_buttons_get
153 #define ux_host_class_hid_mouse_position_get                _uxe_host_class_hid_mouse_position_get
154 #define ux_host_class_hid_mouse_wheel_get                   _uxe_host_class_hid_mouse_wheel_get
155 
156 #else
157 
158 #define ux_host_class_hid_mouse_buttons_get                 _ux_host_class_hid_mouse_buttons_get
159 #define ux_host_class_hid_mouse_position_get                _ux_host_class_hid_mouse_position_get
160 #define ux_host_class_hid_mouse_wheel_get                   _ux_host_class_hid_mouse_wheel_get
161 
162 #endif
163 
164 
165 /* Determine if a C++ compiler is being used.  If so, complete the standard
166    C conditional started above.  */
167 #ifdef __cplusplus
168 }
169 #endif
170 
171 #endif
172