Line 0
Link Here
|
|
|
1 |
From 0d3ec2e97c99431cdbaea8e958a75ff2e748da41 Mon Sep 17 00:00:00 2001 |
2 |
From: Jaska Kivela <jaska@kivela.net> |
3 |
Date: Wed, 16 Jan 2013 11:51:04 +0200 |
4 |
Subject: Added axis inversion functionality. |
5 |
|
6 |
The module would previously log a message if min > max, but not do anything |
7 |
about it. Keep the original min/max around, swap on-the-fly. |
8 |
|
9 |
Signed-off-by: Jaska Kivela <jaska@kivela.net> |
10 |
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> |
11 |
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> |
12 |
|
13 |
diff --git a/src/xf86Elo.c b/src/xf86Elo.c |
14 |
index cb1699e..c37cf9a 100644 |
15 |
--- src/xf86Elo.c |
16 |
+++ src/xf86Elo.c |
17 |
@@ -360,6 +360,22 @@ xf86EloReadInput(InputInfoPtr pInfo) |
18 |
cur_y = WORD_ASSEMBLY(priv->packet_buf[5], priv->packet_buf[6]); |
19 |
state = priv->packet_buf[2] & 0x07; |
20 |
|
21 |
+ DBG(5, ErrorF("ELO got: x(%d), y(%d), %s\n", |
22 |
+ cur_x, cur_y, |
23 |
+ (state == ELO_PRESS) ? "Press" : |
24 |
+ ((state == ELO_RELEASE) ? "Release" : "Stream"))); |
25 |
+ |
26 |
+ if (priv->min_y > priv->max_y) { |
27 |
+ /* inverted y axis */ |
28 |
+ cur_y = priv->max_y - cur_y + priv->min_y; |
29 |
+ } |
30 |
+ |
31 |
+ if (priv->min_x > priv->max_x) { |
32 |
+ /* inverted x axis */ |
33 |
+ cur_x = priv->max_x - cur_x + priv->min_x; |
34 |
+ } |
35 |
+ |
36 |
+ |
37 |
/* |
38 |
* Send events. |
39 |
* |
40 |
@@ -676,6 +692,7 @@ xf86EloControl(DeviceIntPtr dev, |
41 |
unsigned char reply[ELO_PACKET_SIZE]; |
42 |
Atom btn_label; |
43 |
Atom axis_labels[2] = { 0, 0 }; |
44 |
+ int x0, x1, y0, y1; |
45 |
|
46 |
switch(mode) { |
47 |
|
48 |
@@ -719,17 +736,27 @@ xf86EloControl(DeviceIntPtr dev, |
49 |
return !Success; |
50 |
} |
51 |
else { |
52 |
+ |
53 |
+ /* Correct the coordinates for possibly inverted axis. |
54 |
+ Leave priv->variables untouched so we can check for |
55 |
+ inversion on incoming events. |
56 |
+ */ |
57 |
+ y0 = min(priv->min_y, priv->max_y); |
58 |
+ y1 = max(priv->min_y, priv->max_y); |
59 |
+ x0 = min(priv->min_x, priv->max_x); |
60 |
+ x1 = max(priv->min_x, priv->max_x); |
61 |
+ |
62 |
/* I will map coordinates myself */ |
63 |
InitValuatorAxisStruct(dev, 0, |
64 |
axis_labels[0], |
65 |
- priv->min_x, priv->max_x, |
66 |
+ x0, x1, |
67 |
9500, |
68 |
0 /* min_res */, |
69 |
9500 /* max_res */, |
70 |
Absolute); |
71 |
InitValuatorAxisStruct(dev, 1, |
72 |
axis_labels[1], |
73 |
- priv->min_y, priv->max_y, |
74 |
+ y0, y1, |
75 |
10500, |
76 |
0 /* min_res */, |
77 |
10500 /* max_res */, |
78 |
-- |
79 |
cgit v0.10.2 |
80 |
|