Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 147537 | Differences between
and this patch

Collapse All | Expand All

(-)src/xdrv/wcmISDV4.c.original (-89 / +47 lines)
Lines 99-107 Link Here
99
{  
99
{  
100
	/* set parameters */
100
	/* set parameters */
101
	common->wcmProtocolLevel = 4;
101
	common->wcmProtocolLevel = 4;
102
	common->wcmPktLength = 5;       /* length of a packet 
102
	common->wcmPktLength = 9; 	
103
					 * device packets are 9 bytes long,
104
					 * multitouch are only 5 */
105
	common->wcmResolX = 2540; 	/* tablet X resolution in points/inch */
103
	common->wcmResolX = 2540; 	/* tablet X resolution in points/inch */
106
	common->wcmResolY = 2540; 	/* tablet Y resolution in points/inch */
104
	common->wcmResolY = 2540; 	/* tablet Y resolution in points/inch */
107
	common->wcmTPCButton = 1;	/* Tablet PC buttons on by default */
105
	common->wcmTPCButton = 1;	/* Tablet PC buttons on by default */
Lines 206-232 Link Here
206
	WacomCommonPtr common = priv->common;
204
	WacomCommonPtr common = priv->common;
207
	WacomDeviceState* last = &common->wcmChannel[0].valid.state;
205
	WacomDeviceState* last = &common->wcmChannel[0].valid.state;
208
	WacomDeviceState* ds;
206
	WacomDeviceState* ds;
209
	int n, cur_type, ismt = 0;
207
	int n, cur_type;
210
	static int lastismt = 0;
208
	static int lastismt = 0;
211
209
212
	DBG(10, common->debugLevel, ErrorF("isdv4Parse \n"));
210
	DBG(10, common->debugLevel, ErrorF("isdv4Parse \n"));
213
211
214
	/* determine the type of message */
215
	if (data[0] & 0x10)
216
	{
217
		ismt = 1;
218
		common->wcmPktLength = 5;
219
	}
220
	else
221
	{
222
		common->wcmPktLength = 9;
223
		if (common->buffer + common->bufpos - data < common->wcmPktLength)
224
		{
225
			/* we can't handle this yet */
226
			return 0;
227
		}
228
	}
229
230
	if ((n = xf86WcmSerialValidate(common,data)) > 0)
212
	if ((n = xf86WcmSerialValidate(common,data)) > 0)
231
		return n;
213
		return n;
232
	else
214
	else
Lines 239-319 Link Here
239
	ds = &common->wcmChannel[0].work;
221
	ds = &common->wcmChannel[0].work;
240
	RESET_RELATIVE(*ds);
222
	RESET_RELATIVE(*ds);
241
223
242
	if (ismt)
224
	ds->proximity = (data[0] & 0x20);
243
	{
244
		if (!lastismt && last->pressure)
245
		{
246
			/* pen sends both pen and MultiTouch input, 
247
			 * since pressing it creates pressure. 
248
			 * We only want the pen input though.
249
			 */
250
			return common->wcmPktLength;
251
		}
252
		lastismt = ismt;
253
254
		/* MultiTouch input is comparably simple */
255
		ds->proximity = 0;
256
		ds->x = (((((int)data[1]) << 7) | ((int)data[2])) - 18) * common->wcmMaxX / 926;
257
		ds->y = (((((int)data[3]) << 7) | ((int)data[4])) - 51) * common->wcmMaxY / 934;
258
		ds->pressure = (data[0] & 0x01) * common->wcmMaxZ;
259
		ds->buttons = 1;
260
		ds->device_id = STYLUS_DEVICE_ID;
261
		ds->device_type = 0;
262
		DBG(8, priv->debugLevel, ErrorF("isdv4Parse MultiTouch\n"));
263
	}
264
	else
265
	{
266
		ds->proximity = (data[0] & 0x20);
267
268
		/* x and y in "normal" orientetion (wide length is X) */
269
		ds->x = (((int)data[6] & 0x60) >> 5) | ((int)data[2] << 2) |
270
			((int)data[1] << 9);
271
		ds->y = (((int)data[6] & 0x18) >> 3) | ((int)data[4] << 2) |
272
			((int)data[3] << 9);
273
274
		/* pressure */
275
		ds->pressure = (((data[6] & 0x07) << 7) | data[5] );
276
277
		/* buttons */
278
		ds->buttons = (data[0] & 0x07);
279
225
280
		/* check which device we have */
226
	/* x and y in "normal" orientetion (wide length is X) */
281
		cur_type = (ds->buttons & 4) ? ERASER_ID : STYLUS_ID;
227
	ds->x = (((int)data[6] & 0x60) >> 5) | ((int)data[2] << 2) |
282
228
		((int)data[1] << 9);
283
		/* first time into prox */
229
	ds->y = (((int)data[6] & 0x18) >> 3) | ((int)data[4] << 2) |
284
		if (!last->proximity && ds->proximity) 
230
		((int)data[3] << 9);
231
232
	/* pressure */
233
	ds->pressure = (((data[6] & 0x07) << 7) | data[5] );
234
235
	/* buttons */
236
	ds->buttons = (data[0] & 0x07);
237
238
	/* check which device we have */
239
	cur_type = (ds->buttons & 4) ? ERASER_ID : STYLUS_ID;
240
241
	/* first time into prox */
242
	if (!last->proximity && ds->proximity) 
243
		ds->device_type = cur_type;
244
	/* check on previous proximity */
245
	else if (cur_type == STYLUS_ID && ds->proximity)
246
	{
247
		/* we were fooled by tip and second
248
		 * sideswitch when it came into prox */
249
		if ((ds->device_type != cur_type) &&
250
			(ds->device_type == ERASER_ID))
251
		{
252
			/* send a prox-out for old device */
253
			WacomDeviceState out = { 0 };
254
			xf86WcmEvent(common, 0, &out);
285
			ds->device_type = cur_type;
255
			ds->device_type = cur_type;
286
		/* check on previous proximity */
287
		else if (cur_type == STYLUS_ID && ds->proximity)
288
		{
289
			/* we were fooled by tip and second
290
			 * sideswitch when it came into prox */
291
			if ((ds->device_type != cur_type) &&
292
				(ds->device_type == ERASER_ID))
293
			{
294
				/* send a prox-out for old device */
295
				WacomDeviceState out = { 0 };
296
				xf86WcmEvent(common, 0, &out);
297
				ds->device_type = cur_type;
298
			}
299
		}
256
		}
257
	}
300
258
301
		ds->device_id = (ds->device_type == CURSOR_ID) ? 
259
	ds->device_id = (ds->device_type == CURSOR_ID) ? 
302
			CURSOR_DEVICE_ID : STYLUS_DEVICE_ID;
260
		CURSOR_DEVICE_ID : STYLUS_DEVICE_ID;
303
304
		/* don't send button 3 event for eraser 
305
		 * button 1 event will be sent by testing presure level
306
		 */
307
		if (ds->device_type == ERASER_ID && ds->buttons&4)
308
		{
309
			ds->buttons = 0;
310
			ds->device_id = ERASER_DEVICE_ID;
311
		}
312
261
313
		DBG(8, priv->debugLevel, ErrorF("isdv4Parse %s\n",
262
	/* don't send button 3 event for eraser 
314
			ds->device_type == ERASER_ID ? "ERASER " :
263
	 * button 1 event will be sent by testing presure level
315
			ds->device_type == STYLUS_ID ? "STYLUS" : "NONE"));
264
	 */
265
	if (ds->device_type == ERASER_ID && ds->buttons&4)
266
	{
267
		ds->buttons = 0;
268
		ds->device_id = ERASER_DEVICE_ID;
316
	}
269
	}
270
271
	DBG(8, priv->debugLevel, ErrorF("isdv4Parse %s\n",
272
		ds->device_type == ERASER_ID ? "ERASER " :
273
		ds->device_type == STYLUS_ID ? "STYLUS" : "NONE"));
274
317
	xf86WcmEvent(common,0,ds);
275
	xf86WcmEvent(common,0,ds);
318
	return common->wcmPktLength;
276
	return common->wcmPktLength;
319
}
277
}

Return to bug 147537