summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2014-02-13 14:55:12 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2014-02-21 11:10:29 +1000
commit0b70c76eab57822526585bbd11a1408bd115f26b (patch)
tree3c8a5b5039c418ec803e31e35b11ea0d8677d393 /src
parent1bd4ca3b5af6e5ee98c7d7f153fd4ee643c29e1a (diff)
Revert "Drop circular pad support"
This reverts commit 3b02e7fd81da4b100fb9ac32378f6d50f54cf0e2. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Conflicts: man/synaptics.man src/synaptics.c Acked-by: Daniel Stone <daniel@fooishbar.org> (cherry picked from commit 4f543ce1d6ae9ca11086a3009d149505590584a8)
Diffstat (limited to 'src')
-rw-r--r--src/properties.c9
-rw-r--r--src/synaptics.c55
-rw-r--r--src/synapticsstr.h1
3 files changed, 65 insertions, 0 deletions
diff --git a/src/properties.c b/src/properties.c
index 0041544..886d8c2 100644
--- a/src/properties.c
+++ b/src/properties.c
@@ -295,6 +295,9 @@ InitDeviceProperties(InputInfoPtr pInfo)
prop_circscroll_trigger =
InitAtom(pInfo->dev, SYNAPTICS_PROP_CIRCULAR_SCROLLING_TRIGGER, 8, 1,
&para->circular_trigger);
+ prop_circpad =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_CIRCULAR_PAD, 8, 1,
+ &para->circular_pad);
prop_palm =
InitAtom(pInfo->dev, SYNAPTICS_PROP_PALM_DETECT, 8, 1,
&para->palm_detect);
@@ -666,6 +669,12 @@ SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
para->circular_trigger = trigger;
}
+ else if (property == prop_circpad) {
+ if (prop->size != 1 || prop->format != 8 || prop->type != XA_INTEGER)
+ return BadMatch;
+
+ para->circular_pad = *(BOOL *) prop->data;
+ }
else if (property == prop_palm) {
if (prop->size != 1 || prop->format != 8 || prop->type != XA_INTEGER)
return BadMatch;
diff --git a/src/synaptics.c b/src/synaptics.c
index 493986d..1c22873 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -701,6 +701,7 @@ set_default_parameters(InputInfoPtr pInfo)
pars->circular_scrolling =
xf86SetBoolOption(opts, "CircularScrolling", FALSE);
pars->circular_trigger = xf86SetIntOption(opts, "CircScrollTrigger", 0);
+ pars->circular_pad = xf86SetBoolOption(opts, "CircularPad", FALSE);
pars->palm_detect = xf86SetBoolOption(opts, "PalmDetect", FALSE);
pars->palm_min_width = xf86SetIntOption(opts, "PalmMinWidth", palmMinWidth);
pars->palm_min_z = xf86SetIntOption(opts, "PalmMinZ", palmMinZ);
@@ -1328,6 +1329,32 @@ DeviceInit(DeviceIntPtr dev)
return !Success;
}
+/*
+ * Convert from absolute X/Y coordinates to a coordinate system where
+ * -1 corresponds to the left/upper edge and +1 corresponds to the
+ * right/lower edge.
+ */
+static void
+relative_coords(SynapticsPrivate * priv, int x, int y,
+ double *relX, double *relY)
+{
+ int minX = priv->synpara.left_edge;
+ int maxX = priv->synpara.right_edge;
+ int minY = priv->synpara.top_edge;
+ int maxY = priv->synpara.bottom_edge;
+ double xCenter = (minX + maxX) / 2.0;
+ double yCenter = (minY + maxY) / 2.0;
+
+ if ((maxX - xCenter > 0) && (maxY - yCenter > 0)) {
+ *relX = (x - xCenter) / (maxX - xCenter);
+ *relY = (y - yCenter) / (maxY - yCenter);
+ }
+ else {
+ *relX = 0;
+ *relY = 0;
+ }
+}
+
/* return angle of point relative to center */
static double
angle(SynapticsPrivate * priv, int x, int y)
@@ -1352,10 +1379,38 @@ diffa(double a1, double a2)
}
static enum EdgeType
+circular_edge_detection(SynapticsPrivate * priv, int x, int y)
+{
+ enum EdgeType edge = 0;
+ double relX, relY, relR;
+
+ relative_coords(priv, x, y, &relX, &relY);
+ relR = SQR(relX) + SQR(relY);
+
+ if (relR > 1) {
+ /* we are outside the ellipse enclosed by the edge parameters */
+ if (relX > M_SQRT1_2)
+ edge |= RIGHT_EDGE;
+ else if (relX < -M_SQRT1_2)
+ edge |= LEFT_EDGE;
+
+ if (relY < -M_SQRT1_2)
+ edge |= TOP_EDGE;
+ else if (relY > M_SQRT1_2)
+ edge |= BOTTOM_EDGE;
+ }
+
+ return edge;
+}
+
+static enum EdgeType
edge_detection(SynapticsPrivate * priv, int x, int y)
{
enum EdgeType edge = NO_EDGE;
+ if (priv->synpara.circular_pad)
+ return circular_edge_detection(priv, x, y);
+
if (x > priv->synpara.right_edge)
edge |= RIGHT_EDGE;
else if (x < priv->synpara.left_edge)
diff --git a/src/synapticsstr.h b/src/synapticsstr.h
index 3f66b14..54bc154 100644
--- a/src/synapticsstr.h
+++ b/src/synapticsstr.h
@@ -190,6 +190,7 @@ typedef struct _SynapticsParameters {
Bool circular_scrolling; /* Enable circular scrolling */
double scroll_dist_circ; /* Scrolling angle radians */
int circular_trigger; /* Trigger area for circular scrolling */
+ Bool circular_pad; /* Edge has an oval or circular shape */
Bool palm_detect; /* Enable Palm Detection */
int palm_min_width; /* Palm detection width */
int palm_min_z; /* Palm detection depth */