summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@bitmath.org>2010-08-25 19:45:56 +0200
committerHenrik Rydberg <rydberg@bitmath.org>2010-08-25 19:45:56 +0200
commite4ef52b319f755ffd9fde547d4ac751e32b14e93 (patch)
tree5f384b6951c99f80cd6c34c70cdeb9f256a44afd /usr/src
parentfa669917d7ad99275056f1361c2c9d9f00997ba0 (diff)
works well for one finger
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/dkms_source_tree/hid-ntrig.c52
1 files changed, 24 insertions, 28 deletions
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 {
39 unsigned int id; 39 unsigned int id;
40 struct mt_data data[16]; 40 struct mt_data data[16];
41 int contactcount; 41 int contactcount;
42 int x, y;
43}; 42};
44 43
45#define SN_MOVE 100 44#define SN_MOVE 100
@@ -145,6 +144,29 @@ static int ntrig_input_mapped(struct hid_device *hdev, struct hid_input *hi,
145 return 0; 144 return 0;
146} 145}
147 146
147static void report_frame(struct input_dev *input, struct ntrig_data *nd)
148{
149 int i, count = nd->contactcount;
150 for (i = 0; i < count; i++) {
151 struct mt_data *p = &nd->data[i];
152 if (i == 0) {
153 input_report_key(input, BTN_TOUCH, 1);
154 input_report_abs(input, ABS_X, p->x);
155 input_report_abs(input, ABS_Y, p->y);
156 }
157 input_report_abs(input, ABS_MT_POSITION_X, p->x);
158 input_report_abs(input, ABS_MT_POSITION_Y, p->y);
159 input_report_abs(input, ABS_MT_TOUCH_MINOR, p->h);
160 input_report_abs(input, ABS_MT_TOUCH_MAJOR, p->w);
161 input_report_abs(input, ABS_MT_ORIENTATION, p->w > p->h);
162 input_mt_sync(input);
163 }
164 if (!count) {
165 input_report_key(input, BTN_TOUCH, 0);
166 }
167 input_sync(input);
168}
169
148/* 170/*
149 * this function is called upon all reports 171 * this function is called upon all reports
150 * so that we can filter contact point information, 172 * so that we can filter contact point information,
@@ -157,7 +179,6 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
157 struct input_dev *input = field->hidinput->input; 179 struct input_dev *input = field->hidinput->input;
158 struct ntrig_data *nd = hid_get_drvdata(hid); 180 struct ntrig_data *nd = hid_get_drvdata(hid);
159 struct mt_data *p = &nd->data[nd->id]; 181 struct mt_data *p = &nd->data[nd->id];
160 int i, count, mx, my;
161 182
162 /* No special handling needed for the pen */ 183 /* No special handling needed for the pen */
163 if (field->application == HID_DG_PEN) 184 if (field->application == HID_DG_PEN)
@@ -170,29 +191,6 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
170 break; 191 break;
171 /* new mt packet */ 192 /* new mt packet */
172 case 0xff000001: 193 case 0xff000001:
173 count = nd->contactcount;
174 mx = my = 0;
175 for (i = 0; i < count; i++) {
176 p = &nd->data[i];
177 mx += p->x;
178 my += p->y;
179 input_report_abs(input, ABS_MT_POSITION_X, p->x);
180 input_report_abs(input, ABS_MT_POSITION_Y, p->y);
181 input_report_abs(input, ABS_MT_TOUCH_MINOR, p->h);
182 input_report_abs(input, ABS_MT_TOUCH_MAJOR, p->w);
183 input_report_abs(input, ABS_MT_ORIENTATION, p->w > p->h);
184 input_mt_sync(field->hidinput->input);
185 }
186 if (count > 0) {
187 nd->x = mx / count;
188 nd->y = my / count;
189 }
190 input_mt_sync(input);
191 input_report_key(input, BTN_TOUCH, count > 0);
192 input_report_abs(input, ABS_X, nd->x);
193 input_report_abs(input, ABS_Y, nd->y);
194 //input_sync(input);
195
196 p = &nd->data[nd->id = 0]; 194 p = &nd->data[nd->id = 0];
197 memset(p, 0, sizeof(*p)); 195 memset(p, 0, sizeof(*p));
198 break; 196 break;
@@ -203,8 +201,6 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
203 p->confidence = value; 201 p->confidence = value;
204 break; 202 break;
205 case HID_DG_CONTACTID: 203 case HID_DG_CONTACTID:
206 if (value >= 6)
207 break;
208 p = &nd->data[nd->id = value]; 204 p = &nd->data[nd->id = value];
209 memset(p, 0, sizeof(*p)); 205 memset(p, 0, sizeof(*p));
210 break; 206 break;
@@ -226,9 +222,9 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
226 else 222 else
227 printk(KERN_INFO "NTRIG: lots %d\n", value); 223 printk(KERN_INFO "NTRIG: lots %d\n", value);
228 break; 224 break;
229
230 case HID_DG_CONTACTCOUNT: 225 case HID_DG_CONTACTCOUNT:
231 nd->contactcount = value; 226 nd->contactcount = value;
227 report_frame(input, nd);
232 break; 228 break;
233 229
234 default: 230 default: