summaryrefslogtreecommitdiff
path: root/dix/devices.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2013-02-08 14:52:02 +1000
committerKeith Packard <keithp@keithp.com>2013-02-08 09:02:57 -0800
commitb58221f9da8c549d979215271359c6cd88b5568a (patch)
tree116d142be89e85ab53422b41aabfcefa1fc18311 /dix/devices.c
parentb173eb2ae3349c557db1ff9e424fa540b8289bb2 (diff)
dix: support the transformation matrix for relative devices.
The transformation matrix we previously stored was a scaled matrix based on the axis ranges of the device. For relative movements, the scaling is not required (or desired). Store two separate matrices, one as requested by the client, one as the product of [scale . matrix . inv_scale]. Depending on the type of movement, apply the respective matrix. For relative movements, also drop the translation component since it doesn't really make sense to use that bit. Input ABI 19 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'dix/devices.c')
-rw-r--r--dix/devices.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/dix/devices.c b/dix/devices.c
index 172fc0460..530f15d66 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -93,9 +93,10 @@ SOFTWARE.
static void RecalculateMasterButtons(DeviceIntPtr slave);
static void
-DeviceSetTransform(DeviceIntPtr dev, float *transform)
+DeviceSetTransform(DeviceIntPtr dev, float *transform_data)
{
struct pixman_f_transform scale;
+ struct pixman_f_transform transform;
double sx, sy;
int x, y;
@@ -122,16 +123,21 @@ DeviceSetTransform(DeviceIntPtr dev, float *transform)
/* transform */
for (y = 0; y < 3; y++)
for (x = 0; x < 3; x++)
- dev->transform.m[y][x] = *transform++;
+ transform.m[y][x] = *transform_data++;
- pixman_f_transform_multiply(&dev->transform, &scale, &dev->transform);
+ pixman_f_transform_multiply(&dev->scale_and_transform, &scale, &transform);
/* scale */
pixman_f_transform_init_scale(&scale, 1.0 / sx, 1.0 / sy);
scale.m[0][2] = -dev->valuator->axes[0].min_value / sx;
scale.m[1][2] = -dev->valuator->axes[1].min_value / sy;
- pixman_f_transform_multiply(&dev->transform, &dev->transform, &scale);
+ pixman_f_transform_multiply(&dev->scale_and_transform, &dev->scale_and_transform, &scale);
+
+ /* remove translation component for relative movements */
+ dev->relative_transform = transform;
+ dev->relative_transform.m[0][2] = 0;
+ dev->relative_transform.m[1][2] = 0;
}
/**
@@ -308,9 +314,10 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
/* unity matrix */
memset(transform, 0, sizeof(transform));
transform[0] = transform[4] = transform[8] = 1.0f;
- dev->transform.m[0][0] = 1.0;
- dev->transform.m[1][1] = 1.0;
- dev->transform.m[2][2] = 1.0;
+ dev->relative_transform.m[0][0] = 1.0;
+ dev->relative_transform.m[1][1] = 1.0;
+ dev->relative_transform.m[2][2] = 1.0;
+ dev->scale_and_transform = dev->relative_transform;
XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_TRANSFORM),
XIGetKnownProperty(XATOM_FLOAT), 32,