From ffc2c9961f5fb099b85a97550a30a854420ee773 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 20 May 2010 11:54:56 +1000 Subject: Move checks for calibration, inversion and axis swap to EvdevProbe. Keyboard devices don't need these checks. Signed-off-by: Peter Hutterer --- src/evdev.c | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index e09c203..e54a8ed 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -94,6 +94,7 @@ static int EvdevCacheCompare(InputInfoPtr pInfo, BOOL compare); static void EvdevKbdCtrl(DeviceIntPtr device, KeybdCtrl *ctrl); static int EvdevSwitchMode(ClientPtr client, DeviceIntPtr device, int mode); static BOOL EvdevGrabDevice(InputInfoPtr pInfo, int grab, int ungrab); +static void EvdevSetCalibration(InputInfoPtr pInfo, int num_calibration, int calibration[4]); #ifdef HAVE_PROPERTIES static void EvdevInitAxesLabels(EvdevPtr pEvdev, int natoms, Atom *atoms); @@ -1927,6 +1928,30 @@ EvdevProbe(InputInfoPtr pInfo) } } + if (has_rel_axes || has_abs_axes) + { + char *str; + int num_calibration = 0, calibration[4] = { 0, 0, 0, 0 }; + + 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]); + xfree(str); + 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); + } + } + if (has_rel_axes || has_abs_axes || num_buttons) { pInfo->flags |= XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS | XI86_CONFIGURED; @@ -1993,8 +2018,7 @@ static InputInfoPtr EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) { InputInfoPtr pInfo; - const char *device, *str; - int num_calibration = 0, calibration[4] = { 0, 0, 0, 0 }; + const char *device; EvdevPtr pEvdev; if (!(pInfo = xf86AllocateInput(drv, 0))) @@ -2060,24 +2084,6 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) goto error; } - 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]); - xfree(str); - 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); - } - /* 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. */ -- cgit v1.2.3