source: mainline/uspace/lib/usb/include/usb/classes/hid.h@ 6986418

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 6986418 was 6986418, checked in by Lubos Slovak <lubos.slovak@…>, 15 years ago

Descriptor parsing modified (fixed)

  • change usbkbd_parse_descriptors() not to parse class-specific descriptors as these are retrieved differently
  • dump functions moved to descdump.h/c
  • getting report descriptor in usbkbd/main.c
  • changed descriptor structures (hid.h) to reflect, that there is only one report descriptor
  • Property mode set to 100644
File size: 4.1 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 libusb usb
30 * @{
31 */
32/** @file
33 * @brief USB HID device related types.
34 */
35#ifndef LIBUSB_HID_H_
36#define LIBUSB_HID_H_
37
38#include <usb/usb.h>
39#include <driver.h>
40#include <usb/classes/hidparser.h>
41#include <usb/descriptor.h>
42
43/** USB/HID device requests. */
44typedef enum {
45 USB_HIDREQ_GET_REPORT = 1,
46 USB_HIDREQ_GET_IDLE = 2,
47 USB_HIDREQ_GET_PROTOCOL = 3,
48 /* Values 4 to 8 are reserved. */
49 USB_HIDREQ_SET_REPORT = 9,
50 USB_HIDREQ_SET_IDLE = 10,
51 USB_HIDREQ_SET_PROTOCOL = 11
52} usb_hid_request_t;
53
54/** USB/HID interface protocols. */
55typedef enum {
56 USB_HID_PROTOCOL_NONE = 0,
57 USB_HID_PROTOCOL_KEYBOARD = 1,
58 USB_HID_PROTOCOL_MOUSE = 2
59} usb_hid_protocol_t;
60
61/** Part of standard USB HID descriptor specifying one class descriptor.
62 *
63 * (See HID Specification, p.22)
64 */
65typedef struct {
66 /** Type of class-specific descriptor (Report or Physical). */
67 uint8_t type;
68 /** Length of class-specific descriptor in bytes. */
69 uint16_t length;
70} __attribute__ ((packed)) usb_standard_hid_class_descriptor_info_t;
71
72/** Standard USB HID descriptor.
73 *
74 * (See HID Specification, p.22)
75 *
76 * It is actually only the "header" of the descriptor, it does not contain
77 * the last two mandatory fields (type and length of the first class-specific
78 * descriptor).
79 */
80typedef struct {
81 /** Total size of this descriptor in bytes.
82 *
83 * This includes all class-specific descriptor info - type + length
84 * for each descriptor.
85 */
86 uint8_t length;
87 /** Descriptor type (USB_DESCTYPE_HID). */
88 uint8_t descriptor_type;
89 /** HID Class Specification release. */
90 uint16_t spec_release;
91 /** Country code of localized hardware. */
92 uint8_t country_code;
93 /** Total number of class-specific (i.e. Report and Physical)
94 * descriptors.
95 *
96 * @note There is always only one Report descriptor.
97 */
98 uint8_t class_desc_count;
99 /** First mandatory class descriptor (Report) info. */
100 usb_standard_hid_descriptor_class_item_t report_desc_info;
101} __attribute__ ((packed)) usb_standard_hid_descriptor_t;
102
103/**
104 *
105 */
106typedef struct {
107 usb_standard_interface_descriptor_t iface_desc;
108 usb_standard_endpoint_descriptor_t *endpoints;
109 usb_standard_hid_descriptor_t hid_desc;
110 uint8_t *report_desc;
111 //usb_standard_hid_class_descriptor_info_t *class_desc_info;
112 //uint8_t **class_descs;
113} usb_hid_iface_t;
114
115/**
116 *
117 */
118typedef struct {
119 usb_standard_configuration_descriptor_t config_descriptor;
120 usb_hid_iface_t *interfaces;
121} usb_hid_configuration_t;
122
123/**
124 * @brief USB/HID keyboard device type.
125 *
126 * Quite dummy right now.
127 */
128typedef struct {
129 device_t *device;
130 usb_hid_configuration_t *conf;
131 usb_address_t address;
132 usb_endpoint_t poll_endpoint;
133 usb_hid_report_parser_t *parser;
134} usb_hid_dev_kbd_t;
135
136// TODO: more configurations!
137
138#endif
139/**
140 * @}
141 */
Note: See TracBrowser for help on using the repository browser.