| 1 | /*
|
|---|
| 2 | * SPDX-FileCopyrightText: 2010 Vojtech Horky
|
|---|
| 3 | *
|
|---|
| 4 | * SPDX-License-Identifier: BSD-3-Clause
|
|---|
| 5 | */
|
|---|
| 6 |
|
|---|
| 7 | /** @addtogroup libdrv
|
|---|
| 8 | * @{
|
|---|
| 9 | */
|
|---|
| 10 | /** @file
|
|---|
| 11 | * USB HID interface definition.
|
|---|
| 12 | */
|
|---|
| 13 |
|
|---|
| 14 | #ifndef LIBDRV_USBHID_IFACE_H_
|
|---|
| 15 | #define LIBDRV_USBHID_IFACE_H_
|
|---|
| 16 |
|
|---|
| 17 | #include "ddf/driver.h"
|
|---|
| 18 |
|
|---|
| 19 | extern errno_t usbhid_dev_get_event_length(async_sess_t *, size_t *);
|
|---|
| 20 | extern errno_t usbhid_dev_get_event(async_sess_t *, uint8_t *, size_t, size_t *,
|
|---|
| 21 | int *, unsigned int);
|
|---|
| 22 | extern errno_t usbhid_dev_get_report_descriptor_length(async_sess_t *, size_t *);
|
|---|
| 23 | extern errno_t usbhid_dev_get_report_descriptor(async_sess_t *, uint8_t *, size_t,
|
|---|
| 24 | size_t *);
|
|---|
| 25 |
|
|---|
| 26 | /** USB HID device communication interface. */
|
|---|
| 27 | typedef struct {
|
|---|
| 28 | /** Get size of the event in bytes.
|
|---|
| 29 | *
|
|---|
| 30 | * @param[in] fun DDF function answering the request.
|
|---|
| 31 | * @return Size of the event in bytes.
|
|---|
| 32 | */
|
|---|
| 33 | size_t (*get_event_length)(ddf_fun_t *fun);
|
|---|
| 34 |
|
|---|
| 35 | /** Get single event from the HID device.
|
|---|
| 36 | *
|
|---|
| 37 | * @param[in] fun DDF function answering the request.
|
|---|
| 38 | * @param[out] buffer Buffer with raw data from the device.
|
|---|
| 39 | * @param[out] act_size Actual number of returned events.
|
|---|
| 40 | * @param[in] flags Flags (see USBHID_IFACE_FLAG_*).
|
|---|
| 41 | * @return Error code.
|
|---|
| 42 | */
|
|---|
| 43 | errno_t (*get_event)(ddf_fun_t *fun, uint8_t *buffer, size_t size,
|
|---|
| 44 | size_t *act_size, int *event_nr, unsigned int flags);
|
|---|
| 45 |
|
|---|
| 46 | /** Get size of the report descriptor in bytes.
|
|---|
| 47 | *
|
|---|
| 48 | * @param[in] fun DDF function answering the request.
|
|---|
| 49 | * @return Size of the report descriptor in bytes.
|
|---|
| 50 | */
|
|---|
| 51 | size_t (*get_report_descriptor_length)(ddf_fun_t *fun);
|
|---|
| 52 |
|
|---|
| 53 | /** Get the report descriptor from the HID device.
|
|---|
| 54 | *
|
|---|
| 55 | * @param[in] fun DDF function answering the request.
|
|---|
| 56 | * @param[out] desc Buffer with the report descriptor.
|
|---|
| 57 | * @param[in] size Size of the allocated @p desc buffer.
|
|---|
| 58 | * @param[out] act_size Actual size of the report descriptor returned.
|
|---|
| 59 | * @return Error code.
|
|---|
| 60 | */
|
|---|
| 61 | errno_t (*get_report_descriptor)(ddf_fun_t *fun, uint8_t *desc,
|
|---|
| 62 | size_t size, size_t *act_size);
|
|---|
| 63 | } usbhid_iface_t;
|
|---|
| 64 |
|
|---|
| 65 | #endif
|
|---|
| 66 | /**
|
|---|
| 67 | * @}
|
|---|
| 68 | */
|
|---|