summaryrefslogtreecommitdiff
path: root/src/mtdev-plumbing.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mtdev-plumbing.h')
-rw-r--r--src/mtdev-plumbing.h105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/mtdev-plumbing.h b/src/mtdev-plumbing.h
new file mode 100644
index 0000000..c1d141e
--- /dev/null
+++ b/src/mtdev-plumbing.h
@@ -0,0 +1,105 @@
1/*****************************************************************************
2 *
3 * mtdev - Multitouch Protocol Translation Library (MIT license)
4 *
5 * Copyright (C) 2010 Henrik Rydberg <rydberg@bitmath.org>
6 * Copyright (C) 2010 Canonical Ltd.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice (including the next
16 * paragraph) shall be included in all copies or substantial portions of the
17 * Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 * DEALINGS IN THE SOFTWARE.
26 *
27 ****************************************************************************/
28
29#ifndef _MTDEV_PLUMBING_H
30#define _MTDEV_PLUMBING_H
31
32#include <mtdev.h>
33
34/**
35 * mtdev_init - initialize mtdev converter
36 * @dev: the mtdev to initialize
37 *
38 * Sets up the internal data structures.
39 *
40 * Returns zero on success, negative error number otherwise.
41 */
42int mtdev_init(struct mtdev *dev);
43
44/**
45 * mtdev_configure - configure the mtdev converter
46 * @dev: the mtdev to configure
47 * @fd: file descriptor of the kernel device
48 *
49 * Reads the device properties to set up the protocol capabilities.
50 * If preferred, this can be done by hand, omitting this call.
51 *
52 * Returns zero on success, negative error number otherwise.
53 */
54int mtdev_configure(struct mtdev *dev, int fd);
55
56/**
57 * mtdev_fetch_event - fetch an event from the kernel device
58 * @dev: the mtdev in use
59 * @fd: file descriptor of the kernel device
60 * @ev: the kernel input event to fill
61 *
62 * Fetch a kernel event from the kernel device. The read operation
63 * behaves as dictated by the file descriptor; if O_NONBLOCK is not
64 * set, the read will block until an event is available.
65 *
66 * On success, returns the number of events read (0 or 1). Otherwise,
67 * a standard negative error number is returned.
68 */
69int mtdev_fetch_event(struct mtdev *dev, int fd, struct input_event *ev);
70
71/**
72 * mtdev_put_event - put an event into the converter
73 * @dev: the mtdev in use
74 * @ev: the kernel input event to put
75 *
76 * Put a kernel event into the mtdev converter. The event should
77 * come straight from the device.
78 *
79 * This call does not block; if the buffer becomes full, older events
80 * are dropped. The buffer is guaranteed to handle several complete MT
81 * packets.
82 */
83void mtdev_put_event(struct mtdev *dev, const struct input_event *ev);
84
85/**
86 * mtdev_empty - check if there are events to get
87 * @dev: the mtdev in use
88 *
89 * Returns true if the processed event queue is empty, false otherwise.
90 */
91int mtdev_empty(struct mtdev *dev);
92
93/**
94 * mtdev_get_event - get processed events from mtdev
95 * @dev: the mtdev in use
96 * @ev: the input event to fill
97 *
98 * Get a processed event from mtdev. The events appear as if they came
99 * from a type B device emitting MT slot events.
100 *
101 * The queue must be non-empty before calling this function.
102 */
103void mtdev_get_event(struct mtdev *dev, struct input_event* ev);
104
105#endif