diff options
Diffstat (limited to 'xorg-server/hw/xfree86/common/xf86Xinput.c')
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86Xinput.c | 65 |
1 files changed, 46 insertions, 19 deletions
diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c index d22fdc8b9..9fbcba9d5 100644 --- a/xorg-server/hw/xfree86/common/xf86Xinput.c +++ b/xorg-server/hw/xfree86/common/xf86Xinput.c @@ -266,6 +266,34 @@ ApplyAccelerationSettings(DeviceIntPtr dev){ } } +static void +ApplyTransformationMatrix(DeviceIntPtr dev) +{ + InputInfoPtr pInfo = (InputInfoPtr)dev->public.devicePrivate; + char *str; + int rc; + float matrix[9] = {0}; + + if (!dev->valuator) + return; + + str = xf86SetStrOption(pInfo->options, "TransformationMatrix", NULL); + if (!str) + return; + + rc = sscanf(str, "%f %f %f %f %f %f %f %f %f", &matrix[0], &matrix[1], &matrix[2], + &matrix[3], &matrix[4], &matrix[5], &matrix[6], &matrix[7], &matrix[8]); + if (rc != 9) { + xf86Msg(X_ERROR, "%s: invalid format for transformation matrix. Ignoring configuration.\n", + pInfo->name); + return; + } + + XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_TRANSFORM), + XIGetKnownProperty(XATOM_FLOAT), 32, + PropModeReplace, 9, matrix, FALSE); +} + /*********************************************************************** * * xf86ProcessCommonOptions -- @@ -276,7 +304,7 @@ ApplyAccelerationSettings(DeviceIntPtr dev){ */ void xf86ProcessCommonOptions(InputInfoPtr pInfo, - pointer list) + XF86OptionPtr list) { if (xf86SetBoolOption(list, "Floating", 0) || !xf86SetBoolOption(list, "AlwaysCore", 1) || @@ -746,7 +774,7 @@ xf86DeleteInput(InputInfoPtr pInp, int flags) } /* - * Apply backend-specific initialization. Invoked after ActiveteDevice(), + * Apply backend-specific initialization. Invoked after ActivateDevice(), * i.e. after the driver successfully completed DEVICE_INIT and the device * is advertised. * @param dev the device @@ -755,6 +783,7 @@ xf86DeleteInput(InputInfoPtr pInp, int flags) static int xf86InputDevicePostInit(DeviceIntPtr dev) { ApplyAccelerationSettings(dev); + ApplyTransformationMatrix(dev); return Success; } @@ -879,35 +908,35 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs, if (!pInfo) return BadAlloc; - for (option = options; option; option = option->next) { - if (strcasecmp(option->key, "driver") == 0) { + nt_list_for_each_entry(option, options, next) { + if (strcasecmp(input_option_get_key(option), "driver") == 0) { if (pInfo->driver) { rval = BadRequest; goto unwind; } - pInfo->driver = xstrdup(option->value); + pInfo->driver = xstrdup(input_option_get_value(option)); if (!pInfo->driver) { rval = BadAlloc; goto unwind; } } - if (strcasecmp(option->key, "name") == 0 || - strcasecmp(option->key, "identifier") == 0) { + if (strcasecmp(input_option_get_key(option), "name") == 0 || + strcasecmp(input_option_get_key(option), "identifier") == 0) { if (pInfo->name) { rval = BadRequest; goto unwind; } - pInfo->name = xstrdup(option->value); + pInfo->name = xstrdup(input_option_get_value(option)); if (!pInfo->name) { rval = BadAlloc; goto unwind; } } - if (strcmp(option->key, "_source") == 0 && - (strcmp(option->value, "server/hal") == 0 || - strcmp(option->value, "server/udev") == 0)) { + if (strcmp(input_option_get_key(option), "_source") == 0 && + (strcmp(input_option_get_value(option), "server/hal") == 0 || + strcmp(input_option_get_value(option), "server/udev") == 0)) { is_auto = 1; if (!xf86Info.autoAddDevices) { rval = BadMatch; @@ -916,13 +945,11 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs, } } - for (option = options; option; option = option->next) { - /* Steal option key/value strings from the provided list. - * We need those strings, the InputOption list doesn't. */ - pInfo->options = xf86addNewOption(pInfo->options, - option->key, option->value); - option->key = NULL; - option->value = NULL; + nt_list_for_each_entry(option, options, next) { + /* Copy option key/value strings from the provided list */ + pInfo->options = xf86AddNewOption(pInfo->options, + input_option_get_key(option), + input_option_get_value(option)); } /* Apply InputClass settings */ @@ -1348,7 +1375,7 @@ xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, } /* - * Set the valuator values to be in synch with dix/event.c + * Set the valuator values to be in sync with dix/event.c * DefineInitialRootWindow(). */ void |