diff --git a/README.md b/README.md index b218f3e..839bdf5 100644 --- a/README.md +++ b/README.md @@ -47,47 +47,47 @@ of 1 will disable tapping and gestures but not movement. A value of 2 will disable all input. A value of 3 will also disable physical buttons. Integer. Default is 0. -**Sensitivity** - +**Sensitivity** - Adjusts the sensitivity (movement speed) of the touchpad. This is a real number greater than or equal to zero. Default is 1. A value of 0 will disable pointer movement. -**FingerHigh** - +**FingerHigh** - Defines the pressure at which a finger is detected as a touch. This is a percentage represented as an integer. Default is 5. -**FingerLow** - +**FingerLow** - Defines the pressure at which a finger is detected as a release. This is a percentage represented as an integer. Default is 5. -**IgnoreThumb** - +**IgnoreThumb** - Whether or not to ignore touches that are determined to be thumbs. Boolean value. Defaults to false. -**IgnorePalm** - +**IgnorePalm** - Whether or not to ignore touches that are determined to be palms. Boolean value. Defaults to false. -**DisableOnThumb** - +**DisableOnThumb** - Whether or not to disable the entire trackpad when a thumb is touching. Boolean value. Defaults to false. -**DisableOnPalm** - +**DisableOnPalm** - Whether or not to disable the entire trackpad when a palm is touching. Boolean value. Defaults to false. -**ThumbRatio** - +**ThumbRatio** - The width/length ratio of what's considered a thumb. It is expected that a thumb is longer than it is wide. This tells the driver how much longer. Percentage represented by an integer. Defaults to 70. -**ThumbSize** - +**ThumbSize** - The minimum size of what's considered a thumb. It is expected that a thumb will be larger than other fingers. This is represented as a percentage of the maximum touch value and is dependent on the trackpad hardware. Integer value. Defaults to 25. -**PalmSize** - +**PalmSize** - The minimum size of what's considered a palm. Palms are expected to be very large on the trackpad. This is represented as a percentage of the maximum touch value and is dependent on the trackpad hardware. Integer value. Defaults to 40. @@ -97,11 +97,30 @@ The size of an area at the bottom of the trackpad where new touches are ignored (fingers traveling into this area from above will still be tracked). This is represented as a percentage of the total trackpad height. Defaults to 10. -**ButtonEnable** - +**TopEdge** - +The size of an area at the top of the trackpad where new touched are ignored if +IgnoreTop is enabled. This is represented as percentage of the total trackpad +height. Defaults to 10. + +**IgnoreTop** - +Whether or not to ignore new touches on the top (as defined by the TopEdge +property). Defaults to false. + +**TopCorners** - +The percentage of the top edge and the left edge of the trackpad to form a +triangle with in the top left corner. Same applies for the top right corner. +This zone can be used to ignore touches using the `IgnoreTopCorners` property. +Defaults to 20. + +**IgnoreTopCorners** - +Wether or not to ignore new touches in the top left and right corners of the +trackpad (as defined by `TopCorners`). Defaults to false. + +**ButtonEnable** - Whether or not to enable the physical buttons on or near the trackpad. Boolean value. Defaults to true. -**ButtonIntegrated** - +**ButtonIntegrated** - Whether or not the physical buttons are integrated with the trackpad. If you have a one-piece trackpad like on newer MacBooks, this should be set to true. Button emulation depends on this value being correct. Boolean value. Defaults @@ -119,150 +138,150 @@ those ClickFinger values that are enabled. So setting ClickFinger1 to 0 and enabling the other two will create two zones, one for ClickFinger2 and one for ClickFinger3. Boolean value. Defaults to false. -**ButtonTouchExpire** - +**ButtonTouchExpire** - How long (in ms) to consider a touching finger as part of button emulation. A value of 0 will not expire touches. Integer value. Defaults to 100. -**ClickFinger1** - +**ClickFinger1** - Which button to emulate when one finger is touching the trackpad during a click. Integer value. A value of 0 disables one-touch emulation. Defaults to 3. -**ClickFinger2** - +**ClickFinger2** - Which button to emulate when two fingers are touching the trackpad during a click. Integer value. A value of 0 disabled one-touch emulation. Defaults to 2. -**ClickFinger3** - +**ClickFinger3** - Which button to emulate when three fingers are touching the trackpad during a click. Integer value. A value of 0 disabled one-touch emulation. Defaults to 0. -**TapButton1** - +**TapButton1** - Which button to emulate for one-finger tapping. Integer value. A value of 0 disables one-finger tapping. Defaults to 1. -**TapButton2** - +**TapButton2** - Which button to emulate for two-finger tapping. Integer value. A value of 0 disables two-finger tapping. Defaults to 3. -**TapButton3** - +**TapButton3** - Which button to emulate for three-finger tapping. Integer value. A value of 0 disables three-finger tapping. Defaults to 2. -**TapButton4** - +**TapButton4** - Which button to emulate for four-finger tapping. Integer value. A value of 0 disables three-finger tapping. Defaults to 0. -**ClickTime** - +**ClickTime** - When tapping, how much time to hold down the emulated button. Integer value representing milliseconds. Defaults to 50. -**MaxTapTime** - +**MaxTapTime** - The amount of time to wait for a tap to release before counting it as a move. Integer value representing milliseconds. Defaults to 120. -**MaxTapMove** - +**MaxTapMove** - How far a touch is allowed to move before counting it is no longer considered a tap. Integer value. Defaults to 400. -**GestureClickTime** - +**GestureClickTime** - When a gesture triggers a click, how much time to hold down the emulated button. Integer value representing milliseconds. Defaults to 10. -**GestureWaitTime** - +**GestureWaitTime** - Touches are allowed to transition from one gesture to another. For example, you may go from scrolling to swiping without releasing your fingers from the pad. This value is the amount of time you must be performing the new gesture before it is triggered. This prevents accidental touches from triggering other gestures. Integer value representing milliseconds. Defaults to 100. -**ScrollDistance** - +**ScrollDistance** - For two finger scrolling. How far you must move your fingers before a button click is triggered. Integer value. Defaults to 150. -**ScrollUpButton** - +**ScrollUpButton** - For two finger scrolling. The button that is triggered by scrolling up. Integer value. A value of 0 disables scrolling up. Defaults to 4. -**ScrollDownButton** - +**ScrollDownButton** - For two finger scrolling. The button that is triggered by scrolling down. Integer value. A value of 0 disables scrolling down. Defaults to 5. -**ScrollLeftButton** - +**ScrollLeftButton** - For two finger scrolling. The button that is triggered by scrolling left. Integer value. A value of 0 disables scrolling left. Defaults to 6. -**ScrollRightButton** - +**ScrollRightButton** - For two finger scrolling. The button that is triggered by scrolling right. Integer value. A value of 0 disables scrolling right. Defaults to 7. -**SwipeDistance** - +**SwipeDistance** - For three finger swiping. How far you must move your fingers before a button click is triggered. Integer value. Defaults to 700. -**SwipeUpButton** - +**SwipeUpButton** - For three finger swiping. The button that is triggered by swiping up. Integer value. A value of 0 disables swiping up. Defaults to 8. -**SwipeDownButton** - +**SwipeDownButton** - For three finger swiping. The button that is triggered by swiping down. Integer value. A value of 0 disables swiping down. Defaults to 9. -**SwipeLeftButton** - +**SwipeLeftButton** - For three finger swiping. The button that is triggered by swiping left. Integer value. A value of 0 disables swiping left. Defaults to 10. -**SwipeRightButton** - +**SwipeRightButton** - For three finger swiping. The button that is triggered by swiping right. Integer value. A value of 0 disables swiping right. Defaults to 11. -**Swipe4Distance** - +**Swipe4Distance** - For four finger swiping. How far you must move your fingers before a button click is triggered. Integer value. Defaults to 700. -**Swipe4UpButton** - +**Swipe4UpButton** - For four finger swiping. The button that is triggered by swiping up. Integer value. A value of 0 disables swiping up. Defaults to 8. -**Swipe4DownButton** - +**Swipe4DownButton** - For four finger swiping. The button that is triggered by swiping down. Integer value. A value of 0 disables swiping down. Defaults to 9. -**Swipe4LeftButton** - +**Swipe4LeftButton** - For four finger swiping. The button that is triggered by swiping left. Integer value. A value of 0 disables swiping left. Defaults to 10. -**Swipe4RightButton** - +**Swipe4RightButton** - For four finger swiping. The button that is triggered by swiping right. Integer value. A value of 0 disables swiping right. Defaults to 11. -**ScaleDistance** - +**ScaleDistance** - For pinch scaling. How far you must move your fingers before a button click is triggered. Integer value. Defaults to 150. -**ScaleUpButton** - +**ScaleUpButton** - For pinch scaling. The button that is triggered by scaling up. Integer value. A value of 0 disables scaling up. Defaults to 12. -**ScaleDownButton** - +**ScaleDownButton** - For pinch scaling. The button that is triggered by scaling down. Integer value. A value of 0 disables scaling down. Defaults to 13. -**RotateDistance** - +**RotateDistance** - For two finger rotation. How far you must move your fingers before a button click is triggered. Integer value. Defaults to 150. -**RotateLeftButton** - +**RotateLeftButton** - For two finger rotation. The button that is triggered by rotating left. Integer value. A value of 0 disables rotation left. Defaults to 14. -**RotateRightButton** - +**RotateRightButton** - For two finger rotation. The button that is triggered by rotating right. Integer value. A value of 0 disables rotation right. Defaults to 15. -**TapDragEnable** - +**TapDragEnable** - Whether or not to enable tap-to-drag functionality. Boolean value. Defaults to true. -**TapDragTime** - +**TapDragTime** - The tap-to-drag timeout. This is how long the driver will wait after a single tap for a movement event before sending the click. Integer value representing milliseconds. Defaults to 350. diff --git a/include/capabilities.h b/include/capabilities.h index 65777d3..0e8a912 100644 --- a/include/capabilities.h +++ b/include/capabilities.h @@ -47,6 +47,9 @@ int get_cap_ymid(const struct Capabilities *cap); int get_cap_xflip(const struct Capabilities *cap, int x); int get_cap_yflip(const struct Capabilities *cap, int y); +int get_cap_zero_based_x(const struct Capabilities *cap, int x); +int get_cap_zero_based_y(const struct Capabilities *cap, int y); + void output_capabilities(const struct Capabilities *cap); #endif diff --git a/include/mconfig.h b/include/mconfig.h index 6cead2a..65394ab 100644 --- a/include/mconfig.h +++ b/include/mconfig.h @@ -35,6 +35,10 @@ #define DEFAULT_THUMB_SIZE 25 #define DEFAULT_PALM_SIZE 40 #define DEFAULT_BOTTOM_EDGE 10 +#define DEFAULT_TOP_EDGE 10 +#define DEFAULT_TOP_CORNERS 20 +#define DEFAULT_IGNORE_TOP 0 +#define DEFAULT_IGNORE_TOP_CORNERS 0 #define DEFAULT_BUTTON_ENABLE 1 #define DEFAULT_BUTTON_INTEGRATED 1 #define DEFAULT_BUTTON_ZONES 0 @@ -107,7 +111,11 @@ struct MConfig { int thumb_ratio; // Ratio of width to length that makes a touch a thumb. 0 - 100 int thumb_size; // Minimum touch size for a thumb. 0 - 100 int palm_size; // Minimum touch size for a palm. 0 - 100 - int bottom_edge; // Percent of bottom of trackpad to ignore for new touches. 0 - 100 + int bottom_edge; // Percent of bottom of trackpad to ignore for new touches. 0 - 100 + int top_edge; // Percent of top of trackpad to ignore for new touches. 0 - 100 + int top_corners; // Percent of edges of trackpad to use as points to form triangles in the corners to ignore for new touches. 0 - 100 + int ignore_top; // Disable top. 0 or 1. + int ignore_top_corners; // Disable top corners. 0 or 1. int axis_x_invert; // Whether or not to invert the x axis. 0 or 1. int axis_y_invert; // Whether or not to invert the y axis. 0 or 1. diff --git a/include/mtstate.h b/include/mtstate.h index 6232361..25cdcf6 100644 --- a/include/mtstate.h +++ b/include/mtstate.h @@ -34,6 +34,8 @@ #define MT_THUMB 3 #define MT_PALM 4 #define MT_BOTTOM_EDGE 5 +#define MT_TOP_EDGE 6 +#define MT_TOP_CORNERS 7 struct Touch { bitmask_t state; diff --git a/src/capabilities.c b/src/capabilities.c index 310ee0b..f3d7801 100644 --- a/src/capabilities.c +++ b/src/capabilities.c @@ -163,6 +163,17 @@ int get_cap_yflip(const struct Capabilities *cap, int y) return i->maximum - (y - i->minimum); } +int get_cap_zero_based_x(const struct Capabilities* cap, int x) { + const struct input_absinfo *i = &cap->abs[MTDEV_POSITION_X]; + return x - i->minimum; +} + +int get_cap_zero_based_y(const struct Capabilities* cap, int y) { + const struct input_absinfo *i = &cap->abs[MTDEV_POSITION_Y]; + return y - i->minimum; +} + + void output_capabilities(const struct Capabilities *cap) { char line[1024]; diff --git a/src/mconfig.c b/src/mconfig.c index 4ecbd87..2b0c5e5 100644 --- a/src/mconfig.c +++ b/src/mconfig.c @@ -34,6 +34,8 @@ void mconfig_defaults(struct MConfig* cfg) cfg->thumb_size = DEFAULT_THUMB_SIZE; cfg->palm_size = DEFAULT_PALM_SIZE; cfg->bottom_edge = DEFAULT_BOTTOM_EDGE; + cfg->top_edge = DEFAULT_TOP_EDGE; + cfg->ignore_top = DEFAULT_IGNORE_TOP; // Configure Gestures cfg->trackpad_disable = DEFAULT_TRACKPAD_DISABLE; @@ -85,7 +87,7 @@ void mconfig_init(struct MConfig* cfg, cfg->touch_minor = caps->has_abs[MTDEV_TOUCH_MINOR]; cfg->pad_width = get_cap_xsize(caps); cfg->pad_height = get_cap_ysize(caps); - + if (caps->has_abs[MTDEV_TOUCH_MAJOR] && caps->has_abs[MTDEV_WIDTH_MAJOR]) { cfg->touch_type = MCFG_SCALE; cfg->touch_min = caps->abs[MTDEV_TOUCH_MAJOR].minimum; @@ -130,6 +132,10 @@ void mconfig_configure(struct MConfig* cfg, cfg->thumb_size = CLAMPVAL(xf86SetIntOption(opts, "ThumbSize", DEFAULT_THUMB_SIZE), 0, 100); cfg->palm_size = CLAMPVAL(xf86SetIntOption(opts, "PalmSize", DEFAULT_PALM_SIZE), 0, 100); cfg->bottom_edge = CLAMPVAL(xf86SetIntOption(opts, "BottomEdge", DEFAULT_BOTTOM_EDGE), 0, 100); + cfg->top_edge = CLAMPVAL(xf86SetIntOption(opts, "TopEdge", DEFAULT_TOP_EDGE), 0, 100); + cfg->top_corners = CLAMPVAL(xf86SetIntOption(opts, "TopCorners", DEFAULT_TOP_CORNERS), 0, 100); + cfg->ignore_top = xf86SetBoolOption(opts, "IgnoreTop", DEFAULT_IGNORE_TOP); + cfg->ignore_top_corners = xf86SetBoolOption(opts, "IgnoreTopCorners", DEFAULT_IGNORE_TOP_CORNERS); // Configure Gestures cfg->trackpad_disable = CLAMPVAL(xf86SetIntOption(opts, "TrackpadDisable", DEFAULT_TRACKPAD_DISABLE), 0, 3); diff --git a/src/mtstate.c b/src/mtstate.c index 2cc0c32..48eac84 100644 --- a/src/mtstate.c +++ b/src/mtstate.c @@ -140,6 +140,8 @@ static int touch_append(struct MTState* ms, else { x = cfg->axis_x_invert ? get_cap_xflip(caps, fs->position_x) : fs->position_x; y = cfg->axis_y_invert ? get_cap_yflip(caps, fs->position_y) : fs->position_y; + x = get_cap_zero_based_x(caps, x); + y = get_cap_zero_based_y(caps, y); ms->touch[n].state = 0U; ms->touch[n].flags = 0U; timercp(&ms->touch[n].down, &hs->evtime); @@ -168,6 +170,8 @@ static void touch_update(struct MTState* ms, int x, y; x = cfg->axis_x_invert ? get_cap_xflip(caps, fs->position_x) : fs->position_x; y = cfg->axis_y_invert ? get_cap_yflip(caps, fs->position_y) : fs->position_y; + x = get_cap_zero_based_x(caps, x); + y = get_cap_zero_based_y(caps, y); ms->touch[touch].dx = x - ms->touch[touch].x; ms->touch[touch].dy = y - ms->touch[touch].y; ms->touch[touch].total_dx += ms->touch[touch].dx; @@ -231,24 +235,45 @@ static void touches_update(struct MTState* ms, SETBIT(ms->touch[n].state, MT_THUMB); else CLEARBIT(ms->touch[n].state, MT_THUMB); - + if (is_palm(cfg, &hs->data[i])) SETBIT(ms->touch[n].state, MT_PALM); else CLEARBIT(ms->touch[n].state, MT_PALM); - + if (ms->touch[n].y > (100 - cfg->bottom_edge)*cfg->pad_height/100) { if (GETBIT(ms->touch[n].state, MT_NEW)) SETBIT(ms->touch[n].state, MT_BOTTOM_EDGE); } else CLEARBIT(ms->touch[n].state, MT_BOTTOM_EDGE); - + + if (ms->touch[n].y < (cfg->top_edge * cfg->pad_height)/100) { + if (GETBIT(ms->touch[n].state, MT_NEW)) + SETBIT(ms->touch[n].state, MT_TOP_EDGE); + } + else + CLEARBIT(ms->touch[n].state, MT_TOP_EDGE); + + + if (ms->touch[n].y < (cfg->top_corners * cfg->pad_height)/100) { + int xfrac = ms->touch[n].x * 100 / cfg->pad_width; + int yfrac = ms->touch[n].y * 100 / cfg->pad_height; + if ((xfrac + yfrac < cfg->top_corners) || ((100-xfrac) + yfrac < cfg->top_corners)) { + if (GETBIT(ms->touch[n].state, MT_NEW)) + SETBIT(ms->touch[n].state, MT_TOP_CORNERS); + } else + CLEARBIT(ms->touch[n].state, MT_TOP_CORNERS); + } else + CLEARBIT(ms->touch[n].state, MT_TOP_CORNERS); + MODBIT(ms->touch[n].state, MT_INVALID, GETBIT(ms->touch[n].state, MT_THUMB) && cfg->ignore_thumb || GETBIT(ms->touch[n].state, MT_PALM) && cfg->ignore_palm || + GETBIT(ms->touch[n].state, MT_TOP_EDGE) && cfg->ignore_top || + GETBIT(ms->touch[n].state, MT_TOP_CORNERS) && cfg->ignore_top_corners || GETBIT(ms->touch[n].state, MT_BOTTOM_EDGE)); - + disable |= cfg->disable_on_thumb && GETBIT(ms->touch[n].state, MT_THUMB); disable |= cfg->disable_on_palm && GETBIT(ms->touch[n].state, MT_PALM); } @@ -291,7 +316,7 @@ static void mtstate_output(const struct MTState* ms, ms->touch[i].direction, timertoms(&ms->touch[i].down), timertoms(&tv)); } else if (GETBIT(ms->touch[i].state, MT_NEW)) { - xf86Msg(X_INFO, " new p(%d, %d) d(%+d, %+d) dir(%f) down(%llu)\n", + xf86Msg(X_INFO, " new p(%d, %d) d(%+d, %+d) dir(%f) down(%llu)\n", ms->touch[i].x, ms->touch[i].y, ms->touch[i].dx, ms->touch[i].dy, ms->touch[i].direction, timertoms(&ms->touch[i].down)); }