summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaska Kivela <jaska@kivela.net>2013-01-16 11:51:04 +0200
committerPeter Hutterer <peter.hutterer@who-t.net>2013-01-17 08:18:10 +1000
commit0d3ec2e97c99431cdbaea8e958a75ff2e748da41 (patch)
tree15dbc4acb0dbb4f629f36b34f50604529732b11a /src
parent9fc73c9d037a751dc2b98d4b07d7580db31b8e3a (diff)
Added axis inversion functionality.
The module would previously log a message if min > max, but not do anything about it. Keep the original min/max around, swap on-the-fly. Signed-off-by: Jaska Kivela <jaska@kivela.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r--src/xf86Elo.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/xf86Elo.c b/src/xf86Elo.c
index cb1699e..c37cf9a 100644
--- a/src/xf86Elo.c
+++ b/src/xf86Elo.c
@@ -360,6 +360,22 @@ xf86EloReadInput(InputInfoPtr pInfo)
cur_y = WORD_ASSEMBLY(priv->packet_buf[5], priv->packet_buf[6]);
state = priv->packet_buf[2] & 0x07;
+ DBG(5, ErrorF("ELO got: x(%d), y(%d), %s\n",
+ cur_x, cur_y,
+ (state == ELO_PRESS) ? "Press" :
+ ((state == ELO_RELEASE) ? "Release" : "Stream")));
+
+ if (priv->min_y > priv->max_y) {
+ /* inverted y axis */
+ cur_y = priv->max_y - cur_y + priv->min_y;
+ }
+
+ if (priv->min_x > priv->max_x) {
+ /* inverted x axis */
+ cur_x = priv->max_x - cur_x + priv->min_x;
+ }
+
+
/*
* Send events.
*
@@ -676,6 +692,7 @@ xf86EloControl(DeviceIntPtr dev,
unsigned char reply[ELO_PACKET_SIZE];
Atom btn_label;
Atom axis_labels[2] = { 0, 0 };
+ int x0, x1, y0, y1;
switch(mode) {
@@ -719,17 +736,27 @@ xf86EloControl(DeviceIntPtr dev,
return !Success;
}
else {
+
+ /* Correct the coordinates for possibly inverted axis.
+ Leave priv->variables untouched so we can check for
+ inversion on incoming events.
+ */
+ y0 = min(priv->min_y, priv->max_y);
+ y1 = max(priv->min_y, priv->max_y);
+ x0 = min(priv->min_x, priv->max_x);
+ x1 = max(priv->min_x, priv->max_x);
+
/* I will map coordinates myself */
InitValuatorAxisStruct(dev, 0,
axis_labels[0],
- priv->min_x, priv->max_x,
+ x0, x1,
9500,
0 /* min_res */,
9500 /* max_res */,
Absolute);
InitValuatorAxisStruct(dev, 1,
axis_labels[1],
- priv->min_y, priv->max_y,
+ y0, y1,
10500,
0 /* min_res */,
10500 /* max_res */,