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

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

Added structures for HID descriptor.

  • Property mode set to 100644
File size: 3.4 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
42/** USB/HID device requests. */
43typedef enum {
44 USB_HIDREQ_GET_REPORT = 1,
45 USB_HIDREQ_GET_IDLE = 2,
46 USB_HIDREQ_GET_PROTOCOL = 3,
47 /* Values 4 to 8 are reserved. */
48 USB_HIDREQ_SET_REPORT = 9,
49 USB_HIDREQ_SET_IDLE = 10,
50 USB_HIDREQ_SET_PROTOCOL = 11
51} usb_hid_request_t;
52
53/** USB/HID interface protocols. */
54typedef enum {
55 USB_HID_PROTOCOL_NONE = 0,
56 USB_HID_PROTOCOL_KEYBOARD = 1,
57 USB_HID_PROTOCOL_MOUSE = 2
58} usb_hid_protocol_t;
59
60/** Part of standard USB HID descriptor specifying one class descriptor.
61 *
62 * (See HID Specification, p.22)
63 */
64typedef struct {
65 /** Type of class descriptor (Report or Physical). */
66 uint8_t class_descriptor_type;
67 /** Length of class descriptor. */
68 uint16_t class_descriptor_length;
69} __attribute__ ((packed)) usb_standard_hid_descriptor_class_item_t;
70
71/** Standard USB HID descriptor.
72 *
73 * (See HID Specification, p.22)
74 *
75 * It is actually only the "header" of the descriptor, as it may have arbitrary
76 * length if more than one class descritor is provided.
77 */
78typedef struct {
79 /** Size of this descriptor in bytes. */
80 uint8_t length;
81 /** Descriptor type (USB_DESCTYPE_HID). */
82 uint8_t descriptor_type;
83 /** HID Class Specification release. */
84 uint16_t spec_release;
85 /** Country code of localized hardware. */
86 uint8_t country_code;
87 /** Total number of class (i.e. Report and Physical) descriptors. */
88 uint8_t class_count;
89 /** First mandatory class descriptor info. */
90 usb_standard_hid_descriptor_class_item_t class_descriptor;
91} __attribute__ ((packed)) usb_standard_hid_descriptor_t;
92
93
94/**
95 * @brief USB/HID keyboard device type.
96 *
97 * Quite dummy right now.
98 */
99typedef struct {
100 device_t *device;
101 usb_address_t address;
102 usb_endpoint_t default_ep;
103 usb_hid_report_parser_t *parser;
104} usb_hid_dev_kbd_t;
105
106#endif
107/**
108 * @}
109 */
Note: See TracBrowser for help on using the repository browser.