⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wacom.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 3 页
字号:
				/* I3 marker pen rotation reported as wheel				 * due to valuator limitation				 */				t = (data[6] << 3) | ((data[7] >> 5) & 7);				t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :					((t-1) / 2 + 450)) : (450 - t / 2) ;				input_report_abs(dev, ABS_WHEEL, t);			} else {				/* 4D mouse rotation packet */				t = (data[6] << 3) | ((data[7] >> 5) & 7);				input_report_abs(dev, ABS_RZ, (data[7] & 0x20) ?					((t - 1) / 2) : -t / 2);			}		} else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3) {			/* 4D mouse packet */			input_report_key(dev, BTN_LEFT,   data[8] & 0x01);			input_report_key(dev, BTN_MIDDLE, data[8] & 0x02);			input_report_key(dev, BTN_RIGHT,  data[8] & 0x04);			input_report_key(dev, BTN_SIDE,   data[8] & 0x20);			input_report_key(dev, BTN_EXTRA,  data[8] & 0x10);			t = (data[6] << 2) | ((data[7] >> 6) & 3);			input_report_abs(dev, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);		} else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {			/* 2D mouse packet */			input_report_key(dev, BTN_LEFT,   data[8] & 0x04);			input_report_key(dev, BTN_MIDDLE, data[8] & 0x08);			input_report_key(dev, BTN_RIGHT,  data[8] & 0x10);			input_report_rel(dev, REL_WHEEL, ((data[8] & 0x02) >> 1)						 - (data[8] & 0x01));			/* I3 2D mouse side buttons */			if (wacom->features->type == INTUOS3) {				input_report_key(dev, BTN_SIDE,   data[8] & 0x40);				input_report_key(dev, BTN_EXTRA,  data[8] & 0x20);			}		} else if (wacom->features->type < INTUOS3) {			/* Lens cursor packets */			input_report_key(dev, BTN_LEFT,   data[8] & 0x01);			input_report_key(dev, BTN_MIDDLE, data[8] & 0x02);			input_report_key(dev, BTN_RIGHT,  data[8] & 0x04);			input_report_key(dev, BTN_SIDE,   data[8] & 0x10);			input_report_key(dev, BTN_EXTRA,  data[8] & 0x08);		}	}	input_report_key(dev, wacom->tool[idx], wacom->id[idx]);	input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);	input_sync(dev);exit:	retval = usb_submit_urb (urb, GFP_ATOMIC);	if (retval)		err ("%s - usb_submit_urb failed with result %d",		    __FUNCTION__, retval);}static struct wacom_features wacom_features[] = {	{ "Wacom Penpartner",    7,   5040,  3780,  255, 32, PENPARTNER, wacom_penpartner_irq },        { "Wacom Graphire",      8,  10206,  7422,  511, 32, GRAPHIRE,   wacom_graphire_irq },	{ "Wacom Graphire2 4x5", 8,  10206,  7422,  511, 32, GRAPHIRE,   wacom_graphire_irq },	{ "Wacom Graphire2 5x7", 8,  13918, 10206,  511, 32, GRAPHIRE,   wacom_graphire_irq },	{ "Wacom Graphire3",     8,  10208,  7424,  511, 32, GRAPHIRE,   wacom_graphire_irq },	{ "Wacom Graphire3 6x8", 8,  16704, 12064,  511, 32, GRAPHIRE,   wacom_graphire_irq },	{ "Wacom Graphire4 4x5", 8,  10208,  7424,  511, 32, G4,	 wacom_graphire_irq },	{ "Wacom Graphire4 6x8", 8,  16704, 12064,  511, 32, G4,	 wacom_graphire_irq },	{ "Wacom Volito",        8,   5104,  3712,  511, 32, GRAPHIRE,   wacom_graphire_irq },	{ "Wacom PenStation2",   8,   3250,  2320,  255, 32, GRAPHIRE,   wacom_graphire_irq },	{ "Wacom Volito2 4x5",   8,   5104,  3712,  511, 32, GRAPHIRE,   wacom_graphire_irq },	{ "Wacom Volito2 2x3",   8,   3248,  2320,  511, 32, GRAPHIRE,   wacom_graphire_irq },	{ "Wacom PenPartner2",   8,   3250,  2320,  255, 32, GRAPHIRE,   wacom_graphire_irq },	{ "Wacom Intuos 4x5",   10,  12700, 10600, 1023, 15, INTUOS,     wacom_intuos_irq },	{ "Wacom Intuos 6x8",   10,  20320, 16240, 1023, 15, INTUOS,     wacom_intuos_irq },	{ "Wacom Intuos 9x12",  10,  30480, 24060, 1023, 15, INTUOS,     wacom_intuos_irq },	{ "Wacom Intuos 12x12", 10,  30480, 31680, 1023, 15, INTUOS,     wacom_intuos_irq },	{ "Wacom Intuos 12x18", 10,  45720, 31680, 1023, 15, INTUOS,     wacom_intuos_irq },	{ "Wacom PL400",         8,   5408,  4056,  255, 32, PL,         wacom_pl_irq },	{ "Wacom PL500",         8,   6144,  4608,  255, 32, PL,         wacom_pl_irq },	{ "Wacom PL600",         8,   6126,  4604,  255, 32, PL,         wacom_pl_irq },	{ "Wacom PL600SX",       8,   6260,  5016,  255, 32, PL,         wacom_pl_irq },	{ "Wacom PL550",         8,   6144,  4608,  511, 32, PL,         wacom_pl_irq },	{ "Wacom PL800",         8,   7220,  5780,  511, 32, PL,         wacom_pl_irq },	{ "Wacom PL700",         8,   6758,  5406,  511, 32, PL,	 wacom_pl_irq },	{ "Wacom PL510",         8,   6282,  4762,  511, 32, PL,	 wacom_pl_irq },	{ "Wacom PL710",         8,  34080, 27660,  511, 32, PL,	 wacom_pl_irq },	{ "Wacom DTF720",        8,   6858,  5506,  511, 32, PL,	 wacom_pl_irq },	{ "Wacom Cintiq Partner",8,  20480, 15360,  511, 32, PL,         wacom_ptu_irq },	{ "Wacom Intuos2 4x5",   10, 12700, 10600, 1023, 15, INTUOS,     wacom_intuos_irq },	{ "Wacom Intuos2 6x8",   10, 20320, 16240, 1023, 15, INTUOS,     wacom_intuos_irq },	{ "Wacom Intuos2 9x12",  10, 30480, 24060, 1023, 15, INTUOS,     wacom_intuos_irq },	{ "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, INTUOS,     wacom_intuos_irq },	{ "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, INTUOS,     wacom_intuos_irq },	{ "Wacom Intuos3 4x5",   10, 25400, 20320, 1023, 15, INTUOS3,    wacom_intuos_irq },	{ "Wacom Intuos3 6x8",   10, 40640, 30480, 1023, 15, INTUOS3,    wacom_intuos_irq },	{ "Wacom Intuos3 9x12",  10, 60960, 45720, 1023, 15, INTUOS3,    wacom_intuos_irq },	{ "Wacom Intuos3 6x11",  10, 54204, 31750, 1023, 15, INTUOS3,    wacom_intuos_irq },	{ "Wacom Cintiq 21UX",   10, 87200, 65600, 1023, 15, CINTIQ,     wacom_intuos_irq },	{ "Wacom Intuos2 6x8",   10, 20320, 16240, 1023, 15, INTUOS,     wacom_intuos_irq },	{ }};static struct usb_device_id wacom_ids[] = {	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },	{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },	{ }};MODULE_DEVICE_TABLE(usb, wacom_ids);static int wacom_open(struct input_dev *dev){	struct wacom *wacom = dev->private;	wacom->irq->dev = wacom->usbdev;	if (usb_submit_urb(wacom->irq, GFP_KERNEL))		return -EIO;	return 0;}static void wacom_close(struct input_dev *dev){	struct wacom *wacom = dev->private;	usb_kill_urb(wacom->irq);}static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id){	struct usb_device *dev = interface_to_usbdev(intf);	struct usb_endpoint_descriptor *endpoint;	struct wacom *wacom;	struct input_dev *input_dev;	char rep_data[2] = {0x02, 0x02};	wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);	input_dev = input_allocate_device();	if (!wacom || !input_dev)		goto fail1;	wacom->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma);	if (!wacom->data)		goto fail1;	wacom->irq = usb_alloc_urb(0, GFP_KERNEL);	if (!wacom->irq)		goto fail2;	wacom->usbdev = dev;	wacom->dev = input_dev;	usb_make_path(dev, wacom->phys, sizeof(wacom->phys));	strlcat(wacom->phys, "/input0", sizeof(wacom->phys));	wacom->features = wacom_features + (id - wacom_ids);	if (wacom->features->pktlen > 10)		BUG();	input_dev->name = wacom->features->name;	usb_to_input_id(dev, &input_dev->id);	input_dev->cdev.dev = &intf->dev;	input_dev->private = wacom;	input_dev->open = wacom_open;	input_dev->close = wacom_close;	input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS);	input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS);	input_set_abs_params(input_dev, ABS_X, 0, wacom->features->x_max, 4, 0);	input_set_abs_params(input_dev, ABS_Y, 0, wacom->features->y_max, 4, 0);	input_set_abs_params(input_dev, ABS_PRESSURE, 0, wacom->features->pressure_max, 0, 0);	switch (wacom->features->type) {		case G4:			input_dev->evbit[0] |= BIT(EV_MSC);			input_dev->mscbit[0] |= BIT(MSC_SERIAL);			input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);			input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7);			/* fall through */		case GRAPHIRE:			input_dev->evbit[0] |= BIT(EV_REL);			input_dev->relbit[0] |= BIT(REL_WHEEL);			input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);			input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2);			input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom->features->distance_max, 0, 0);			break;		case INTUOS3:		case CINTIQ:			input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);			input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7);			input_set_abs_params(input_dev, ABS_RX, 0, 4097, 0, 0);			input_set_abs_params(input_dev, ABS_RY, 0, 4097, 0, 0);			/* fall through */		case INTUOS:			input_dev->evbit[0] |= BIT(EV_MSC) | BIT(EV_REL);			input_dev->mscbit[0] |= BIT(MSC_SERIAL);			input_dev->relbit[0] |= BIT(REL_WHEEL);			input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA);			input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE)	| BIT(BTN_TOOL_BRUSH)							  | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2);			input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom->features->distance_max, 0, 0);			input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);			input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);			input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);			input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);			input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);			break;		case PL:			input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER);			break;	}	endpoint = &intf->cur_altsetting->endpoint[0].desc;	if (wacom->features->pktlen > 10)		BUG();	usb_fill_int_urb(wacom->irq, dev,			 usb_rcvintpipe(dev, endpoint->bEndpointAddress),			 wacom->data, wacom->features->pktlen,			 wacom->features->irq, wacom, endpoint->bInterval);	wacom->irq->transfer_dma = wacom->data_dma;	wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;	input_register_device(wacom->dev);	/* ask the tablet to report tablet data */	usb_set_report(intf, 3, 2, rep_data, 2);	/* repeat once (not sure why the first call often fails) */	usb_set_report(intf, 3, 2, rep_data, 2);	usb_set_intfdata(intf, wacom);	return 0;fail2:	usb_buffer_free(dev, 10, wacom->data, wacom->data_dma);fail1:	input_free_device(input_dev);	kfree(wacom);	return -ENOMEM;}static void wacom_disconnect(struct usb_interface *intf){	struct wacom *wacom = usb_get_intfdata (intf);	usb_set_intfdata(intf, NULL);	if (wacom) {		usb_kill_urb(wacom->irq);		input_unregister_device(wacom->dev);		usb_free_urb(wacom->irq);		usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma);		kfree(wacom);	}}static struct usb_driver wacom_driver = {	.owner =	THIS_MODULE,	.name =		"wacom",	.probe =	wacom_probe,	.disconnect =	wacom_disconnect,	.id_table =	wacom_ids,};static int __init wacom_init(void){	int result = usb_register(&wacom_driver);	if (result == 0)		info(DRIVER_VERSION ":" DRIVER_DESC);	return result;}static void __exit wacom_exit(void){	usb_deregister(&wacom_driver);}module_init(wacom_init);module_exit(wacom_exit);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -