[PATCH elographics] Configurable mirroring of X,Y input coordinates.
Antti Peltonen
antti.peltonen at iki.fi
Thu Jul 25 09:59:10 PDT 2013
Some hardware out there appears to report Y coordinates in reverse. I fixed this by adding an configurable parameter to drivers config in xorg.conf and while I was at it I also added the same functionality for X axis as well in case there are similarly "broken" implmentations in use.
Signed-off-by: Antti Peltonen <antti.peltonen at iki.fi>
---
man/elographics.man | 6 ++++++
src/xf86Elo.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/man/elographics.man b/man/elographics.man
index 32efda4..e260644 100644
--- a/man/elographics.man
+++ b/man/elographics.man
@@ -71,6 +71,12 @@ Delay between report packets. Default: 1 (10ms).
.TP
.BI "Option \*qModel\*q \*q" string \*q
The touchscreen model. Default: unset. Supported models: "Sunit dSeries".
+.TP
+.BI "Option \*qMirrorX\*q \*q" boolean \*q
+Mirror coordinates read from device on X axis. eg. Down becomes up
+.TP
+.BI "Option \*qMirrorY\*q \*q" boolean \*q
+Mirror coordinates read from device on Y axis. eg. Left becomes right
.SH "SEE ALSO"
__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__).
.SH AUTHORS
diff --git a/src/xf86Elo.c b/src/xf86Elo.c
index c37cf9a..dea4f48 100644
--- a/src/xf86Elo.c
+++ b/src/xf86Elo.c
@@ -194,6 +194,8 @@ typedef struct _EloPrivateRec {
int checksum; /* Current checksum of data in assembly buffer */
int packet_buf_p; /* Assembly buffer pointer */
int swap_axes; /* Swap X an Y axes if != 0 */
+ int mirror_x; /* Mirror X axis input if != 0 */
+ int mirror_y; /* Mirror Y axis input if != 0 */
unsigned char packet_buf[ELO_PACKET_SIZE]; /* Assembly buffer */
int model; /* one of MODEL_... */
} EloPrivateRec, *EloPrivatePtr;
@@ -336,6 +338,9 @@ xf86EloReadInput(InputInfoPtr pInfo)
int cur_x, cur_y;
int state;
+ int eff_max_x, eff_max_y;
+ int eff_min_x, eff_min_y;
+
DBG(4, ErrorF("Entering ReadInput\n"));
/*
@@ -365,16 +370,35 @@ xf86EloReadInput(InputInfoPtr pInfo)
(state == ELO_PRESS) ? "Press" :
((state == ELO_RELEASE) ? "Release" : "Stream")));
+ eff_max_y = priv->max_y;
+ eff_min_y = priv->min_y;
if (priv->min_y > priv->max_y) {
/* inverted y axis */
cur_y = priv->max_y - cur_y + priv->min_y;
+ /* change effective values */
+ eff_max_y = priv->min_y;
+ eff_min_y = priv->max_y;
}
if (priv->min_x > priv->max_x) {
/* inverted x axis */
cur_x = priv->max_x - cur_x + priv->min_x;
+ /* change effective values */
+ eff_max_x = priv->min_x;
+ eff_min_x = priv->max_x;
}
+ /*
+ * Mirror axis coordinates if so configured
+ */
+ if (priv->mirror_x)
+ {
+ cur_x = abs(cur_x - eff_max_x) + eff_min_x;
+ }
+ if (priv->mirror_y)
+ {
+ cur_y = abs(cur_y - eff_max_y) + eff_min_y;
+ }
/*
* Send events.
@@ -912,6 +936,8 @@ xf86EloAllocate(InputDriverPtr drv, InputInfoPtr pInfo)
priv->checksum = ELO_INIT_CHECKSUM;
priv->packet_buf_p = 0;
priv->swap_axes = 0;
+ priv->mirror_x = 0;
+ priv->mirror_y = 0;
pInfo->device_control = xf86EloControl;
pInfo->read_input = xf86EloReadInput;
@@ -1018,6 +1044,14 @@ xf86EloInit(InputDriverPtr drv,
if (priv->swap_axes) {
xf86Msg(X_CONFIG, "Elographics device will work with X and Y axes swapped\n");
}
+ priv->mirror_x = xf86SetBoolOption(pInfo->options, "MirrorX", 0);
+ if (priv->mirror_x) {
+ xf86Msg(X_CONFIG, "Elographics device will work with X axis coordinates mirrored\n");
+ }
+ priv->mirror_y = xf86SetBoolOption(pInfo->options, "MirrorY", 0);
+ if (priv->mirror_y) {
+ xf86Msg(X_CONFIG, "Elographics device will work with Y axis coordinates mirrored\n");
+ }
debug_level = xf86SetIntOption(pInfo->options, "DebugLevel", 0);
if (debug_level) {
#if DEBUG
--
1.8.1.4
More information about the xorg-devel
mailing list