blob: 4f7e8c0793eb3bffdd09ef7f4b6092095ac05f45 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
* Copyright (c) 2026-present Eclipse ThreadX contributors
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** HID Keyboard Client */
/** */
/**************************************************************************/
/**************************************************************************/
/* Include necessary system files. */
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_host_class_hid.h"
#include "ux_host_class_hid_keyboard.h"
#include "ux_host_stack.h"
#if defined(UX_HOST_STANDALONE)
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_hid_keyboard_tasks_run PORTABLE C */
/* 6.2.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This file contains the keyboard tasks used to process the changes */
/* in the keyboard LEDs. */
/* */
/* It's for standalone mode. */
/* */
/* INPUT */
/* */
/* client The keyboard client */
/* */
/* OUTPUT */
/* */
/* None */
/* */
/* CALLS */
/* */
/* _ux_host_class_hid_report_id_get Get report ID */
/* _ux_host_class_hid_report_set Do SET_REPORT */
/* */
/* CALLED BY */
/* */
/* USBX Host HID */
/* */
/**************************************************************************/
VOID _ux_host_class_hid_keyboard_tasks_run(UX_HOST_CLASS_HID_CLIENT *client)
{
UX_HOST_CLASS_HID_KEYBOARD *keyboard;
UX_HOST_CLASS_HID *hid;
UX_HOST_CLASS_HID_CLIENT_REPORT client_report;
UX_HOST_CLASS_HID_REPORT_GET_ID report_id;
UINT status;
/* Sanity check. */
if (client == UX_NULL)
return;
/* Get keyboard instance. */
keyboard = (UX_HOST_CLASS_HID_KEYBOARD *)client -> ux_host_class_hid_client_local_instance;
if (keyboard == UX_NULL)
return;
/* Get HID instance. */
hid = keyboard -> ux_host_class_hid_keyboard_hid;
if (hid == UX_NULL)
return;
/* Check if there is pending chnages. */
if (keyboard -> ux_host_class_hid_keyboard_out_state != UX_STATE_WAIT)
return;
/* We got awaken by the keyboard callback which indicates a change on
the LEDs has to happen. We need to build the field for the LEDs. */
keyboard -> ux_host_class_hid_keyboard_led_mask =
keyboard -> ux_host_class_hid_keyboard_alternate_key_state &
UX_HID_KEYBOARD_STATE_MASK_LOCK;
/* We need to find the OUTPUT report for the keyboard LEDs. */
if (keyboard -> ux_host_class_hid_keyboard_out_report == UX_NULL)
{
report_id.ux_host_class_hid_report_get_report = UX_NULL;
report_id.ux_host_class_hid_report_get_type = UX_HOST_CLASS_HID_REPORT_TYPE_OUTPUT;
status = _ux_host_class_hid_report_id_get(hid, &report_id);
if (status != UX_SUCCESS)
{
keyboard -> ux_host_class_hid_keyboard_status = status;
return;
}
keyboard -> ux_host_class_hid_keyboard_out_report = report_id.ux_host_class_hid_report_get_report;
}
/* Build a RAW client report. */
client_report.ux_host_class_hid_client_report = keyboard -> ux_host_class_hid_keyboard_out_report;
client_report.ux_host_class_hid_client_report_flags = UX_HOST_CLASS_HID_REPORT_RAW;
client_report.ux_host_class_hid_client_report_length = 1;
client_report.ux_host_class_hid_client_report_buffer = &keyboard -> ux_host_class_hid_keyboard_led_mask;
/* The HID class will perform the SET_REPORT command. */
status = _ux_host_class_hid_report_set_run(hid, &client_report);
if (status < UX_STATE_WAIT)
{
/* Update status. */
keyboard -> ux_host_class_hid_keyboard_status = hid -> ux_host_class_hid_status;
/* The change is processed. */
keyboard -> ux_host_class_hid_keyboard_out_state = UX_STATE_IDLE;
}
}
#endif
|