diff options
author | Ping Cheng <pingc@wacom.com> | 2009-12-22 17:12:05 -0800 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-12-24 09:01:05 +1000 |
commit | fe2d108ac2e2bbddc1a8dba96550e737a15aee9e (patch) | |
tree | 0b64567d177e0eb6a1369d5ad55c7b427cf0b219 | |
parent | aa5c91c68ce9e3c758b584359f9c18f6ce88250e (diff) | |
download | xf86-input-wacom-fe2d108ac2e2bbddc1a8dba96550e737a15aee9e.tar.gz |
Add routine wcmRotateCoordinates
Both wcmCommon.c and wcmTouchFilter.c need to rotate x and y before
sending X input events. wcmRotateCoordinates is added to wcmCommon.c
so it can serve both cases.
Signed-off-by: Ping Cheng <pinglinux@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | src/wcmCommon.c | 76 | ||||
-rw-r--r-- | src/wcmTouchFilter.c | 4 |
2 files changed, 45 insertions, 35 deletions
diff --git a/src/wcmCommon.c b/src/wcmCommon.c index fad9e47..1d2e3f2 100644 --- a/src/wcmCommon.c +++ b/src/wcmCommon.c @@ -27,6 +27,7 @@ void xf86WcmInitialScreens(LocalDevicePtr local); void xf86WcmRotateTablet(LocalDevicePtr local, int value); +void wcmRotateCoordinates(LocalDevicePtr local, int* x, int* y); extern int xf86WcmDevSwitchModeCall(LocalDevicePtr local, int mode); extern void xf86WcmChangeScreen(LocalDevicePtr local, int value); @@ -713,6 +714,47 @@ static void sendCommonEvents(LocalDevicePtr local, const WacomDeviceState* ds, i sendWheelStripEvents(local, ds, x, y, z, v3, v4, v5); } +/* rotate x and y before post X inout events */ +void wcmRotateCoordinates(LocalDevicePtr local, int* x, int* y) +{ + WacomDevicePtr priv = (WacomDevicePtr) local->private; + WacomCommonPtr common = priv->common; + int tmp_coord; + + /* rotation mixes x and y up a bit */ + if (common->wcmRotate == ROTATE_CW) + { + tmp_coord = *x; + *x = *y; + if (!IsTouch(priv)) + *y = common->wcmMaxY - tmp_coord; + else + *y = common->wcmMaxTouchY - tmp_coord; + } + else if (common->wcmRotate == ROTATE_CCW) + { + tmp_coord = *y; + *y = *x; + if (!IsTouch(priv)) + *x = common->wcmMaxX - tmp_coord; + else + *y = common->wcmMaxTouchX - tmp_coord; + } + else if (common->wcmRotate == ROTATE_HALF) + { + if (!IsTouch(priv)) + { + *x = common->wcmMaxX - *x; + *y = common->wcmMaxY - *y; + } + else + { + *x = common->wcmMaxTouchX - *x; + *y = common->wcmMaxTouchY - *y; + } + } +} + /***************************************************************************** * xf86WcmSendEvents -- * Send events according to the device state. @@ -736,7 +778,6 @@ void xf86WcmSendEvents(LocalDevicePtr local, const WacomDeviceState* ds) int rot = ds->rotation; int throttle = ds->throttle; int wheel = ds->abswheel; - int tmp_coord; WacomDevicePtr priv = (WacomDevicePtr) local->private; WacomCommonPtr common = priv->common; int naxes = priv->naxes; @@ -775,38 +816,7 @@ void xf86WcmSendEvents(LocalDevicePtr local, const WacomDeviceState* ds) x, y, z, is_button ? "true" : "false", buttons, tx, ty, wheel, rot, throttle); - /* rotation mixes x and y up a bit */ - if (common->wcmRotate == ROTATE_CW) - { - tmp_coord = x; - x = y; - if (!IsTouch(priv)) - y = common->wcmMaxY - tmp_coord; - else - y = common->wcmMaxTouchY - tmp_coord; - } - else if (common->wcmRotate == ROTATE_CCW) - { - tmp_coord = y; - y = x; - if (!IsTouch(priv)) - x = common->wcmMaxX - tmp_coord; - else - y = common->wcmMaxTouchX - tmp_coord; - } - else if (common->wcmRotate == ROTATE_HALF) - { - if (!IsTouch(priv)) - { - x = common->wcmMaxX - x; - y = common->wcmMaxY - y; - } - else - { - x = common->wcmMaxTouchX - x; - y = common->wcmMaxTouchY - y; - } - } + wcmRotateCoordinates(local, &x, &y); if (IsCursor(priv)) { diff --git a/src/wcmTouchFilter.c b/src/wcmTouchFilter.c index d56ae5e..2b069c0 100644 --- a/src/wcmTouchFilter.c +++ b/src/wcmTouchFilter.c @@ -44,7 +44,7 @@ void xf86WcmFingerTapToClick(WacomCommonPtr common); -extern void xf86WcmRotateCoordinates(LocalDevicePtr local, int x, int y); +extern void wcmRotateCoordinates(LocalDevicePtr local, int* x, int* y); extern void emitKeysym (DeviceIntPtr keydev, int keysym, int state); static void xf86WcmFingerScroll(WacomDevicePtr priv); @@ -334,7 +334,7 @@ static void xf86WcmFingerScroll(WacomDevicePtr priv) /* rotate the coordinates first */ for (i=0; i<6; i++) - xf86WcmRotateCoordinates(priv->local, filterd.x[i], filterd.y[i]); + wcmRotateCoordinates(priv->local, &filterd.x[i], &filterd.y[i]); /* check vertical direction */ midPoint_old = (((double)filterd.x[4] + (double)filterd.x[5]) / 2.); |