diff --git a/driver/mtrack.c b/driver/mtrack.c index 18a8f97..864f8ac 100644 --- a/driver/mtrack.c +++ b/driver/mtrack.c @@ -22,6 +22,7 @@ #include "mtouch.h" #include "mprops.h" +#include "capabilities.h" #include #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 @@ -201,7 +202,9 @@ static void handle_gestures(LocalDevicePtr local, * are not scaled, this is oke if the touchscreen has the same resolution as the display. */ if(mt->cfg.absolute_mode == TRUE) - xf86PostMotionEvent(local->dev, 1, 0, 2, mt->state.touch[0].x, mt->state.touch[0].y); + xf86PostMotionEvent(local->dev, 1, 0, 2, + mt->state.touch[0].x + get_cap_xmid(&mt->caps), + mt->state.touch[0].y + get_cap_ymid(&mt->caps)); for (i = 0; i < 32; i++) { if (GETBIT(gs->buttons, i) == GETBIT(buttons_prev, i)) diff --git a/include/mconfig.h b/include/mconfig.h index a760464..a6fcd0a 100644 --- a/include/mconfig.h +++ b/include/mconfig.h @@ -96,6 +96,8 @@ struct MConfig { int touch_max; // Maximum touch value. int pad_width; // Width of the touchpad. int pad_height; // Height of the touchpad. + int x_min; // Minimum value of first position coordinate + int y_min; // Minimum value of second position coordinate // Set by config. int touch_down; // When is a finger touching? 0 - 100 (percentage) diff --git a/src/capabilities.c b/src/capabilities.c index fc1ccba..499ec7f 100644 --- a/src/capabilities.c +++ b/src/capabilities.c @@ -163,6 +163,18 @@ int get_cap_y(const struct Capabilities *cap, int y) return y - mid; } +int get_cap_xmin(const struct Capabilities *cap) +{ + const struct input_absinfo *x = &cap->abs[MTDEV_POSITION_X]; + return x->minimum; +} + +int get_cap_ymin(const struct Capabilities *cap) +{ + const struct input_absinfo *y = &cap->abs[MTDEV_POSITION_Y]; + return y->minimum; +} + void output_capabilities(const struct Capabilities *cap) { char line[1024]; diff --git a/src/mconfig.c b/src/mconfig.c index 5ebf357..3326c84 100644 --- a/src/mconfig.c +++ b/src/mconfig.c @@ -85,6 +85,8 @@ 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); + cfg->x_min = get_cap_xmin(caps); + cfg->y_min = get_cap_ymin(caps); if (caps->has_abs[MTDEV_TOUCH_MAJOR] && caps->has_abs[MTDEV_WIDTH_MAJOR]) { cfg->touch_type = MCFG_SCALE; diff --git a/src/mtstate.c b/src/mtstate.c index abe5096..0e665c7 100644 --- a/src/mtstate.c +++ b/src/mtstate.c @@ -121,10 +121,11 @@ static int is_edge(const struct MConfig* cfg, const struct FingerState* hw) { int edge_width = (cfg->edge_size * cfg->pad_width) / 100; int edge_height = (cfg->edge_size * cfg->pad_height) / 100; - return ((hw->position_x < edge_width) || - (hw->position_x >= (cfg->pad_width-edge_width)) || - (hw->position_y < edge_height) || - (hw->position_y >= (cfg->pad_height-edge_height))); + return + hw->position_x < cfg->x_min + edge_width || + hw->position_x > cfg->x_min - edge_width + cfg->pad_width || + hw->position_y < cfg->y_min + edge_height || + hw->position_y > cfg->y_min - edge_height + cfg->pad_height; } /* Find a touch by its tracking ID. Return -1 if not found. @@ -154,6 +155,7 @@ static int touch_append(struct MTState* ms, if (n < 0) xf86Msg(X_WARNING, "Too many touches to track. Ignoring touch %d.\n", fs->tracking_id); else { + /* map origin of mtrack coordinate system to middle point of device */ x = get_cap_x(caps, fs->position_x); y = get_cap_y(caps, fs->position_y); x = cfg->axis_x_invert ? -x : x; @@ -184,8 +186,10 @@ static void touch_update(struct MTState* ms, int touch) { int x, y; + /* map origin of mtrack coordinate system to middle point of device */ x = get_cap_x(caps, fs->position_x); y = get_cap_y(caps, fs->position_y); + x = cfg->axis_x_invert ? -x : x; y = cfg->axis_y_invert ? -y : y; ms->touch[touch].dx = x - ms->touch[touch].x;