1
/*****************************************************************************
3
* grail - Gesture Recognition And Instantiation Library
5
* Copyright (C) 2010-2012 Canonical Ltd.
7
* This library is free software: you can redistribute it and/or modify it
8
* under the terms of the GNU Lesser General Public License version 3
9
* as published by the Free Software Foundation.
11
* This library is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranties of
13
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14
* PURPOSE. See the GNU Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this library. If not, see <http://www.gnu.org/licenses/>.
19
****************************************************************************/
24
#define DIM_EVENTS 4096
29
struct input_event buffer[DIM_EVENTS];
32
static inline void evbuf_clear(struct evbuf *evbuf)
34
evbuf->head = evbuf->tail = 0;
37
static inline int evbuf_empty(const struct evbuf *evbuf)
39
return evbuf->head == evbuf->tail;
42
static inline void evbuf_put(struct evbuf *evbuf,
43
const struct input_event *ev)
45
evbuf->buffer[evbuf->head++] = *ev;
46
evbuf->head &= DIM_EVENTS - 1;
49
static inline void evbuf_get(struct evbuf *evbuf,
50
struct input_event *ev)
52
*ev = evbuf->buffer[evbuf->tail++];
53
evbuf->tail &= DIM_EVENTS - 1;