Guest User

fpit

a guest
May 18th, 2010
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.30 KB | None | 0 0
  1. static void xf86FpitSetUpAxes(DeviceIntPtr dev, FpitPrivatePtr priv)
  2. {
  3.     /*
  4.      * Device reports motions on 2 axes in absolute coordinates.
  5.      * Axes min and max values are reported in raw coordinates.
  6.      * Resolution is computed roughly by the difference between
  7.      * max and min values scaled from the approximate size of the
  8.      * screen to fit one meter.
  9.      */
  10.     int quarter_turns;
  11. #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
  12.         Atom axis_labels[2] = { 0, 0 };
  13. #endif
  14.  
  15.     priv->screen_width = screenInfo.screens[priv->screen_no]->width;
  16.     priv->screen_height = screenInfo.screens[priv->screen_no]->height;
  17.  
  18.     priv->fpitTotalOrientation = priv->fpitBaseOrientation;
  19.     if (!priv->fpitTrackRandR)
  20.         return;
  21.  
  22.     /* now apply transforms specified by RandR:
  23.      * slightly complicated because invertX/Y and swapXY don't commute. */
  24.     priv->screen_rotation = RRGetRotation(screenInfo.screens[priv->screen_no]);
  25.     quarter_turns = (
  26.         (priv->screen_rotation & RR_Rotate_90  ? 1 : 0) +
  27.         (priv->screen_rotation & RR_Rotate_180 ? 2 : 0) +
  28.         (priv->screen_rotation & RR_Rotate_270 ? 3 : 0) ) % 4;
  29.     if (quarter_turns / 2 != 0)
  30.         priv->fpitTotalOrientation ^= FPIT_INVERT_X | FPIT_INVERT_Y;
  31.     if (quarter_turns % 2 != 0) {
  32.         priv->fpitTotalOrientation ^=
  33.             (priv->fpitTotalOrientation & FPIT_THEN_SWAP_XY ? FPIT_INVERT_X : FPIT_INVERT_Y)
  34.             | FPIT_THEN_SWAP_XY;
  35.     }
  36.  
  37.     if (priv->fpitTotalOrientation & FPIT_THEN_SWAP_XY) {
  38.         InitValuatorAxisStruct(dev, 1,
  39. #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
  40.                        axis_labels[1],
  41. #endif
  42.                        priv->fpitMinX, priv->fpitMaxX, 9500, 0 /* min_res */ ,
  43.                        9500 /* max_res */ );
  44.         InitValuatorAxisStruct(dev, 0,
  45. #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
  46.                        axis_labels[0],
  47. #endif
  48.                        priv->fpitMinY, priv->fpitMaxY, 10500, 0 /* min_res */ ,
  49.                        10500 /* max_res */ );
  50.     } else {
  51.  
  52. /*
  53. typo fpit...Y changed
  54. */
  55.  
  56.         InitValuatorAxisStruct(dev, 0,
  57. #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
  58.                        axis_labels[0],
  59. #endif
  60.                        priv->fpitMinX, priv->fpitMaxX, 9500, 0 /* min_res */ ,
  61.                        9500 /* max_res */ );
  62.         InitValuatorAxisStruct(dev, 1,
  63. #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
  64.                        axis_labels[1],
  65. #endif
  66.                        priv->fpitMinY, priv->fpitMaxY, 10500, 0 /* min_res */ ,
  67.                        10500 /* max_res */ );
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment