summaryrefslogtreecommitdiff
path: root/src/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h95
1 files changed, 0 insertions, 95 deletions
diff --git a/src/common.h b/src/common.h
deleted file mode 100644
index 32be48d..0000000
--- a/src/common.h
+++ /dev/null
@@ -1,95 +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#ifndef COMMON_H
23#define COMMON_H
24
25#include "xorg-server.h"
26#include <xf86.h>
27#include <xf86_OSproc.h>
28#include <xf86Xinput.h>
29#include <linux/input.h>
30#include <errno.h>
31#include <match/match.h>
32
33/* includes available in 2.6.30-rc5 */
34
35#ifndef BTN_TOOL_QUADTAP
36#define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */
37#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */
38#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */
39#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */
40#define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */
41#define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */
42#define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */
43#define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */
44#define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */
45#define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */
46#define SYN_MT_REPORT 2
47#define MT_TOOL_FINGER 0
48#define MT_TOOL_PEN 1
49#endif
50
51/* includes available in 2.6.33 */
52#ifndef ABS_MT_PRESSURE
53#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */
54#endif
55
56#define SYSCALL(call) while (((call) == -1) && (errno == EINTR))
57
58#define BITMASK(x) (1U << (x))
59#define BITONES(x) (BITMASK(x) - 1U)
60#define GETBIT(m, x) (((m) >> (x)) & 1U)
61#define SETBIT(m, x) (m |= BITMASK(x))
62#define CLEARBIT(m, x) (m &= ~BITMASK(x))
63
64static inline int maxval(int x, int y) { return x > y ? x : y; }
65static inline int minval(int x, int y) { return x < y ? x : y; }
66
67static inline int clamp15(int x)
68{
69 return x < -32767 ? -32767 : x > 32767 ? 32767 : x;
70}
71
72/* absolute scale is assumed to fit in 15 bits */
73static inline int dist2(int dx, int dy)
74{
75 dx = clamp15(dx);
76 dy = clamp15(dy);
77 return dx * dx + dy * dy;
78}
79
80/* Count number of bits (Sean Eron Andersson's Bit Hacks) */
81static inline int bitcount(unsigned v)
82{
83 v -= ((v>>1) & 0x55555555);
84 v = (v&0x33333333) + ((v>>2) & 0x33333333);
85 return (((v + (v>>4)) & 0xF0F0F0F) * 0x1010101) >> 24;
86}
87
88/* Return index of first bit [0-31], -1 on zero */
89#define firstbit(v) (__builtin_ffs(v) - 1)
90
91/* boost-style foreach bit */
92#define foreach_bit(i, m) \
93 for (i = firstbit(m); i >= 0; i = firstbit((m) & (~0U << i + 1)))
94
95#endif