Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Patch inspired from the one made by Henry Hermawan at http://henryhermawan.blogspot.fr/2011/03/synaptics-140-patch-for-activating.html
- --- ./src/synaptics.c 2012-04-16 03:44:14.000000000 +0200
- +++ gynaptics.c 2012-04-17 15:09:48.417328099 +0200
- @@ -204,6 +204,9 @@ _X_EXPORT XF86ModuleData synapticsModule
- NULL
- };
- +static void HandleClickpad(InputInfoPtr pInfo, struct SynapticsHwState *hw, edge_type edge);
- +
- +static edge_type edge_detection(SynapticsPrivate *priv, int x, int y);
- /*****************************************************************************
- * Function Definitions
- @@ -681,6 +684,18 @@ static void set_default_parameters(Input
- vertResolution = priv->resy;
- }
- + /* Clickpad mode -- bottom area is used as buttons */
- + if (priv->is_clickpad) {
- + int button_bottom;
- + /* Clickpad devices usually the button area at the bottom, and
- + * its size seems ca. 20% of the touchpad height no matter how
- + * large the pad is.
- + */
- + button_bottom = priv->maxy - (abs(priv->maxy - priv->miny) * 20) / 100;
- + if (button_bottom < b && button_bottom >= t)
- + b = button_bottom;
- + }
- +
- /* set the parameters */
- pars->left_edge = xf86SetIntOption(opts, "LeftEdge", l);
- pars->right_edge = xf86SetIntOption(opts, "RightEdge", r);
- @@ -1415,6 +1430,66 @@ fail:
- return !Success;
- }
- +/* clickpad event handling */
- +static void
- +HandleClickpad(InputInfoPtr pInfo, struct SynapticsHwState *hw, edge_type edge)
- +{
- + SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private);
- + SynapticsParameters *para = &priv->synpara;
- +
- + /*edge_type edge = NO_EDGE;*/
- + edge = edge_detection(priv, hw->x, hw->y);
- + /* Clickpad handling for button area */
- + if (priv->is_clickpad)
- + HandleClickpad(pInfo, hw, edge);
- +
- +
- + if (edge & BOTTOM_EDGE) {
- + /* button area */
- + int width = priv->maxx - priv->minx;
- + int left_button_x, right_button_x;
- +
- + /* left and right clickpad button ranges;
- + * the gap between them is interpreted as a middle-button click
- + */
- + left_button_x = width * 2/ 5 + priv->minx;
- + right_button_x = width * 3 / 5 + priv->minx;
- +
- + /* clickpad reports only one button, and we need
- + * to fake left/right buttons depending on the touch position
- + */
- + if (hw->left) { /* clicked? */
- + hw->left = 0;
- + if (hw->x < left_button_x)
- + hw->left = 1;
- + else if (hw->x > right_button_x)
- + hw->right = 1;
- + else
- + hw->middle = 1;
- + }
- +
- + /* Don't move pointer position in the button area during clicked,
- + * except for horiz/vert scrolling is enabled.
- + *
- + * The synaptics driver tends to be pretty sensitive. This hack
- + * is to avoid that the pointer moves slightly and misses the
- + * poistion you aimed to click.
- + *
- + * Also, when the pointer movement is reported, the dragging
- + * (with a sort of multi-touching) doesn't work well, too.
- + */
- + if (hw->left || !(para->scroll_edge_horiz ||
- + ((edge & RIGHT_EDGE) && para->scroll_edge_vert)))
- + hw->z = 0; /* don't move pointer */
- +
- + } else if (hw->left) {
- + /* dragging */
- + hw->left = priv->prev_hw.left;
- + hw->right = priv->prev_hw.right;
- + hw->middle = priv->prev_hw.middle;
- + }
- + priv->prev_hw = *hw;
- +}
- /*
- * Convert from absolute X/Y coordinates to a coordinate system where
- @@ -2785,6 +2860,13 @@ update_hw_button_state(const InputInfoPt
- {
- SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private);
- SynapticsParameters *para = &priv->synpara;
- + edge_type edge = NO_EDGE;
- +
- + edge = edge_detection(priv, hw->x, hw->y);
- +
- + /* Clickpad handling for button area */
- + if (priv->is_clickpad)
- + HandleClickpad(pInfo, hw, edge);
- /* Treat the first two multi buttons as up/down for now. */
- hw->up |= hw->multi[0];
- @@ -3160,7 +3242,7 @@ HandleState(InputInfoPtr pInfo, struct S
- /* no edge or finger detection outside of area */
- if (inside_active_area) {
- - edge = edge_detection(priv, hw->x, hw->y);
- + /*edge = edge_detection(priv, hw->x, hw->y);*/
- if (!from_timer)
- finger = SynapticsDetectFinger(priv, hw);
- else
- diff -uprN ./src/synapticsstr.h gynapticsstr.h
- --- ./src/synapticsstr.h 2012-04-11 01:02:08.000000000 +0200
- +++ gynapticsstr.h 2012-04-17 14:46:13.264823404 +0200
- @@ -272,7 +272,8 @@ struct _SynapticsPrivateRec
- Bool has_width; /* device reports finger width */
- Bool has_scrollbuttons; /* device has physical scrollbuttons */
- Bool has_semi_mt; /* device is only semi-multitouch capable */
- -
- + Bool is_clickpad;
- + struct SynapticsHwState prev_hw;
- enum TouchpadModel model; /* The detected model */
- unsigned short id_vendor; /* vendor id */
- unsigned short id_product; /* product id */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement