Monado OpenXR Runtime
opengloves_communication.h
Go to the documentation of this file.
1// Copyright 2019-2022, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Communication structures for OpenGloves
6 * @author Daniel Willmott <web@dan-w.com>
7 * @ingroup drv_opengloves
8 */
9
10#pragma once
11#include <stdint.h>
12#include <stddef.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18/*!
19 * @interface opengloves_communication_device
20 *
21 * Interface for a communication method
22 *
23 * @ingroup drv_opengloves
24 */
26{
27 int (*read)(struct opengloves_communication_device *comm_dev, char *data, size_t size);
28
29 int (*write)(struct opengloves_communication_device *comm_dev, const char *data, size_t size);
30
31 void (*destroy)(struct opengloves_communication_device *comm_dev);
32};
33
34static inline int
35opengloves_communication_device_read(struct opengloves_communication_device *comm_dev, char *data, size_t size)
36{
37 return comm_dev->read(comm_dev, data, size);
38}
39
40static inline int
41opengloves_communication_device_write(struct opengloves_communication_device *comm_dev, const char *data, size_t size)
42{
43 return comm_dev->write(comm_dev, data, size);
44}
45
46
47static inline void
48opengloves_communication_device_destory(struct opengloves_communication_device *comm_dev)
49{
50 comm_dev->destroy(comm_dev);
51}
52
53
54#ifdef __cplusplus
55}
56#endif
Interface for a communication method.
Definition: opengloves_communication.h:26