source: mainline/uspace/app/virtusbkbd/kbdconfig.c@ 0a9ea4a

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 0a9ea4a was 4b4c797, checked in by Vojtech Horky <vojtechhorky@…>, 15 years ago

Directory structure reorganization

USB class-specific headers are in separate directory.

Removed unused/unreachable code.

  • Property mode set to 100644
File size: 4.7 KB
Line 
1/*
2 * Copyright (c) 2010 Vojtech Horky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup usb
30 * @{
31 */
32/**
33 * @file
34 * @brief Keyboard configuration.
35 */
36#include "kbdconfig.h"
37#include "keys.h"
38#include <usb/usb.h>
39#include <usb/classes/hid.h>
40#include <usb/classes/hidut.h>
41#include <usb/classes/classes.h>
42
43/** Standard device descriptor. */
44usb_standard_device_descriptor_t std_device_descriptor = {
45 .length = sizeof(usb_standard_device_descriptor_t),
46 .descriptor_type = USB_DESCTYPE_DEVICE,
47 .usb_spec_version = 0x110,
48 .device_class = USB_CLASS_USE_INTERFACE,
49 .device_subclass = 0,
50 .device_protocol = 0,
51 .max_packet_size = 64,
52 .configuration_count = 1
53};
54
55/** Standard interface descriptor. */
56usb_standard_interface_descriptor_t std_interface_descriptor = {
57 .length = sizeof(usb_standard_interface_descriptor_t),
58 .descriptor_type = USB_DESCTYPE_INTERFACE,
59 .interface_number = 0,
60 .alternate_setting = 0,
61 .endpoint_count = 1,
62 .interface_class = USB_CLASS_HID,
63 .interface_subclass = 0,
64 .interface_protocol = USB_HID_PROTOCOL_KEYBOARD,
65 .str_interface = 0
66};
67
68/** USB keyboard report descriptor.
69 * Copied from USB HID 1.11 (section E.6).
70 */
71report_descriptor_data_t report_descriptor = {
72 STD_USAGE_PAGE(USB_HIDUT_PAGE_GENERIC_DESKTOP),
73 USAGE1(USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYBOARD),
74 START_COLLECTION(COLLECTION_APPLICATION),
75 STD_USAGE_PAGE(USB_HIDUT_PAGE_KEYBOARD),
76 USAGE_MINIMUM1(224),
77 USAGE_MAXIMUM1(231),
78 LOGICAL_MINIMUM1(0),
79 LOGICAL_MAXIMUM1(1),
80 REPORT_SIZE1(1),
81 REPORT_COUNT1(8),
82 /* Modifiers */
83 INPUT(IOF_DATA | IOF_VARIABLE | IOF_ABSOLUTE),
84 REPORT_COUNT1(1),
85 REPORT_SIZE1(8),
86 /* Reserved */
87 INPUT(IOF_CONSTANT),
88 REPORT_COUNT1(5),
89 REPORT_SIZE1(1),
90 STD_USAGE_PAGE(USB_HIDUT_PAGE_LED),
91 USAGE_MINIMUM1(1),
92 USAGE_MAXIMUM1(5),
93 /* LED states */
94 OUTPUT(IOF_DATA | IOF_VARIABLE | IOF_ABSOLUTE),
95 REPORT_COUNT1(1),
96 REPORT_SIZE1(3),
97 /* LED states padding */
98 OUTPUT(IOF_CONSTANT),
99 REPORT_COUNT1(KB_MAX_KEYS_AT_ONCE),
100 REPORT_SIZE1(8),
101 LOGICAL_MINIMUM1(0),
102 LOGICAL_MAXIMUM1(101),
103 STD_USAGE_PAGE(USB_HIDUT_PAGE_KEYBOARD),
104 USAGE_MINIMUM1(0),
105 USAGE_MAXIMUM1(101),
106 /* Key array */
107 INPUT(IOF_DATA | IOF_ARRAY),
108 END_COLLECTION()
109};
110size_t report_descriptor_size = sizeof(report_descriptor);
111
112/** HID descriptor. */
113hid_descriptor_t hid_descriptor = {
114 .length = sizeof(hid_descriptor_t),
115 .type = 0x21, // HID descriptor
116 .hid_spec_release = 0x101,
117 .country_code = 0,
118 .descriptor_count = 1,
119 .descriptor1_type = 0x22, // Report descriptor
120 .descriptor1_length = sizeof(report_descriptor)
121};
122
123/** Endpoint descriptor. */
124usb_standard_endpoint_descriptor_t endpoint_descriptor = {
125 .length = sizeof(usb_standard_endpoint_descriptor_t),
126 .descriptor_type = USB_DESCTYPE_ENDPOINT,
127 .endpoint_address = 1 | 128,
128 .attributes = USB_TRANSFER_INTERRUPT,
129 .max_packet_size = 8,
130 .poll_interval = 10
131};
132
133/** Standard configuration descriptor. */
134usb_standard_configuration_descriptor_t std_configuration_descriptor = {
135 .length = sizeof(usb_standard_configuration_descriptor_t),
136 .descriptor_type = USB_DESCTYPE_CONFIGURATION,
137 .total_length =
138 sizeof(usb_standard_configuration_descriptor_t)
139 + sizeof(std_interface_descriptor)
140 + sizeof(hid_descriptor)
141 + sizeof(endpoint_descriptor)
142 ,
143 .interface_count = 1,
144 .configuration_number = 1,
145 .str_configuration = 0,
146 .attributes = 128, /* denotes bus-powered device */
147 .max_power = 50
148};
149
150
151
152
153
154/** @}
155 */
Note: See TracBrowser for help on using the repository browser.