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

Support palm rejection on some "minimal capability" trackpads #116

Open
wants to merge 1 commit 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
2 changes: 1 addition & 1 deletion include/hwstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct FingerState {
int width_major, width_minor;
int orientation, pressure;
int position_x, position_y;
int tracking_id;
int tracking_id, tool_type;
};

struct HWState {
Expand Down
1 change: 1 addition & 0 deletions include/mconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
#define MCFG_PRESSURE_SIZE 3
#define MCFG_SIZE_PRESSURE 4 /* same capabilities as above, but with higher resolution of touches*/
#define MCFG_PRESSURE 5
#define MCFG_DUMB_PALM 6

struct MConfig {
/* Used by MTState */
Expand Down
3 changes: 3 additions & 0 deletions src/hwstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ static int read_event(struct HWState *s, const struct Capabilities *caps,
s->data[s->slot].tracking_id = ev->value;
MODBIT(s->used, s->slot, ev->value != MT_ID_NULL);
break;
case ABS_MT_TOOL_TYPE:
s->data[s->slot].tool_type = ev->value;
break;
}
break;
}
Expand Down
5 changes: 5 additions & 0 deletions src/mconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ void mconfig_init(struct MConfig* cfg,
LOG_INFO("Touchpad is pressure based.\n");
LOG_INFO(" pressure_min = %d, pressure_max = %d\n", cfg->pressure_min, cfg->pressure_max);
}
else if (caps->has_mtdata && caps->has_abs[ABS_MT_TOOL_TYPE])
{
cfg->touch_type = MCFG_DUMB_PALM;
LOG_WARNING("Touchpad only supports multitouch and palm rejection.\n");
}
else {
cfg->touch_type = MCFG_NONE;
LOG_WARNING("Touchpad has minimal capabilities. Some features will be unavailable.\n");
Expand Down
7 changes: 6 additions & 1 deletion src/mtstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ static int is_palm(const struct MConfig* cfg,
case MCFG_PRESSURE:
ratio = pressure_range_ratio(cfg, hw->pressure);
break;
case MCFG_DUMB_PALM:
if(hw->tool_type > 0)
{
ratio = cfg->palm_size+1;
break;
}
default:
return 0;
}
Expand Down Expand Up @@ -392,4 +398,3 @@ void mtstate_extract(struct MTState* ms,
mtstate_output(ms, hs);
#endif
}