vins31

xf86-input-synaptics-1.5.99.903-clickpad.patch

Apr 17th, 2012
87
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Patch inspired from the one made by Henry Hermawan at http://henryhermawan.blogspot.fr/2011/03/synaptics-140-patch-for-activating.html
  2. --- ./src/synaptics.c   2012-04-16 03:44:14.000000000 +0200
  3. +++ gynaptics.c 2012-04-17 15:09:48.417328099 +0200
  4. @@ -204,6 +204,9 @@ _X_EXPORT XF86ModuleData synapticsModule
  5.      NULL
  6.  };
  7.  
  8. +static void HandleClickpad(InputInfoPtr pInfo, struct SynapticsHwState *hw, edge_type edge);
  9. +
  10. +static edge_type edge_detection(SynapticsPrivate *priv, int x, int y);
  11.  
  12.  /*****************************************************************************
  13.   * Function Definitions
  14. @@ -681,6 +684,18 @@ static void set_default_parameters(Input
  15.          vertResolution = priv->resy;
  16.      }
  17.  
  18. +    /* Clickpad mode -- bottom area is used as buttons */
  19. +    if (priv->is_clickpad) {
  20. +   int button_bottom;
  21. +   /* Clickpad devices usually the button area at the bottom, and
  22. +    * its size seems ca. 20% of the touchpad height no matter how
  23. +    * large the pad is.
  24. +    */
  25. +   button_bottom = priv->maxy - (abs(priv->maxy - priv->miny) * 20) / 100;
  26. +   if (button_bottom < b && button_bottom >= t)
  27. +       b = button_bottom;
  28. +    }
  29. +
  30.      /* set the parameters */
  31.      pars->left_edge = xf86SetIntOption(opts, "LeftEdge", l);
  32.      pars->right_edge = xf86SetIntOption(opts, "RightEdge", r);
  33. @@ -1415,6 +1430,66 @@ fail:
  34.      return !Success;
  35.  }
  36.  
  37. +/* clickpad event handling */
  38. +static void
  39. +HandleClickpad(InputInfoPtr pInfo, struct SynapticsHwState *hw, edge_type edge)
  40. +{
  41. +    SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private);
  42. +    SynapticsParameters *para = &priv->synpara;
  43. +
  44. +    /*edge_type edge = NO_EDGE;*/
  45. +    edge = edge_detection(priv, hw->x, hw->y);
  46. +    /* Clickpad handling for button area */
  47. +    if (priv->is_clickpad)
  48. +        HandleClickpad(pInfo, hw, edge);
  49. +
  50. +
  51. +    if (edge & BOTTOM_EDGE) {
  52. +   /* button area */
  53. +   int width = priv->maxx - priv->minx;
  54. +   int left_button_x, right_button_x;
  55. +
  56. +   /* left and right clickpad button ranges;
  57. +    * the gap between them is interpreted as a middle-button click
  58. +    */
  59. +   left_button_x = width * 2/ 5 + priv->minx;
  60. +   right_button_x = width * 3 / 5 + priv->minx;
  61. +
  62. +   /* clickpad reports only one button, and we need
  63. +    * to fake left/right buttons depending on the touch position
  64. +    */
  65. +   if (hw->left) { /* clicked? */
  66. +       hw->left = 0;
  67. +       if (hw->x < left_button_x)
  68. +       hw->left = 1;
  69. +       else if (hw->x > right_button_x)
  70. +       hw->right = 1;
  71. +       else
  72. +       hw->middle = 1;
  73. +   }
  74. +
  75. +   /* Don't move pointer position in the button area during clicked,
  76. +    * except for horiz/vert scrolling is enabled.
  77. +    *
  78. +    * The synaptics driver tends to be pretty sensitive.  This hack
  79. +    * is to avoid that the pointer moves slightly and misses the
  80. +    * poistion you aimed to click.
  81. +    *
  82. +    * Also, when the pointer movement is reported, the dragging
  83. +    * (with a sort of multi-touching) doesn't work well, too.
  84. +    */
  85. +   if (hw->left || !(para->scroll_edge_horiz ||
  86. +             ((edge & RIGHT_EDGE) && para->scroll_edge_vert)))
  87. +       hw->z = 0; /* don't move pointer */
  88. +
  89. +    } else if (hw->left) {
  90. +   /* dragging */
  91. +   hw->left = priv->prev_hw.left;
  92. +   hw->right = priv->prev_hw.right;
  93. +   hw->middle = priv->prev_hw.middle;
  94. +    }
  95. +    priv->prev_hw = *hw;
  96. +}
  97.  
  98.  /*
  99.   * Convert from absolute X/Y coordinates to a coordinate system where
  100. @@ -2785,6 +2860,13 @@ update_hw_button_state(const InputInfoPt
  101.  {
  102.      SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private);
  103.      SynapticsParameters *para = &priv->synpara;
  104. +    edge_type edge = NO_EDGE;
  105. +
  106. +    edge = edge_detection(priv, hw->x, hw->y);
  107. +
  108. +    /* Clickpad handling for button area */
  109. +    if (priv->is_clickpad)
  110. +       HandleClickpad(pInfo, hw, edge);
  111.  
  112.      /* Treat the first two multi buttons as up/down for now. */
  113.      hw->up |= hw->multi[0];
  114. @@ -3160,7 +3242,7 @@ HandleState(InputInfoPtr pInfo, struct S
  115.  
  116.      /* no edge or finger detection outside of area */
  117.      if (inside_active_area) {
  118. -   edge = edge_detection(priv, hw->x, hw->y);
  119. +   /*edge = edge_detection(priv, hw->x, hw->y);*/
  120.     if (!from_timer)
  121.         finger = SynapticsDetectFinger(priv, hw);
  122.     else
  123. diff -uprN ./src/synapticsstr.h gynapticsstr.h
  124. --- ./src/synapticsstr.h    2012-04-11 01:02:08.000000000 +0200
  125. +++ gynapticsstr.h  2012-04-17 14:46:13.264823404 +0200
  126. @@ -272,7 +272,8 @@ struct _SynapticsPrivateRec
  127.      Bool has_width;            /* device reports finger width */
  128.      Bool has_scrollbuttons;        /* device has physical scrollbuttons */
  129.      Bool has_semi_mt;          /* device is only semi-multitouch capable */
  130. -
  131. +    Bool is_clickpad;
  132. +    struct SynapticsHwState prev_hw;
  133.      enum TouchpadModel model;      /* The detected model */
  134.      unsigned short id_vendor;      /* vendor id */
  135.      unsigned short id_product;     /* product id */
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×