source: mainline/uspace/lib/drv/include/usbhid_iface.h@ 27b85d9

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

Add USB HID interface

  • 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 libdrv
30 * @{
31 */
32/** @file
33 * USB HID interface definition.
34 */
35
36#ifndef LIBDRV_USBHID_IFACE_H_
37#define LIBDRV_USBHID_IFACE_H_
38
39#include "ddf/driver.h"
40#include <usb/usb.h>
41
42/** IPC methods for USB HID device interface. */
43typedef enum {
44 /** Get number of events reported in single burst.
45 * Parameters: none
46 * Answer:
47 * - EOK (expected always as long as device support USB HID interface)
48 * Parameters of the answer:
49 * - number of items
50 */
51 IPC_M_USBHID_GET_EVENT_LENGTH,
52 /** Get single event from the HID device.
53 * The word single refers to set of individual events that were
54 * available at particular point in time.
55 * Parameters:
56 * - flags
57 * The call is followed by data read expecting two concatenated
58 * arrays.
59 * Answer:
60 * - EOK - events returned
61 * - EAGAIN - no event ready (only in non-blocking mode)
62 *
63 * It is okay if the client requests less data. Extra data must
64 * be truncated by the driver.
65 */
66 IPC_M_USBHID_GET_EVENT
67} usbhid_iface_funcs_t;
68
69/** USB HID interface flag - return immediately if no data are available. */
70#define USBHID_IFACE_FLAG_NON_BLOCKING (1 << 0)
71
72/** USB HID device communication interface. */
73typedef struct {
74 /** Get number of items in the event.
75 *
76 * @param[in] fun DDF function answering the request.
77 * @return Number of events or error code.
78 */
79 int (*get_event_length)(ddf_fun_t *fun);
80
81 /** Get single event from the HID device.
82 *
83 * @param[in] fun DDF function answering the request.
84 * @param[out] usage_page Array of usage pages and usages.
85 * @param[out] usage Array of data (1:1 with @p usage).
86 * @param[in] size Size of @p usage and @p data arrays.
87 * @param[out] act_size Actual number of returned events.
88 * @param[in] flags Flags (see USBHID_IFACE_FLAG_*).
89 * @return Error code.
90 */
91 int (*get_event)(ddf_fun_t *fun,
92 uint16_t *usage_page, uint16_t *usage, size_t size, size_t *act_size,
93 unsigned int flags);
94} usbhid_iface_t;
95
96
97#endif
98/**
99 * @}
100 */
Note: See TracBrowser for help on using the repository browser.