GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usbx_host_classes/src/ux_host_class_hid_mouse_position_get.c Lines: 8 13 61.5 %
Date: 2024-12-12 17:16:36 Branches: 2 10 20.0 %

Line Branch Exec Source
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
/* Include necessary system files.  */
24
25
#define UX_SOURCE_CODE
26
27
#include "ux_api.h"
28
#include "ux_host_class_hid.h"
29
#include "ux_host_class_hid_mouse.h"
30
#include "ux_host_stack.h"
31
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _ux_host_class_hid_mouse_position_get               PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Chaoqiong Xiao, Microsoft Corporation                               */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function reads the mouse position and reports it to the user.  */
46
/*    We have the X and Y coordinates passed by the application.          */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    mouse_instance                        Pointer to mouse instance     */
51
/*    mouse_x_position                      Current Mouse X Position      */
52
/*    mouse_y_position                      Current Mouse Y Position      */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    Completion Status                                                   */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    None                                                                */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    HID Mouse Class                                                     */
65
/*                                                                        */
66
/*  RELEASE HISTORY                                                       */
67
/*                                                                        */
68
/*    DATE              NAME                      DESCRIPTION             */
69
/*                                                                        */
70
/*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
71
/*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
72
/*                                            resulting in version 6.1    */
73
/*                                                                        */
74
/**************************************************************************/
75
81
UINT  _ux_host_class_hid_mouse_position_get(UX_HOST_CLASS_HID_MOUSE *mouse_instance,
76
                                            SLONG *mouse_x_position,
77
                                            SLONG *mouse_y_position)
78
{
79
80
UX_HOST_CLASS_HID   *hid;
81
82
    /* Get the HID class associated with the HID client. */
83
81
    hid = mouse_instance -> ux_host_class_hid_mouse_hid;
84
85
    /* Ensure the instance is valid.  */
86
81
    if (_ux_host_stack_class_instance_verify(_ux_system_host_class_hid_name, (VOID *) hid) != UX_SUCCESS)
87
    {
88
89
        /* Error trap. */
90
1
        _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_HOST_CLASS_INSTANCE_UNKNOWN);
91
92
        /* If trace is enabled, insert this event into the trace buffer.  */
93
        UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_INSTANCE_UNKNOWN, hid, 0, 0, UX_TRACE_ERRORS, 0, 0)
94
95
1
        return(UX_HOST_CLASS_INSTANCE_UNKNOWN);
96
    }
97
98
    /* Report the mouse X position.  */
99
80
    *mouse_x_position = mouse_instance -> ux_host_class_hid_mouse_x_position;
100
101
    /* Report the mouse Y position.  */
102
80
    *mouse_y_position = mouse_instance -> ux_host_class_hid_mouse_y_position;
103
104
    /* The status will tell the application there is something valid in the usage/value.  */
105
80
    return(UX_SUCCESS);
106
}
107
108
/**************************************************************************/
109
/*                                                                        */
110
/*  FUNCTION                                               RELEASE        */
111
/*                                                                        */
112
/*    _uxe_host_class_hid_mouse_position_get              PORTABLE C      */
113
/*                                                           6.3.0        */
114
/*  AUTHOR                                                                */
115
/*                                                                        */
116
/*    Chaoqiong Xiao, Microsoft Corporation                               */
117
/*                                                                        */
118
/*  DESCRIPTION                                                           */
119
/*                                                                        */
120
/*    This function checks errors in HID mouse position get function call.*/
121
/*                                                                        */
122
/*  INPUT                                                                 */
123
/*                                                                        */
124
/*    mouse_instance                        Pointer to mouse instance     */
125
/*    mouse_x_position                      Current Mouse X Position      */
126
/*    mouse_y_position                      Current Mouse Y Position      */
127
/*                                                                        */
128
/*  OUTPUT                                                                */
129
/*                                                                        */
130
/*    Status                                                              */
131
/*                                                                        */
132
/*  CALLS                                                                 */
133
/*                                                                        */
134
/*    _ux_host_class_hid_mouse_position_get Get mouse position            */
135
/*                                                                        */
136
/*  CALLED BY                                                             */
137
/*                                                                        */
138
/*    Application                                                         */
139
/*                                                                        */
140
/*  RELEASE HISTORY                                                       */
141
/*                                                                        */
142
/*    DATE              NAME                      DESCRIPTION             */
143
/*                                                                        */
144
/*  10-31-2023     Chaoqiong Xiao           Initial Version 6.3.0         */
145
/*                                                                        */
146
/**************************************************************************/
147
UINT  _uxe_host_class_hid_mouse_position_get(UX_HOST_CLASS_HID_MOUSE *mouse_instance,
148
                                            SLONG *mouse_x_position,
149
                                            SLONG *mouse_y_position)
150
{
151
152
    /* Sanity checks.  */
153
    if ((mouse_instance == UX_NULL) ||
154
        (mouse_x_position == UX_NULL) || (mouse_y_position == UX_NULL) ||
155
        (mouse_x_position == mouse_y_position))
156
    {
157
        return(UX_INVALID_PARAMETER);
158
    }
159
160
    /* Invoke position get function.  */
161
    return(_ux_host_class_hid_mouse_position_get(mouse_instance,
162
                                        mouse_x_position, mouse_y_position));
163
}