27 #include <linux/kernel.h>
28 #include <linux/slab.h>
29 #include <linux/module.h>
32 #include <linux/hid.h>
35 #ifdef CONFIG_USB_HID_MODULE
36 #include "../hid-ids.h"
42 #define DRIVER_VERSION "v1.6"
44 #define DRIVER_DESC "USB HID Boot Protocol mouse driver"
45 #define DRIVER_LICENSE "GPL"
55 struct input_dev *
dev;
62 static void usb_mouse_irq(
struct urb *
urb)
66 struct input_dev *
dev = mouse->
dev;
69 switch (urb->status) {
81 input_report_key(dev,
BTN_LEFT, data[0] & 0x01);
82 input_report_key(dev,
BTN_RIGHT, data[0] & 0x02);
83 input_report_key(dev,
BTN_MIDDLE, data[0] & 0x04);
84 input_report_key(dev,
BTN_SIDE, data[0] & 0x08);
85 input_report_key(dev,
BTN_EXTRA, data[0] & 0x10);
87 input_report_rel(dev,
REL_X, data[1]);
88 input_report_rel(dev,
REL_Y, data[2]);
89 input_report_rel(dev,
REL_WHEEL, data[3]);
96 "can't resubmit intr, %s-%s/input0, status %d\n",
97 mouse->
usbdev->bus->bus_name,
98 mouse->
usbdev->devpath, status);
101 static int usb_mouse_open(
struct input_dev *dev)
103 struct usb_mouse *mouse = input_get_drvdata(dev);
112 static void usb_mouse_close(
struct input_dev *dev)
114 struct usb_mouse *mouse = input_get_drvdata(dev);
121 struct usb_device *dev = interface_to_usbdev(intf);
125 struct input_dev *input_dev;
129 interface = intf->cur_altsetting;
131 if (interface->desc.bNumEndpoints != 1)
134 endpoint = &interface->endpoint[0].desc;
135 if (!usb_endpoint_is_int_in(endpoint))
139 maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
142 input_dev = input_allocate_device();
143 if (!mouse || !input_dev)
155 mouse->
dev = input_dev;
157 if (dev->manufacturer)
161 if (dev->manufacturer)
168 "USB HIDBP Mouse %04x:%04x",
172 usb_make_path(dev, mouse->
phys,
sizeof(mouse->
phys));
175 input_dev->name = mouse->
name;
176 input_dev->phys = mouse->
phys;
177 usb_to_input_id(dev, &input_dev->id);
178 input_dev->dev.parent = &intf->dev;
188 input_set_drvdata(input_dev, mouse);
190 input_dev->open = usb_mouse_open;
191 input_dev->close = usb_mouse_close;
193 usb_fill_int_urb(mouse->
irq, dev, pipe, mouse->
data,
194 (maxp > 8 ? 8 : maxp),
195 usb_mouse_irq, mouse, endpoint->
bInterval);
197 mouse->
irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
199 error = input_register_device(mouse->
dev);
203 usb_set_intfdata(intf, mouse);
211 input_free_device(input_dev);
218 struct usb_mouse *mouse = usb_get_intfdata (intf);
220 usb_set_intfdata(intf,
NULL);
223 input_unregister_device(mouse->
dev);
238 static struct usb_driver usb_mouse_driver = {
240 .probe = usb_mouse_probe,
241 .disconnect = usb_mouse_disconnect,
242 .id_table = usb_mouse_id_table,