source: mainline/uspace/app/vuhid/virthid.h@ 57c7050

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

Generic virtual USB HID device application

The application works (more or less) as a boot keyboard.

The code needs a lot of refactoring. That will be done later.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 * Copyright (c) 2011 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 usbvirthid
30 * @{
31 */
32/** @file
33 *
34 */
35#ifndef VUHID_VIRTHID_H_
36#define VUHID_VIRTHID_H_
37
38#include <usb/usb.h>
39#include <usbvirt/device.h>
40
41#define VUHID_ENDPOINT_MAX USB11_ENDPOINT_MAX
42#define VUHID_INTERFACE_MAX 8
43
44typedef struct vuhid_interface vuhid_interface_t;
45
46struct vuhid_interface {
47 const char *name;
48 const char *id;
49 int usb_subclass;
50 int usb_protocol;
51
52 uint8_t *report_descriptor;
53 size_t report_descriptor_size;
54
55 size_t in_data_size;
56 size_t out_data_size;
57
58 int (*on_data_in)(vuhid_interface_t *, void *, size_t, size_t *);
59 int (*on_data_out)(vuhid_interface_t *, void *, size_t);
60 void (*live)(vuhid_interface_t *);
61
62 int set_protocol;
63
64 void *interface_data;
65};
66
67typedef struct {
68 vuhid_interface_t *in_endpoints_mapping[VUHID_ENDPOINT_MAX];
69 size_t in_endpoint_first_free;
70 vuhid_interface_t *out_endpoints_mapping[VUHID_ENDPOINT_MAX];
71 size_t out_endpoint_first_free;
72 vuhid_interface_t *interface_mapping[VUHID_INTERFACE_MAX];
73} vuhid_data_t;
74
75typedef struct {
76 uint8_t length;
77 uint8_t type;
78 uint16_t hid_spec_release;
79 uint8_t country_code;
80 uint8_t descriptor_count;
81 uint8_t descriptor1_type;
82 uint16_t descriptor1_length;
83} __attribute__ ((packed)) hid_descriptor_t;
84
85int add_interface_by_id(vuhid_interface_t **, const char *, usbvirt_device_t *);
86
87#endif
88/**
89 * @}
90 */
Note: See TracBrowser for help on using the repository browser.