Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature: ignore new touches at top edge. #115

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 67 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions include/capabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 9 additions & 1 deletion include/mconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions include/mtstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions src/capabilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
8 changes: 7 additions & 1 deletion src/mconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Loading