summaryrefslogtreecommitdiff
path: root/src/iobuffer.c
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-06-16 02:27:32 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-06-16 02:27:32 +0200
commitff88de5cd38b5b51bad0e63d373d66745f1f8d31 (patch)
tree3fbf4adc8c807bc79a8272c4df1623c3677a9b2f /src/iobuffer.c
parentad6faf6c53bc1924986e1cc10bb42e5d157cba8f (diff)
refactor: Move files
Move all headers into include, separate source files into modules match, mtdev, src and driver, move some common definitions to common.h, and include define support for the MT slot protocol. This patch does not introduce any logical changes. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/iobuffer.c')
-rw-r--r--src/iobuffer.c54
1 files changed, 0 insertions, 54 deletions
diff --git a/src/iobuffer.c b/src/iobuffer.c
deleted file mode 100644
index 35b61e9..0000000
--- a/src/iobuffer.c
+++ /dev/null
@@ -1,54 +0,0 @@
1/***************************************************************************
2 *
3 * Multitouch X driver
4 * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 **************************************************************************/
21
22#include "iobuffer.h"
23
24void init_iobuf(struct IOBuffer *buf)
25{
26 memset(buf, 0, sizeof(struct IOBuffer));
27 buf->at = buf->begin;
28 buf->top = buf->at;
29 buf->end = buf->begin + DIM_BUFFER;
30}
31
32const struct input_event *get_iobuf_event(struct IOBuffer *buf, int fd)
33{
34 const struct input_event *ev;
35 int n = buf->top - buf->at;
36 if (n < EVENT_SIZE) {
37 /* partial event is available: save it */
38 if (buf->at != buf->begin && n > 0)
39 memmove(buf->begin, buf->at, n);
40 /* start from the beginning */
41 buf->at = buf->begin;
42 buf->top = buf->at + n;
43 /* read more data */
44 SYSCALL(n = read(fd, buf->top, buf->end - buf->top));
45 if (n <= 0)
46 return NULL;
47 buf->top += n;
48 }
49 if (buf->top - buf->at < EVENT_SIZE)
50 return NULL;
51 ev = (const struct input_event *)buf->at;
52 buf->at += EVENT_SIZE;
53 return ev;
54}