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

Dev bugfixes #98

Open
wants to merge 2 commits into
base: dev
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
5 changes: 4 additions & 1 deletion driver/mtrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "mtouch.h"
#include "mprops.h"
#include "capabilities.h"

#include <xf86Module.h>
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions include/mconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions src/capabilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 2 additions & 0 deletions src/mconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 8 additions & 4 deletions src/mtstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down