Add log func handling
[platform/upstream/libevdev.git] / libevdev / libevdev-int.h
1 /*
2  * Copyright © 2013 Red Hat, Inc.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and its
5  * documentation for any purpose is hereby granted without fee, provided that
6  * the above copyright notice appear in all copies and that both that copyright
7  * notice and this permission notice appear in supporting documentation, and
8  * that the name of the copyright holders not be used in advertising or
9  * publicity pertaining to distribution of the software without specific,
10  * written prior permission.  The copyright holders make no representations
11  * about the suitability of this software for any purpose.  It is provided "as
12  * is" without express or implied warranty.
13  *
14  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20  * OF THIS SOFTWARE.
21  */
22
23 #ifndef libevdev_INT_H
24 #define libevdev_INT_H
25
26 #include <config.h>
27 #include "libevdev.h"
28
29 #define LONG_BITS (sizeof(long) * 8)
30 #define NLONGS(x) (((x) + LONG_BITS - 1) / LONG_BITS)
31 #define ARRAY_LENGTH(a) (sizeof(a) / (sizeof((a)[0])))
32 #define MAX_NAME 256
33 #define MAX_SLOTS 32
34 #define ABS_MT_MIN ABS_MT_SLOT
35 #define ABS_MT_MAX ABS_MT_TOOL_Y
36 #define ABS_MT_CNT (ABS_MT_MAX - ABS_MT_MIN + 1)
37
38 struct libevdev {
39         int fd;
40         libevdev_callback_proc callback;
41         libevdev_callback_proc sync_callback;
42         void *userdata;
43
44         libevdev_log_func_t log;
45
46         char name[MAX_NAME];
47         struct input_id ids;
48         unsigned long bits[NLONGS(EV_CNT)];
49         unsigned long props[NLONGS(INPUT_PROP_CNT)];
50         unsigned long key_bits[NLONGS(KEY_CNT)];
51         unsigned long rel_bits[NLONGS(REL_CNT)];
52         unsigned long abs_bits[NLONGS(ABS_CNT)];
53         unsigned long led_bits[NLONGS(LED_CNT)];
54         unsigned long key_values[NLONGS(KEY_CNT)];
55         struct input_absinfo abs_info[ABS_CNT];
56         unsigned int mt_slot_vals[MAX_SLOTS][ABS_MT_CNT];
57         int num_slots; /**< valid slots in mt_slot_vals */
58
59         int need_sync;
60         int grabbed;
61
62         struct input_event *queue;
63         size_t queue_size; /**< size of queue in elements */
64         size_t queue_next; /**< next event index */
65 };
66
67 #endif
68