[PATCH] evdev: Support the "Calibration" string option.
Peter Hutterer
peter.hutterer at who-t.net
Sun Aug 2 16:44:13 PDT 2009
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.
NACK, this was intentional.
Evdev sets itself up from the data the kernel provides. If you can
statically configure the calibration (i.e. how far off the kernel
data is from the real data) then fix the kernel driver.
Evdev calibration is just for those devices that require different
calibration each time and this needs to be done at runtime anyway then.
Cheers,
Peter
> ---
> 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);
> + }
> +
> /* 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
>
More information about the xorg-devel
mailing list