summaryrefslogtreecommitdiff
path: root/include/mtstate.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/mtstate.h')
-rw-r--r--include/mtstate.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/include/mtstate.h b/include/mtstate.h
new file mode 100644
index 0000000..ac0b18d
--- /dev/null
+++ b/include/mtstate.h
@@ -0,0 +1,62 @@
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 MTSTATE_H
23#define MTSTATE_H
24
25#include "hwstate.h"
26
27struct MTFinger {
28 struct FingerData hw;
29 int id, thumb;
30};
31
32struct MTState {
33 struct MTFinger finger[DIM_FINGER];
34 int nfinger;
35 unsigned button;
36 mstime_t evtime;
37};
38
39void init_mtstate(struct MTState *s);
40void extract_mtstate(struct MTState *s,
41 const struct HWState *hs,
42 const struct Capabilities *caps);
43void output_mtstate(const struct MTState *s);
44
45const struct MTFinger *find_finger(const struct MTState *s, int id);
46
47
48static inline int center_dist2(const struct MTFinger *a,
49 const struct Capabilities *caps)
50{
51 return dist2(a->hw.position_x - get_cap_xmid(caps),
52 a->hw.position_y - get_cap_ymid(caps));
53}
54
55static inline int center_maxdist2(const struct Capabilities *caps)
56{
57 return dist2(caps->abs_position_x.maximum - get_cap_xmid(caps),
58 caps->abs_position_y.maximum - get_cap_ymid(caps));
59}
60
61#endif
62