📄 wacom.c
字号:
/* * $Id: wacom.c,v 1.1.1.1 2004/03/25 05:51:21 laputa Exp $ * * Copyright (c) 2000-2001 Vojtech Pavlik <vojtech@suse.cz> * Copyright (c) 2000 Andreas Bach Aaen <abach@stofanet.dk> * Copyright (c) 2000 Clifford Wolf <clifford@clifford.at> * Copyright (c) 2000 Sam Mosel <sam.mosel@computer.org> * Copyright (c) 2000 James E. Blair <corvus@gnu.org> * Copyright (c) 2000 Daniel Egger <egger@suse.de> * Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com> * * USB Wacom Graphire and Wacom Intuos tablet support * * Sponsored by SuSE * * ChangeLog: * v0.1 (vp) - Initial release * v0.2 (aba) - Support for all buttons / combinations * v0.3 (vp) - Support for Intuos added * v0.4 (sm) - Support for more Intuos models, menustrip * relative mode, proximity. * v0.5 (vp) - Big cleanup, nifty features removed, * they belong in userspace * v1.8 (vp) - Submit URB only when operating, moved to CVS, * use input_report_key instead of report_btn and * other cleanups * v1.11 (vp) - Add URB ->dev setting for new kernels * v1.11 (jb) - Add support for the 4D Mouse & Lens * v1.12 (de) - Add support for two more inking pen IDs * v1.14 (vp) - Use new USB device id probing scheme. * Fix Wacom Graphire mouse wheel * v1.18 (vp) - Fix mouse wheel direction * Make mouse relative * v1.20 (fl) - Report tool id for Intuos devices * - Multi tools support * - Corrected Intuos protocol decoding (airbrush, 4D mouse, lens cursor...) * - Add PL models support * - Fix Wacom Graphire mouse wheel again * v1.21 (vp) - Removed protocol descriptions * - Added MISC_SERIAL for tool serial numbers * (gb) - Identify version on module load. * v1.21.1 (fl) - added Graphire2 support * v1.21.2 (fl) - added Intuos2 support * - added all the PL ids * v1.21.3 (fl) - added another eraser id from Neil Okamoto * - added smooth filter for Graphire from Peri Hankey * - added PenPartner support from Olaf van Es * - new tool ids from Ole Martin Bjoerndalen *//* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Should you need to contact me, the author, you can do so either by * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail: * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic */#include <linux/kernel.h>#include <linux/slab.h>#include <linux/input.h>#include <linux/module.h>#include <linux/init.h>#include <linux/usb.h>/* * Version Information */#define DRIVER_VERSION "v1.21.3"#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@suse.cz>"#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver"MODULE_AUTHOR( DRIVER_AUTHOR );MODULE_DESCRIPTION( DRIVER_DESC );MODULE_LICENSE("GPL");#define USB_VENDOR_ID_WACOM 0x056astruct wacom_features { char *name; int pktlen; int x_max; int y_max; int pressure_max; int distance_max; void (*irq)(struct urb *urb); unsigned long evbit; unsigned long absbit; unsigned long relbit; unsigned long btnbit; unsigned long digibit;};struct wacom { signed char data[10]; struct input_dev dev; struct usb_device *usbdev; struct urb irq; struct wacom_features *features; int tool[2]; int open; __u32 serial[2];};static void wacom_pl_irq(struct urb *urb){ struct wacom *wacom = urb->context; unsigned char *data = wacom->data; struct input_dev *dev = &wacom->dev; int prox; if (urb->status) return; if (data[0] != 2) { printk(KERN_ERR "wacom_pl_irq: received unknown report #%d\n", data[0]); return; } prox = data[1] & 0x20; input_report_key(dev, BTN_TOOL_PEN, prox); if (prox) { int pressure = (data[4] & 0x04) >> 2 | ((__u32)(data[7] & 0x7f) << 1); input_report_abs(dev, ABS_X, data[3] | ((__u32)data[2] << 8) | ((__u32)(data[1] & 0x03) << 16)); input_report_abs(dev, ABS_Y, data[6] | ((__u32)data[5] << 8) | ((__u32)(data[4] & 0x03) << 8)); input_report_abs(dev, ABS_PRESSURE, (data[7] & 0x80) ? (255 - pressure) : (pressure + 255)); input_report_key(dev, BTN_TOUCH, data[4] & 0x08); input_report_key(dev, BTN_STYLUS, data[4] & 0x10); input_report_key(dev, BTN_STYLUS2, data[4] & 0x20); } input_event(dev, EV_MSC, MSC_SERIAL, 0);}static void wacom_penpartner_irq(struct urb *urb){ struct wacom *wacom = urb->context; unsigned char *data = wacom->data; struct input_dev *dev = &wacom->dev; int x, y; char pressure; int leftmb; if (urb->status) return; x = data[2] << 8 | data[1]; y = data[4] << 8 | data[3]; pressure = data[6]; leftmb = ((pressure > -80) && !(data[5] &20)); input_report_key(dev, BTN_TOOL_PEN, 1); input_report_abs(dev, ABS_X, x); input_report_abs(dev, ABS_Y, y); input_report_abs(dev, ABS_PRESSURE, pressure+127); input_report_key(dev, BTN_LEFT, leftmb); input_report_key(dev, BTN_RIGHT, (data[5] & 0x40)); input_event(dev, EV_MSC, MSC_SERIAL, leftmb);}static void wacom_graphire_irq(struct urb *urb){ struct wacom *wacom = urb->context; unsigned char *data = wacom->data; struct input_dev *dev = &wacom->dev; int x, y; if (urb->status) return; if (data[0] != 2) { printk(KERN_ERR "wacom_graphire_irq: received unknown report #%d\n", data[0]); return; } x = data[2] | ((__u32)data[3] << 8); y = data[4] | ((__u32)data[5] << 8); switch ((data[1] >> 5) & 3) { case 0: /* Pen */ input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x80); break; case 1: /* Rubber */ input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x80); break; case 2: /* Mouse */ input_report_key(dev, BTN_TOOL_MOUSE, data[7] > 24); input_report_key(dev, BTN_LEFT, data[1] & 0x01); input_report_key(dev, BTN_RIGHT, data[1] & 0x02); input_report_key(dev, BTN_MIDDLE, data[1] & 0x04); input_report_abs(dev, ABS_DISTANCE, data[7]); input_report_rel(dev, REL_WHEEL, (signed char) data[6]); input_report_abs(dev, ABS_X, x); input_report_abs(dev, ABS_Y, y); input_event(dev, EV_MSC, MSC_SERIAL, data[1] & 0x01); return; } if (data[1] & 0x80) { input_report_abs(dev, ABS_X, x); input_report_abs(dev, ABS_Y, y); } input_report_abs(dev, ABS_PRESSURE, data[6] | ((__u32)data[7] << 8)); input_report_key(dev, BTN_TOUCH, data[1] & 0x01); input_report_key(dev, BTN_STYLUS, data[1] & 0x02); input_report_key(dev, BTN_STYLUS2, data[1] & 0x04); input_event(dev, EV_MSC, MSC_SERIAL, data[1] & 0x01);}static void wacom_intuos_irq(struct urb *urb){ struct wacom *wacom = urb->context; unsigned char *data = wacom->data; struct input_dev *dev = &wacom->dev; unsigned int t; int idx; if (urb->status) return; if (data[0] != 2) { printk(KERN_ERR "wacom_intuos_irq: received unknown report #%d\n", data[0]); return; } /* tool number */ idx = data[1] & 0x01; if ((data[1] & 0xfc) == 0xc0) { /* Enter report */ wacom->serial[idx] = ((__u32)(data[3] & 0x0f) << 4) + /* serial number of the tool */ ((__u32)data[4] << 16) + ((__u32)data[5] << 12) + ((__u32)data[6] << 4) + (data[7] >> 4); switch (((__u32)data[2] << 4) | (data[3] >> 4)) { case 0x832: case 0x012: wacom->tool[idx] = BTN_TOOL_PENCIL; break; /* Inking pen */ case 0x822: case 0x852: case 0x022: wacom->tool[idx] = BTN_TOOL_PEN; break; /* Pen */ case 0x812: case 0x032: wacom->tool[idx] = BTN_TOOL_BRUSH; break; /* Stroke pen */ case 0x09c: case 0x007: case 0x094: wacom->tool[idx] = BTN_TOOL_MOUSE; break; /* Mouse 4D */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -