aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-05-14 01:15:14 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-05-14 01:41:39 +0200
commit8ced3667a30e00bd2368d4b5417f1f07cc86d290 (patch)
tree57137593f90a29c5ac9039fc1aebcde1158f01cb
parentebaf307ab1b22d4786cc5fb55170204759e887ce (diff)
downloadxorg-input-kobomultitouch-8ced3667a30e00bd2368d4b5417f1f07cc86d290.tar.gz
xorg-input-kobomultitouch-8ced3667a30e00bd2368d4b5417f1f07cc86d290.tar.bz2
xorg-input-kobomultitouch-8ced3667a30e00bd2368d4b5417f1f07cc86d290.zip
Add convenience methods for distance to capability center point
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r--src/capabilities.c10
-rw-r--r--src/capabilities.h3
-rw-r--r--src/mtstate.h14
3 files changed, 27 insertions, 0 deletions
diff --git a/src/capabilities.c b/src/capabilities.c
index 9879ddf..cd96e8e 100644
--- a/src/capabilities.c
+++ b/src/capabilities.c
@@ -128,6 +128,16 @@ int get_cap_wsize(const struct Capabilities *cap)
return cap->abs_touch_major.maximum - cap->abs_touch_major.minimum;
}
+int get_cap_xmid(const struct Capabilities *cap)
+{
+ return (cap->abs_position_x.maximum + cap->abs_position_x.minimum) >> 1;
+}
+
+int get_cap_ymid(const struct Capabilities *cap)
+{
+ return (cap->abs_position_y.maximum + cap->abs_position_y.minimum) >> 1;
+}
+
void output_capabilities(const struct Capabilities *cap)
{
char line[1024];
diff --git a/src/capabilities.h b/src/capabilities.h
index 402d297..23086bd 100644
--- a/src/capabilities.h
+++ b/src/capabilities.h
@@ -49,6 +49,9 @@ int get_cap_xsize(const struct Capabilities *cap);
int get_cap_ysize(const struct Capabilities *cap);
int get_cap_wsize(const struct Capabilities *cap);
+int get_cap_xmid(const struct Capabilities *cap);
+int get_cap_ymid(const struct Capabilities *cap);
+
void output_capabilities(const struct Capabilities *cap);
#endif
diff --git a/src/mtstate.h b/src/mtstate.h
index fa297cd..a8feaa4 100644
--- a/src/mtstate.h
+++ b/src/mtstate.h
@@ -44,5 +44,19 @@ void output_mtstate(const struct MTState *s);
const struct MTFinger *find_finger(const struct MTState *s, int id);
+
+static inline int center_dist2(const struct MTFinger *a,
+ const struct Capabilities *caps)
+{
+ return dist2(a->hw.position_x - get_cap_xmid(caps),
+ a->hw.position_y - get_cap_ymid(caps));
+}
+
+static inline int center_maxdist2(const struct Capabilities *caps)
+{
+ return dist2(caps->abs_position_x.maximum - get_cap_xmid(caps),
+ caps->abs_position_y.maximum - get_cap_ymid(caps));
+}
+
#endif