Hello,
Almost all touchscreen drivers before evdev (elographics, mutouch,
penmount, evtouch and all deprecated serial drivers) use the same Xorg
config names for calibration, namely:
SwapXY
MinX
MaxX
MinY
MaxY
Unfortunately, evdev chose the name 'SwapAxes' instead of 'SwapXY'. But
with the patch from the email below, the gap with the established
drivers is increased by putting all calibration values in one joined
'Calibration <minx> <maxx> <miny> <maxy>'
I would like to argue for using the same standard config names for the
evdev driver. This would allow people to easily switch to and from the
evdev driver: just change the name of the driver. It would also ease the
work of calibration software and FDI policy files: the same min/maxX/Y
can be used for all touchscreen drivers.
Attached is a patch that changes the evdev driver to also use SwapXY and
to use MinX,MaxX,MinY,MaxY for calibration. The manpage is updated too.
Signed-off-by: Tias Guns <[email protected]>
Greetings,
Tias
On Thu, 2009-10-08 at 05:05 +0200, ext Peter Hutterer wrote:
On Mon, Aug 03, 2009 at 02:31:02AM +0300, oliver.mcfadden at
nokia.com wrote:
> From: Oliver McFadden <oliver.mcfadden at nokia.com>
>
> Originally based on a patch from Daniel Stone, this commit allows for
> the calibration factors to be set either from Xorg.conf or via HAL.
>
> Previously the only way was via the properties interface.
> ---
> src/evdev.c | 51 ++++++++++++++++++++++++++++++---------------------
> 1 files changed, 30 insertions(+), 21 deletions(-)
>
> diff --git a/src/evdev.c b/src/evdev.c
> index 7ea2ef7..5cc290a 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -1868,12 +1868,32 @@ EvdevProbe(InputInfoPtr pInfo)
> return 0;
> }
>
> +static void
> +EvdevSetCalibration(InputInfoPtr pInfo, int num_calibration, int
calibration[4])
> +{
> + EvdevPtr pEvdev = pInfo->private;
> +
> + if (num_calibration == 0) {
> + pEvdev->flags &= ~EVDEV_CALIBRATED;
> + pEvdev->calibration.min_x = 0;
> + pEvdev->calibration.max_x = 0;
> + pEvdev->calibration.min_y = 0;
> + pEvdev->calibration.max_y = 0;
> + } else if (num_calibration == 4) {
> + pEvdev->flags |= EVDEV_CALIBRATED;
> + pEvdev->calibration.min_x = calibration[0];
> + pEvdev->calibration.max_x = calibration[1];
> + pEvdev->calibration.min_y = calibration[2];
> + pEvdev->calibration.max_y = calibration[3];
> + }
> +}
>
> static InputInfoPtr
> EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
> {
> InputInfoPtr pInfo;
> - const char *device;
> + const char *device, *str;
> + int num_calibration = 0, calibration[4] = { 0, 0, 0, 0 };
> EvdevPtr pEvdev;
>
> if (!(pInfo = xf86AllocateInput(drv, 0)))
> @@ -1946,6 +1966,14 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr
dev, int flags)
> pEvdev->invert_y = xf86SetBoolOption(pInfo->options,
"InvertY", FALSE);
> pEvdev->swap_axes = xf86SetBoolOption(pInfo->options,
"SwapAxes", FALSE);
>
> + str = xf86CheckStrOption(pInfo->options, "Calibration", NULL);
> + if (str) {
> + num_calibration = sscanf(str, "%d %d %d %d",
> + &calibration[0], &calibration[1],
> + &calibration[2], &calibration[3]);
> + EvdevSetCalibration(pInfo, num_calibration, calibration);
There should be an error message if num_calibration != 4, and better only
call EvdevSetCalibration if num_calibration is 4, it's more readable
- even
though the same check exists inside the function again.
> + }
> +
> /* Grabbing the event device stops in-kernel event forwarding.
In other
> words, it disables rfkill and the "Macintosh mouse button
emulation".
> Note that this needs a server that sets the console to RAW
mode. */
> @@ -2419,27 +2447,8 @@ EvdevSetProperty(DeviceIntPtr dev, Atom
atom, XIPropertyValuePtr val,
> return BadMatch;
> if (val->size != 4 && val->size != 0)
> return BadMatch;
> -
> if (!checkonly)
> - {
> - if (val->size == 0)
> - {
> - pEvdev->flags &= ~EVDEV_CALIBRATED;
> - pEvdev->calibration.min_x = 0;
> - pEvdev->calibration.max_x = 0;
> - pEvdev->calibration.min_y = 0;
> - pEvdev->calibration.max_y = 0;
> - } else if (val->size == 4)
> - {
> - CARD32 *vals = (CARD32*)val->data;
> -
> - pEvdev->flags |= EVDEV_CALIBRATED;
> - pEvdev->calibration.min_x = vals[0];
> - pEvdev->calibration.max_x = vals[1];
> - pEvdev->calibration.min_y = vals[2];
> - pEvdev->calibration.max_y = vals[3];
> - }
> - }
> + EvdevSetCalibration(pInfo, val->size, val->data);
> } else if (atom == prop_swap)
> {
> if (val->format != 8 || val->type != XA_INTEGER ||
val->size != 1)
> --
> 1.6.1
man page addition is missing. Other than that, I'm fine with it.
Cheers,
Peter
diff --git a/man/evdev.man b/man/evdev.man
index 4771167..070fb69 100644
--- a/man/evdev.man
+++ b/man/evdev.man
@@ -130,14 +130,14 @@ events to /dev/kbd or /dev/input/mice. Events from this device will not be
sent to virtual devices (e.g. rfkill or the Macintosh mouse button emulation).
Default: disabled.
.TP 7
-.BI "Option \*qInvertX\*q \*q" Bool \*q
+.BI "Option \*qInvertX\*q \*q" boolean \*q
.TP 7
-.BI "Option \*qInvertY\*q \*q" Bool \*q
-Invert the given axis. Default: off. Property: "Evdev Axis Inversion".
+.BI "Option \*qInvertY\*q \*q" boolean \*q
+Invert the given axis. Default: False. Property: "Evdev Axis Inversion".
.TP 7
-.BI "Option \*qIgnoreRelativeAxes\*q \*q" Bool \*q
+.BI "Option \*qIgnoreRelativeAxes\*q \*q" boolean \*q
.TP 7
-.BI "Option \*qIgnoreAbsoluteAxes\*q \*q" Bool \*q
+.BI "Option \*qIgnoreAbsoluteAxes\*q \*q" boolean \*q
Ignore the specified type of axis. Default: unset. The X server cannot deal
with devices that have both relative and absolute axes. Evdev tries to guess
wich axes to ignore given the device type and disables absolute axes for
@@ -151,16 +151,21 @@ axes regardless of the presence of other axes. This may trigger buggy
behavior and events from this axis are always forwarded. Users are
discouraged from setting this option.
.TP 7
-.BI "Option \*qCalibration\*q \*q" "min-x max-x min-y max-y" \*q
-Calibrates the X and Y axes for devices that need to scale to a different
-coordinate system than reported to the X server. This feature is required
-for devices that need to scale to a different coordinate system than
-originally reported by the kernel (e.g. touchscreens). The scaling to the
-custom coordinate system is done in-driver and the X server is unaware of
-the transformation. Property: "Evdev Axis Calibration".
+.BI "Option \*qMinX\*q \*q" integer \*q
.TP 7
-.BI "Option \*qSwapAxes\*q \*q" Bool \*q
-Swap x/y axes. Default: off. Property: "Evdev Axes Swap".
+.BI "Option \*qMaxX\*q \*q" integer \*q
+.TP 7
+.BI "Option \*qMinY\*q \*q" integer \*q
+.TP 7
+.BI "Option \*qMaxY\*q \*q" integer \*q
+Set minimum and maximum values for the X and Y axis. These values will be used
+to rescale to a different coordinate system than reported by the X server.
+This is needed for devices like touchscreens. The scaling to the custom
+coordinate system is done in\-driver and the X server is unaware of the
+transformation. Property: "Evdev Axis Calibration".
+.TP 7
+.BI "Option \*qSwapXY\*q \*q" boolean \*q
+Swap the X and Y axis on the display. Default: False. Property: "Evdev Axes Swap".
.TP 7
.BI "Option \*qXAxisMapping\*q \*q" "N1 N2" \*q
Specifies which buttons are mapped to motion in the X direction in wheel
diff --git a/src/evdev.c b/src/evdev.c
index 06ea83b..3bdccfb 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1939,7 +1939,7 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
{
InputInfoPtr pInfo;
const char *device, *str;
- int num_calibration = 0, calibration[4] = { 0, 0, 0, 0 };
+ int calibration[4] = { 0, 0, 0, 0 };
EvdevPtr pEvdev;
if (!(pInfo = xf86AllocateInput(drv, 0)))
@@ -2010,18 +2010,15 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
pEvdev->invert_x = xf86SetBoolOption(pInfo->options, "InvertX", FALSE);
pEvdev->invert_y = xf86SetBoolOption(pInfo->options, "InvertY", FALSE);
pEvdev->swap_axes = xf86SetBoolOption(pInfo->options, "SwapAxes", FALSE);
-
- str = xf86CheckStrOption(pInfo->options, "Calibration", NULL);
- if (str) {
- num_calibration = sscanf(str, "%d %d %d %d",
- &calibration[0], &calibration[1],
- &calibration[2], &calibration[3]);
- if (num_calibration == 4)
- EvdevSetCalibration(pInfo, num_calibration, calibration);
- else
- xf86Msg(X_ERROR,
- "%s: Insufficient calibration factors (%d). Ignoring calibration\n",
- pInfo->name, num_calibration);
+ pEvdev->swap_axes = xf86SetBoolOption(pInfo->options, "SwapXY", pEvdev->swap_axes);
+
+ calibration[0] = xf86SetIntOption(pInfo->options, "MinX", 0);
+ calibration[1] = xf86SetIntOption(pInfo->options, "MaxX", 0);
+ calibration[2] = xf86SetIntOption(pInfo->options, "MinY", 0);
+ calibration[3] = xf86SetIntOption(pInfo->options, "MaxY", 0);
+ if (calibration[0] != 0 || calibration[1] != 0 ||
+ calibration[2] != 0 || calibration[3] == 0) {
+ EvdevSetCalibration(pInfo, 4, calibration);
}
/* Grabbing the event device stops in-kernel event forwarding. In other
_______________________________________________
xorg mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/xorg