From e4ef52b319f755ffd9fde547d4ac751e32b14e93 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 25 Aug 2010 19:45:56 +0200 Subject: works well for one finger --- usr/src/dkms_source_tree/hid-ntrig.c | 52 +++++++++++++++++------------------- 1 file changed, 24 insertions(+), 28 deletions(-) (limited to 'usr/src/dkms_source_tree') diff --git a/usr/src/dkms_source_tree/hid-ntrig.c b/usr/src/dkms_source_tree/hid-ntrig.c index fb882bd..70a2ccd 100644 --- a/usr/src/dkms_source_tree/hid-ntrig.c +++ b/usr/src/dkms_source_tree/hid-ntrig.c @@ -39,7 +39,6 @@ struct ntrig_data { unsigned int id; struct mt_data data[16]; int contactcount; - int x, y; }; #define SN_MOVE 100 @@ -145,6 +144,29 @@ static int ntrig_input_mapped(struct hid_device *hdev, struct hid_input *hi, return 0; } +static void report_frame(struct input_dev *input, struct ntrig_data *nd) +{ + int i, count = nd->contactcount; + for (i = 0; i < count; i++) { + struct mt_data *p = &nd->data[i]; + if (i == 0) { + input_report_key(input, BTN_TOUCH, 1); + input_report_abs(input, ABS_X, p->x); + input_report_abs(input, ABS_Y, p->y); + } + input_report_abs(input, ABS_MT_POSITION_X, p->x); + input_report_abs(input, ABS_MT_POSITION_Y, p->y); + input_report_abs(input, ABS_MT_TOUCH_MINOR, p->h); + input_report_abs(input, ABS_MT_TOUCH_MAJOR, p->w); + input_report_abs(input, ABS_MT_ORIENTATION, p->w > p->h); + input_mt_sync(input); + } + if (!count) { + input_report_key(input, BTN_TOUCH, 0); + } + input_sync(input); +} + /* * this function is called upon all reports * so that we can filter contact point information, @@ -157,7 +179,6 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field, struct input_dev *input = field->hidinput->input; struct ntrig_data *nd = hid_get_drvdata(hid); struct mt_data *p = &nd->data[nd->id]; - int i, count, mx, my; /* No special handling needed for the pen */ if (field->application == HID_DG_PEN) @@ -170,29 +191,6 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field, break; /* new mt packet */ case 0xff000001: - count = nd->contactcount; - mx = my = 0; - for (i = 0; i < count; i++) { - p = &nd->data[i]; - mx += p->x; - my += p->y; - input_report_abs(input, ABS_MT_POSITION_X, p->x); - input_report_abs(input, ABS_MT_POSITION_Y, p->y); - input_report_abs(input, ABS_MT_TOUCH_MINOR, p->h); - input_report_abs(input, ABS_MT_TOUCH_MAJOR, p->w); - input_report_abs(input, ABS_MT_ORIENTATION, p->w > p->h); - input_mt_sync(field->hidinput->input); - } - if (count > 0) { - nd->x = mx / count; - nd->y = my / count; - } - input_mt_sync(input); - input_report_key(input, BTN_TOUCH, count > 0); - input_report_abs(input, ABS_X, nd->x); - input_report_abs(input, ABS_Y, nd->y); - //input_sync(input); - p = &nd->data[nd->id = 0]; memset(p, 0, sizeof(*p)); break; @@ -203,8 +201,6 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field, p->confidence = value; break; case HID_DG_CONTACTID: - if (value >= 6) - break; p = &nd->data[nd->id = value]; memset(p, 0, sizeof(*p)); break; @@ -226,9 +222,9 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field, else printk(KERN_INFO "NTRIG: lots %d\n", value); break; - case HID_DG_CONTACTCOUNT: nd->contactcount = value; + report_frame(input, nd); break; default: -- cgit v1.2.3