Commit fe2d108ac2e2bbddc1a8dba96550e737a15aee9e

  • avatar
  • Peter Hutterer <peter.hutterer @wh…t.net> (Committer)
  • Thu Dec 24 00:01:05 CET 2009
  • avatar
  • Ping Cheng <pingc @wa…m.com> (Author)
  • Wed Dec 23 02:12:05 CET 2009
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>
  
2727
2828void xf86WcmInitialScreens(LocalDevicePtr local);
2929void xf86WcmRotateTablet(LocalDevicePtr local, int value);
30void wcmRotateCoordinates(LocalDevicePtr local, int* x, int* y);
3031
3132extern int xf86WcmDevSwitchModeCall(LocalDevicePtr local, int mode);
3233extern void xf86WcmChangeScreen(LocalDevicePtr local, int value);
714714 sendWheelStripEvents(local, ds, x, y, z, v3, v4, v5);
715715}
716716
717/* rotate x and y before post X inout events */
718void wcmRotateCoordinates(LocalDevicePtr local, int* x, int* y)
719{
720 WacomDevicePtr priv = (WacomDevicePtr) local->private;
721 WacomCommonPtr common = priv->common;
722 int tmp_coord;
723
724 /* rotation mixes x and y up a bit */
725 if (common->wcmRotate == ROTATE_CW)
726 {
727 tmp_coord = *x;
728 *x = *y;
729 if (!IsTouch(priv))
730 *y = common->wcmMaxY - tmp_coord;
731 else
732 *y = common->wcmMaxTouchY - tmp_coord;
733 }
734 else if (common->wcmRotate == ROTATE_CCW)
735 {
736 tmp_coord = *y;
737 *y = *x;
738 if (!IsTouch(priv))
739 *x = common->wcmMaxX - tmp_coord;
740 else
741 *y = common->wcmMaxTouchX - tmp_coord;
742 }
743 else if (common->wcmRotate == ROTATE_HALF)
744 {
745 if (!IsTouch(priv))
746 {
747 *x = common->wcmMaxX - *x;
748 *y = common->wcmMaxY - *y;
749 }
750 else
751 {
752 *x = common->wcmMaxTouchX - *x;
753 *y = common->wcmMaxTouchY - *y;
754 }
755 }
756}
757
717758/*****************************************************************************
718759 * xf86WcmSendEvents --
719760 * Send events according to the device state.
778778 int rot = ds->rotation;
779779 int throttle = ds->throttle;
780780 int wheel = ds->abswheel;
781 int tmp_coord;
782781 WacomDevicePtr priv = (WacomDevicePtr) local->private;
783782 WacomCommonPtr common = priv->common;
784783 int naxes = priv->naxes;
816816 x, y, z, is_button ? "true" : "false", buttons,
817817 tx, ty, wheel, rot, throttle);
818818
819 /* rotation mixes x and y up a bit */
820 if (common->wcmRotate == ROTATE_CW)
821 {
822 tmp_coord = x;
823 x = y;
824 if (!IsTouch(priv))
825 y = common->wcmMaxY - tmp_coord;
826 else
827 y = common->wcmMaxTouchY - tmp_coord;
828 }
829 else if (common->wcmRotate == ROTATE_CCW)
830 {
831 tmp_coord = y;
832 y = x;
833 if (!IsTouch(priv))
834 x = common->wcmMaxX - tmp_coord;
835 else
836 y = common->wcmMaxTouchX - tmp_coord;
837 }
838 else if (common->wcmRotate == ROTATE_HALF)
839 {
840 if (!IsTouch(priv))
841 {
842 x = common->wcmMaxX - x;
843 y = common->wcmMaxY - y;
844 }
845 else
846 {
847 x = common->wcmMaxTouchX - x;
848 y = common->wcmMaxTouchY - y;
849 }
850 }
819 wcmRotateCoordinates(local, &x, &y);
851820
852821 if (IsCursor(priv))
853822 {
  
4444
4545void xf86WcmFingerTapToClick(WacomCommonPtr common);
4646
47extern void xf86WcmRotateCoordinates(LocalDevicePtr local, int x, int y);
47extern void wcmRotateCoordinates(LocalDevicePtr local, int* x, int* y);
4848extern void emitKeysym (DeviceIntPtr keydev, int keysym, int state);
4949
5050static void xf86WcmFingerScroll(WacomDevicePtr priv);
334334
335335 /* rotate the coordinates first */
336336 for (i=0; i<6; i++)
337 xf86WcmRotateCoordinates(priv->local, filterd.x[i], filterd.y[i]);
337 wcmRotateCoordinates(priv->local, &filterd.x[i], &filterd.y[i]);
338338
339339 /* check vertical direction */
340340 midPoint_old = (((double)filterd.x[4] + (double)filterd.x[5]) / 2.);