GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usbx_host_classes/src/ux_host_class_hid_mouse_buttons_get.c Lines: 7 11 63.6 %
Date: 2024-12-12 17:16:36 Branches: 2 6 33.3 %

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_buttons_get                PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Chaoqiong Xiao, Microsoft Corporation                               */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function reads the mouse buttons  and reports it to the user.  */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    mouse_instance                        Pointer to mouse instance     */
50
/*    mouse_buttons                         Current Mouse Buttons         */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    Completion Status                                                   */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _ux_host_stack_class_instance_verify  Verify instance               */
59
/*                                                                        */
60
/*  CALLED BY                                                             */
61
/*                                                                        */
62
/*    HID Mouse Class                                                     */
63
/*                                                                        */
64
/*  RELEASE HISTORY                                                       */
65
/*                                                                        */
66
/*    DATE              NAME                      DESCRIPTION             */
67
/*                                                                        */
68
/*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
69
/*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
70
/*                                            resulting in version 6.1    */
71
/*                                                                        */
72
/**************************************************************************/
73
97
UINT  _ux_host_class_hid_mouse_buttons_get(UX_HOST_CLASS_HID_MOUSE *mouse_instance,
74
                                            ULONG *mouse_buttons)
75
{
76
77
UX_HOST_CLASS_HID   *hid;
78
79
    /* Get the HID class associated with the HID client. */
80
97
    hid = mouse_instance -> ux_host_class_hid_mouse_hid;
81
82
    /* Ensure the instance is valid.  */
83
97
    if (_ux_host_stack_class_instance_verify(_ux_system_host_class_hid_name, (VOID *) hid) != UX_SUCCESS)
84
    {
85
86
        /* Error trap. */
87
1
        _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_HOST_CLASS_INSTANCE_UNKNOWN);
88
89
        /* If trace is enabled, insert this event into the trace buffer.  */
90
        UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_INSTANCE_UNKNOWN, hid, 0, 0, UX_TRACE_ERRORS, 0, 0)
91
92
1
        return(UX_HOST_CLASS_INSTANCE_UNKNOWN);
93
    }
94
95
    /* Report the mouse buttons.  */
96
96
    *mouse_buttons = mouse_instance -> ux_host_class_hid_mouse_buttons;
97
98
    /* The status will tell the application there is something valid in the usage/value.  */
99
96
    return(UX_SUCCESS);
100
}
101
102
/**************************************************************************/
103
/*                                                                        */
104
/*  FUNCTION                                               RELEASE        */
105
/*                                                                        */
106
/*    _uxe_host_class_hid_mouse_buttons_get               PORTABLE C      */
107
/*                                                           6.3.0        */
108
/*  AUTHOR                                                                */
109
/*                                                                        */
110
/*    Chaoqiong Xiao, Microsoft Corporation                               */
111
/*                                                                        */
112
/*  DESCRIPTION                                                           */
113
/*                                                                        */
114
/*    This function checks errors in HID mouse buttons get function call. */
115
/*                                                                        */
116
/*  INPUT                                                                 */
117
/*                                                                        */
118
/*    mouse_instance                        Pointer to mouse instance     */
119
/*    mouse_buttons                         Current Mouse Buttons         */
120
/*                                                                        */
121
/*  OUTPUT                                                                */
122
/*                                                                        */
123
/*    Status                                                              */
124
/*                                                                        */
125
/*  CALLS                                                                 */
126
/*                                                                        */
127
/*    _ux_host_class_hid_mouse_buttons_get  Get mouse buttons             */
128
/*                                                                        */
129
/*  CALLED BY                                                             */
130
/*                                                                        */
131
/*    Application                                                         */
132
/*                                                                        */
133
/*  RELEASE HISTORY                                                       */
134
/*                                                                        */
135
/*    DATE              NAME                      DESCRIPTION             */
136
/*                                                                        */
137
/*  10-31-2023     Chaoqiong Xiao           Initial Version 6.3.0         */
138
/*                                                                        */
139
/**************************************************************************/
140
UINT  _uxe_host_class_hid_mouse_buttons_get(UX_HOST_CLASS_HID_MOUSE *mouse_instance,
141
                                            ULONG *mouse_buttons)
142
{
143
144
    /* Sanity checks.  */
145
    if ((mouse_instance == UX_NULL) || (mouse_buttons == UX_NULL))
146
        return(UX_INVALID_PARAMETER);
147
148
    /* Invoke mouse buttons get function.  */
149
    return(_ux_host_class_hid_mouse_buttons_get(mouse_instance, mouse_buttons));
150
151
}