Hi!

This is an update and cleanup of the input drivers for USB for 2.4.
It's mainly documentation and comment update, but it also contains a
couple other changes:

input.c: Add noise filtering for EV_ABS. Not used yet by the USB
        drivers, but will be very useful in the future.

hid.c,usbkbd.c,usbmouse.c,wacom.c: Sumbit the interrupt URB only when
        the device is in use. Trivial change.

all: Add KERN_* to all printk's that were missing it.

usbmouse.c: Removed the USBMOUSE_EXTRA define. Noone ever has used it.

wacom.c: change input_report_btn to input_report_key to keep things
        consistent. One macro less. Good. Added more tool IDs.

wmforce.c: fix max and min values for throttle axis

input.h: cleanups

Hope this will make it in before 2.4.0-final.

-- 
Vojtech Pavlik
SuSE Labs
diff -urN linux-2.4.0-test1-ac4-old/Documentation/Configure.help 
linux/Documentation/Configure.help
--- linux-2.4.0-test1-ac4-old/Documentation/Configure.help      Sun May 28 11:50:55 
2000
+++ linux/Documentation/Configure.help  Sun May 28 19:46:15 2000
@@ -9584,7 +9584,7 @@
 USB Human Interface Device (HID) support
 CONFIG_USB_HID
   Say Y here if you want to connect keyboards, mice, joysticks,
-  graphic tablets, UPS's or any other HID based devices to your
+  graphic tablets, or any other HID based devices to your
   computer via USB. More information is available:
   Documentation/usb/input.txt.
 
@@ -9616,16 +9616,16 @@
 
   This code is also available as a module ( = code which can be
   inserted in and removed from the running kernel whenever you want).
-  The module will be called usbmouse.o. If you want to compile it as a
-  module, say M here and read Documentation/modules.txt.
+  The module will be called usbmouse.o. If you want to compile it as
+  a module, say M here and read Documentation/modules.txt.
 
   If unsure, say N.
 
 Wacom Intuos/Graphire tablet support
 CONFIG_USB_WACOM
-  Say Y here if you want to use the USB version of the Wacom Intuos or
-  Graphire tablet. Make sure to say Y to "Mouse support"
-  (CONFIG_INPUT_MOUSEDEV) and "Event interface support"
+  Say Y here if you want to use the USB version of the Wacom Intuos
+  or Graphire tablet. Make sure to say Y to "Mouse support"
+  (CONFIG_INPUT_MOUSEDEV) and/or "Event interface support"
   (CONFIG_INPUT_EVDEV) as well.
 
   This driver is also available as a module ( = code which can be
@@ -9636,7 +9636,7 @@
 Logitech WingMan Force joystick support
 CONFIG_USB_WMFORCE
   Say Y here if you want to use the Logitech WingMan Force with Linux
-  on the USB port. No force-feedback support yet, but other than that,
+  on the USB port. No force-feedback support yet, but other than that
   it should work like a normal joystick.
 
   This driver is also available as a module ( = code which can be
@@ -9657,31 +9657,35 @@
 Mouse support
 CONFIG_INPUT_MOUSEDEV
   Say Y here if you want your USB HID mouse to be accessible as
-  misc devices 32+ under /dev/, as an emulated PS/2 mouse. That way,
-  all user space programs will be able to use your mouse.
+  char devices 13:32+ - /dev/input/mouseX and 13:63 - /dev/input/mice
+  as an emulated PS/2 mouse.  That way, all user space programs will
+  be able to use your mouse.
   
   If unsure, say Y.
 
   This driver is also available as a module ( = code which can be
   inserted in and removed from the running kernel whenever you want).
-  The module will be called mousedev.o. If you want to compile it as a
-  module, say M here and read Documentation/modules.txt.
+  The module will be called mousedev.o. If you want to compile it as
+  a module, say M here and read Documentation/modules.txt.
 
 Horizontal screen resolution
 CONFIG_INPUT_MOUSEDEV_SCREEN_X
-  For the mouse emulation to be correct, the mousedev driver needs to
-  know the screen resolution you are using (in the X window system).
+  If you're using a digitizer, or a graphic tablet, and want to use
+  it as a mouse then the mousedev driver needs to know the X window
+  screen resolution you are using to correctly scale the data. If
+  you're not using a digitizer, this value is ignored.
 
 Vertical screen resolution
 CONFIG_INPUT_MOUSEDEV_SCREEN_Y
-  For the mouse emulation to be correct, the mousedev driver needs to
-  know the screen resolution you are using (in the X window system).
+  If you're using a digitizer, or a graphic tablet, and want to use
+  it as a mouse then the mousedev driver needs to know the X window
+  screen resolution you are using to correctly scale the data. If
+  you're not using a digitizer, this value is ignored.
 
 Joystick support
 CONFIG_INPUT_JOYDEV
   Say Y here if you want your USB HID joystick or gamepad to be
-  accessible as a /dev/js device. You can't use a normal (non-USB)
-  joystick if you say Y here.
+  accessible as char device 13:0+ - /dev/input/jsX device. 
 
   This driver is also available as a module ( = code which can be
   inserted in and removed from the running kernel whenever you want).
@@ -9691,7 +9695,7 @@
 Event interface support
 CONFIG_INPUT_EVDEV
   Say Y here if you want your USB HID device events be accessible
-  under /dev/inputX (misc 64+) in a generic way.
+  under char device 13:64+ - /dev/inputX in a generic way.
   This is the future ...
 
 USB Scanner support
diff -urN linux-2.4.0-test1-ac4-old/Documentation/usb/input.txt 
linux/Documentation/usb/input.txt
--- linux-2.4.0-test1-ac4-old/Documentation/usb/input.txt       Thu May 11 01:56:44 
2000
+++ linux/Documentation/usb/input.txt   Sun May 28 19:57:48 2000
@@ -1,6 +1,7 @@
-                         Linux Input drivers v0.9
-                (c) 1999 Vojtech Pavlik <[EMAIL PROTECTED]>
+                         Linux Input drivers v1.0
+              (c) 1999-2000 Vojtech Pavlik <[EMAIL PROTECTED]>
                             Sponsored by SuSE
+           $Id: input.txt,v 1.4 2000/05/28 17:57:22 vojtech Exp $
 ----------------------------------------------------------------------------
 
 0. Disclaimer
@@ -62,27 +63,27 @@
        hid.o
 
   After this, the USB keyboard will work straight away, and the USB mouse
-will be available as a character device on major 13, minor 32:
+will be available as a character device on major 13, minor 63:
 
-       crw-r--r--   1 root     root      13,  32 Mar 28 22:45 mouse0
+       crw-r--r--   1 root     root      13,  63 Mar 28 22:45 mice
 
   This device, has to be created, unless you use devfs, in which case it's
 created automatically. The commands to do that are:
 
        cd /dev
        mkdir input
-       mknod input/mouse0 c 13 32
+       mknod input/mice c 13 63
 
   After that you have to point GPM (the textmode mouse cut&paste tool) and
 XFree to this device to use it - GPM should be called like:
 
-       gpm -t ps2 -m /dev/input/mouse0
+       gpm -t ps2 -m /dev/input/mice
 
   And in X:
 
        Section "Pointer"
            Protocol    "ImPS/2"
-           Device      "/dev/input/mouse0"
+           Device      "/dev/input/mice"
            ZAxisMapping 4 5
        EndSection
 
@@ -199,10 +200,11 @@
   CONFIG_INPUT_MOUSEDEV_SCREEN_[XY] in the kernel configuration are the size
 of your screen (in pixels) in XFree86. This is needed if you want to use
 your digitizer in X, because it's movement is sent to X via a virtual PS/2
-mouse. These values won't be used if you use a mouse only.
+mouse and thus needs to be scaled accordingly. These values won't be used if
+you use a mouse only.
 
-  Mousedev.c will generate either PS/2, ImPS/2 (microsoft intellimouse) or
-GenPS/2 (genius netmouse/netscroll) protocols, depending on what the program
+  Mousedev will generate either PS/2, ImPS/2 (Microsoft IntelliMouse) or
+GenPS/2 (Genius NetMouse/NetScroll) protocols, depending on what the program
 reading the data wishes. You can set GPM and X to any of these. You'll need
 ImPS/2 if you want to make use of a wheel on a USB mouse and GenPS/2 if you
 want to use extra (up to 5) buttons. I'm not sure how much is GenPS/2 supported
@@ -249,8 +251,12 @@
 
        http://www.suse.cz/development/input/
 
-You'll find both the latest HID driver and the complete Input driver there.
-There is also a mailing list for this:
+You'll find both the latest HID driver and the complete Input driver there
+as well as information how to access the CVS repository for latest revisions
+of the drivers.
+
+
+  There is also a mailing list for this:
 
        [EMAIL PROTECTED]
 
@@ -278,8 +284,8 @@
 to be extended, but not changed incompatibly as time goes:
 
   You can use blocking and nonblocking reads, also select() on the
-/dev/inputX devices, and you'll always get a whole number of input events on
-a read. Their layout is:
+/dev/input/eventX devices, and you'll always get a whole number of input
+events on a read. Their layout is:
 
 struct input_event {
        struct timeval time;
diff -urN linux-2.4.0-test1-ac4-old/drivers/usb/evdev.c linux/drivers/usb/evdev.c
--- linux-2.4.0-test1-ac4-old/drivers/usb/evdev.c       Fri Apr 21 22:22:23 2000
+++ linux/drivers/usb/evdev.c   Sun May 28 19:33:58 2000
@@ -1,7 +1,7 @@
 /*
- *  evdev.c  Version 0.1
+ * $Id: evdev.c,v 1.7 2000/05/28 17:31:36 vojtech Exp $
  *
- *  Copyright (c) 1999 Vojtech Pavlik
+ *  Copyright (c) 1999-2000 Vojtech Pavlik
  *
  *  Event char devices, giving access to raw input device events.
  *
@@ -212,9 +212,6 @@
 
                case EVIOCGVERSION:
                        return put_user(EV_VERSION, (__u32 *) arg);
-               case EVIOCGID:
-                       return copy_to_user(&dev->id, (void *) arg,
-                                               sizeof(struct input_id)) ? -EFAULT : 0;
                default:
 
                        if (_IOC_TYPE(cmd) != 'E' || _IOC_DIR(cmd) != _IOC_READ)
@@ -286,7 +283,7 @@
 
        evdev->devfs = input_register_minor("event%d", minor, EVDEV_MINOR_BASE);
 
-       printk("event%d: Event device for input%d\n", minor, dev->number);
+       printk(KERN_INFO "event%d: Event device for input%d\n", minor, dev->number);
 
        return &evdev->handle;
 }
diff -urN linux-2.4.0-test1-ac4-old/drivers/usb/hid.c linux/drivers/usb/hid.c
--- linux-2.4.0-test1-ac4-old/drivers/usb/hid.c Tue May  9 00:48:18 2000
+++ linux/drivers/usb/hid.c     Sun May 28 19:33:58 2000
@@ -1,5 +1,5 @@
 /*
- *  hid.c  Version 0.8
+ * $Id: hid.c,v 1.5 2000/05/28 17:31:36 vojtech Exp $
  *
  *  Copyright (c) 1999 Andreas Gal
  *  Copyright (c) 2000 Vojtech Pavlik
@@ -1259,6 +1259,27 @@
        return 0;
 }
 
+static int hid_open(struct input_dev *dev)
+{
+       struct hid_device *hid = dev->private;
+
+       if (hid->open++)
+               return 0;
+
+        if (usb_submit_urb(&hid->urb))
+               return -EIO;
+
+       return 0;
+}
+
+static void hid_close(struct input_dev *dev)
+{
+       struct hid_device *hid = dev->private;
+
+       if (!--hid->open)
+               usb_unlink_urb(&hid->urb);
+}
+
 /*
  * Configure the input layer interface
  * Read all reports and initalize the absoulte field values.
@@ -1272,6 +1293,8 @@
 
        hid->input.private = hid;
        hid->input.event = hid_event;
+       hid->input.open = hid_open;
+       hid->input.close = hid_close;
 
        for (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++) {
 
@@ -1380,11 +1403,6 @@
 
                FILL_INT_URB(&hid->urb, dev, pipe, hid->buffer, maxp > 32 ? 32 : maxp, 
hid_irq, hid, endpoint->bInterval);
        
-               if (usb_submit_urb(&hid->urb)) {
-                       dbg("submitting interrupt URB failed");
-                       continue;
-               }
-
                break;
        }
 
diff -urN linux-2.4.0-test1-ac4-old/drivers/usb/hid.h linux/drivers/usb/hid.h
--- linux-2.4.0-test1-ac4-old/drivers/usb/hid.h Mon Mar 20 03:29:40 2000
+++ linux/drivers/usb/hid.h     Sun May 28 19:33:58 2000
@@ -2,7 +2,7 @@
 #define __HID_H
 
 /*
- *  drivers/usb/hid.h  Version 0.8
+ * $Id: hid.h,v 1.3 2000/05/28 17:31:36 vojtech Exp $
  *
  *  Copyright (c) 1999 Andreas Gal
  *  Copyright (c) 2000 Vojtech Pavlik
@@ -292,6 +292,7 @@
        struct urb urb;                                                 /* USB URB 
structure */
        struct urb urbout;                                              /* Output URB 
*/
        struct input_dev input;                                         /* input 
device structure */
+       int open;                                                       /* is the 
+device open by input? */
        int quirks;                                                     /* Various 
nasty tricks the device can pull on us */
 };
 
diff -urN linux-2.4.0-test1-ac4-old/drivers/usb/input.c linux/drivers/usb/input.c
--- linux-2.4.0-test1-ac4-old/drivers/usb/input.c       Mon May 15 20:38:12 2000
+++ linux/drivers/usb/input.c   Sun May 28 19:33:58 2000
@@ -1,7 +1,7 @@
 /*
- *  input.c  Version 0.1
+ * $Id: input.c,v 1.7 2000/05/28 17:31:36 vojtech Exp $
  *
- *  Copyright (c) 1999 Vojtech Pavlik
+ *  Copyright (c) 1999-2000 Vojtech Pavlik
  *
  *  The input layer module itself
  *
@@ -91,11 +91,27 @@
                
                case EV_ABS:
 
-                       if (code > ABS_MAX || !test_bit(code, dev->absbit) || (value 
== dev->abs[code]))
+                       if (code > ABS_MAX || !test_bit(code, dev->absbit))
                                return;
 
-                       dev->abs[code] = value;
+                       if (dev->absfuzz[code]) {
+                               if ((value > dev->abs[code] - (dev->absfuzz[code] >> 
+1)) &&
+                                   (value < dev->abs[code] + (dev->absfuzz[code] >> 
+1)))
+                                       return;
+
+                               if ((value > dev->abs[code] - dev->absfuzz[code]) &&
+                                   (value < dev->abs[code] + dev->absfuzz[code]))
+                                       value = (dev->abs[code] * 3 + value) >> 2;
+
+                               if ((value > dev->abs[code] - (dev->absfuzz[code] << 
+1)) &&
+                                   (value < dev->abs[code] + (dev->absfuzz[code] << 
+1)))
+                                       value = (dev->abs[code] + value) >> 1;
+                       }
 
+                       if (dev->abs[code] == value)
+                               return;
+
+                       dev->abs[code] = value;
                        break;
 
                case EV_REL:
diff -urN linux-2.4.0-test1-ac4-old/drivers/usb/joydev.c linux/drivers/usb/joydev.c
--- linux-2.4.0-test1-ac4-old/drivers/usb/joydev.c      Fri Apr 21 22:22:42 2000
+++ linux/drivers/usb/joydev.c  Sun May 28 19:33:58 2000
@@ -1,7 +1,7 @@
 /*
- *  joydev.c  Version 0.1
+ * $Id: joydev.c,v 1.6 2000/05/28 17:31:36 vojtech Exp $
  *
- *  Copyright (c) 1999 Vojtech Pavlik                                       
+ *  Copyright (c) 1999-2000 Vojtech Pavlik                                       
  *  Copyright (c) 1999 Colin Van Dyke 
  *
  *  Joystick device driver for the input driver suite.
@@ -449,7 +449,7 @@
 
        joydev->devfs = input_register_minor("js%d", minor, JOYDEV_MINOR_BASE);
 
-       printk("js%d: Joystick device for input%d\n", minor, dev->number);
+       printk(KERN_INFO "js%d: Joystick device for input%d\n", minor, dev->number);
 
        return &joydev->handle;
 }
diff -urN linux-2.4.0-test1-ac4-old/drivers/usb/keybdev.c linux/drivers/usb/keybdev.c
--- linux-2.4.0-test1-ac4-old/drivers/usb/keybdev.c     Wed May  3 00:01:24 2000
+++ linux/drivers/usb/keybdev.c Sun May 28 19:33:58 2000
@@ -1,7 +1,7 @@
 /*
- *  keybdev.c  Version 0.1
+ * $Id: keybdev.c,v 1.3 2000/05/28 17:31:36 vojtech Exp $
  *
- *  Copyright (c) 1999 Vojtech Pavlik
+ *  Copyright (c) 1999-2000 Vojtech Pavlik
  *
  *  Input driver to keyboard driver binding.
  *
@@ -162,14 +162,14 @@
 
        input_open_device(handle);
 
-       printk("keybdev.c: Adding keyboard: input%d\n", dev->number);
+       printk(KERN_INFO "keybdev.c: Adding keyboard: input%d\n", dev->number);
 
        return handle;
 }
 
 static void keybdev_disconnect(struct input_handle *handle)
 {
-       printk("keybdev.c: Removing keyboard: input%d\n", handle->dev->number);
+       printk(KERN_INFO "keybdev.c: Removing keyboard: input%d\n", 
+handle->dev->number);
        input_close_device(handle);
        kfree(handle);
 }
diff -urN linux-2.4.0-test1-ac4-old/drivers/usb/mousedev.c linux/drivers/usb/mousedev.c
--- linux-2.4.0-test1-ac4-old/drivers/usb/mousedev.c    Wed May  3 00:01:24 2000
+++ linux/drivers/usb/mousedev.c        Sun May 28 19:33:58 2000
@@ -1,7 +1,7 @@
 /*
- *  mousedev.c  Version 0.1
+ * $Id: mousedev.c,v 1.8 2000/05/28 17:31:36 vojtech Exp $
  *
- *  Copyright (c) 1999 Vojtech Pavlik
+ *  Copyright (c) 1999-2000 Vojtech Pavlik
  *
  *  Input driver to PS/2 or ImPS/2 device driver module.
  *
@@ -421,7 +421,7 @@
        if (mousedev_mix.open)
                input_open_device(&mousedev->handle);
 
-       printk("mouse%d: PS/2 mouse device for input%d\n", minor, dev->number);
+       printk(KERN_INFO "mouse%d: PS/2 mouse device for input%d\n", minor, 
+dev->number);
 
        return &mousedev->handle;
 }
@@ -459,7 +459,7 @@
        mousedev_mix.minor = MOUSEDEV_MIX;
        mousedev_mix.devfs = input_register_minor("mice", MOUSEDEV_MIX, 
MOUSEDEV_MINOR_BASE);
 
-       printk("mice: PS/2 mouse device common for all mice\n");
+       printk(KERN_INFO "mice: PS/2 mouse device common for all mice\n");
 
        return 0;
 }
diff -urN linux-2.4.0-test1-ac4-old/drivers/usb/usbkbd.c linux/drivers/usb/usbkbd.c
--- linux-2.4.0-test1-ac4-old/drivers/usb/usbkbd.c      Sat Mar 11 01:18:34 2000
+++ linux/drivers/usb/usbkbd.c  Sun May 28 19:33:58 2000
@@ -1,7 +1,7 @@
 /*
- *  usbkbd.c  Version 0.1
+ * $Id: usbkbd.c,v 1.10 2000/05/28 17:31:36 vojtech Exp $
  *
- *  Copyright (c) 1999 Vojtech Pavlik
+ *  Copyright (c) 1999-2000 Vojtech Pavlik
  *
  *  USB HIDBP Keyboard support
  *
@@ -63,6 +63,7 @@
        struct urb irq, led;
        devrequest dr;
        unsigned char leds;
+       int open;
 };
 
 static void usb_kbd_irq(struct urb *urb)
@@ -125,12 +126,33 @@
                warn("led urb status %d received", urb->status);
 }
 
+static int usb_kbd_open(struct input_dev *dev)
+{
+       struct usb_kbd *kbd = dev->private;
+
+       if (kbd->open++)
+               return 0;
+
+       if (usb_submit_urb(&kbd->irq))
+               return -EIO;
+
+       return 0;
+}
+
+static void usb_kbd_close(struct input_dev *dev)
+{
+       struct usb_kbd *kbd = dev->private;
+
+       if (!--kbd->open)
+               usb_unlink_urb(&kbd->irq);
+}
+
 static void *usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
 {
        struct usb_interface_descriptor *interface;
        struct usb_endpoint_descriptor *endpoint;
        struct usb_kbd *kbd;
-       int i;
+       int i, pipe, maxp;
 
        if (dev->descriptor.bNumConfigurations != 1) return NULL;
        interface = dev->config[0].interface[ifnum].altsetting + 0;
@@ -144,6 +166,9 @@
        if (!(endpoint->bEndpointAddress & 0x80)) return NULL;
        if ((endpoint->bmAttributes & 3) != 3) return NULL;
 
+       pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
+       maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
+
        usb_set_protocol(dev, interface->bInterfaceNumber, 0);
        usb_set_idle(dev, interface->bInterfaceNumber, 0, 0);
 
@@ -159,14 +184,11 @@
        
        kbd->dev.private = kbd;
        kbd->dev.event = usb_kbd_event;
+       kbd->dev.open = usb_kbd_open;
+       kbd->dev.close = usb_kbd_close;
 
-       {
-               int pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
-               int maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
-
-               FILL_INT_URB(&kbd->irq, dev, pipe, kbd->new, maxp > 8 ? 8 : maxp,
-                       usb_kbd_irq, kbd, endpoint->bInterval);
-       }
+       FILL_INT_URB(&kbd->irq, dev, pipe, kbd->new, maxp > 8 ? 8 : maxp,
+               usb_kbd_irq, kbd, endpoint->bInterval);
 
        kbd->dr.requesttype = USB_TYPE_CLASS | USB_RECIP_INTERFACE;
        kbd->dr.request = USB_REQ_SET_REPORT;
@@ -177,15 +199,9 @@
        FILL_CONTROL_URB(&kbd->led, dev, usb_sndctrlpipe(dev, 0),
                (void*) &kbd->dr, &kbd->leds, 1, usb_kbd_led, kbd);
                        
-       if (usb_submit_urb(&kbd->irq)) {
-               kfree(kbd);
-               return NULL;
-       }
-
        input_register_device(&kbd->dev);
 
        printk(KERN_INFO "input%d: USB HIDBP keyboard\n", kbd->dev.number);
-
 
        return kbd;
 }
diff -urN linux-2.4.0-test1-ac4-old/drivers/usb/usbmouse.c linux/drivers/usb/usbmouse.c
--- linux-2.4.0-test1-ac4-old/drivers/usb/usbmouse.c    Sat Mar 11 01:18:34 2000
+++ linux/drivers/usb/usbmouse.c        Sun May 28 19:33:58 2000
@@ -1,7 +1,7 @@
 /*
- *  usbmouse.c  Version 0.1
+ * $Id: usbmouse.c,v 1.4 2000/05/28 17:31:36 vojtech Exp $
  *
- *  Copyright (c) 1999 Vojtech Pavlik
+ *  Copyright (c) 1999-2000 Vojtech Pavlik
  *
  *  USB HIDBP Mouse support
  *
@@ -37,12 +37,11 @@
 
 MODULE_AUTHOR("Vojtech Pavlik <[EMAIL PROTECTED]>");
 
-#define USBMOUSE_EXTRA
-
 struct usb_mouse {
        signed char data[8];
        struct input_dev dev;
        struct urb irq;
+       int open;
 };
 
 static void usb_mouse_irq(struct urb *urb)
@@ -53,16 +52,36 @@
 
        if (urb->status) return;
 
-       input_report_key(dev, BTN_LEFT, !!(data[0] & 0x01));
-       input_report_key(dev, BTN_RIGHT, !!(data[0] & 0x02));
-       input_report_key(dev, BTN_MIDDLE, !!(data[0] & 0x04));
-       input_report_rel(dev, REL_X, data[1]);
-       input_report_rel(dev, REL_Y, data[2]);
-#ifdef USBMOUSE_EXTRA
-       input_report_key(dev, BTN_SIDE, !!(data[0] & 0x08));
-       input_report_key(dev, BTN_EXTRA, !!(data[0] & 0x10));
+       input_report_key(dev, BTN_LEFT,   data[0] & 0x01);
+       input_report_key(dev, BTN_RIGHT,  data[0] & 0x02);
+       input_report_key(dev, BTN_MIDDLE, data[0] & 0x04);
+       input_report_key(dev, BTN_SIDE,   data[0] & 0x08);
+       input_report_key(dev, BTN_EXTRA,  data[0] & 0x10);
+
+       input_report_rel(dev, REL_X,     data[1]);
+       input_report_rel(dev, REL_Y,     data[2]);
        input_report_rel(dev, REL_WHEEL, data[3]);
-#endif
+}
+
+static int usb_mouse_open(struct input_dev *dev)
+{
+       struct usb_mouse *mouse = dev->private;
+
+       if (mouse->open++)
+               return 0;
+
+       if (usb_submit_urb(&mouse->irq))
+               return -EIO;
+
+       return 0;
+}
+
+static void usb_mouse_close(struct input_dev *dev)
+{
+       struct usb_mouse *mouse = dev->private;
+
+       if (!--mouse->open)
+               usb_unlink_urb(&mouse->irq);
 }
 
 static void *usb_mouse_probe(struct usb_device *dev, unsigned int ifnum)
@@ -70,6 +89,7 @@
        struct usb_interface_descriptor *interface;
        struct usb_endpoint_descriptor *endpoint;
        struct usb_mouse *mouse;
+       int pipe, maxp;
 
        if (dev->descriptor.bNumConfigurations != 1) return NULL;
        interface = dev->config[0].interface[ifnum].altsetting + 0;
@@ -83,9 +103,9 @@
        if (!(endpoint->bEndpointAddress & 0x80)) return NULL;
        if ((endpoint->bmAttributes & 3) != 3) return NULL;
 
-#ifndef USBMOUSE_EXTRA
-       usb_set_protocol(dev, interface->bInterfaceNumber, 0);
-#endif
+       pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
+       maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
+
        usb_set_idle(dev, interface->bInterfaceNumber, 0, 0);
 
        if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL))) return NULL;
@@ -94,23 +114,15 @@
        mouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
        mouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | 
BIT(BTN_MIDDLE);
        mouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
-#ifdef USBMOUSE_EXTRA
        mouse->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA);
        mouse->dev.relbit[0] |= BIT(REL_WHEEL);
-#endif
 
-       {
-               int pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
-               int maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
-
-               FILL_INT_URB(&mouse->irq, dev, pipe, mouse->data, maxp > 8 ? 8 : maxp,
-                       usb_mouse_irq, mouse, endpoint->bInterval);
-       }
-
-       if (usb_submit_urb(&mouse->irq)) {
-               kfree(mouse);
-               return NULL;
-       }
+       mouse->dev.private = mouse;
+       mouse->dev.open = usb_mouse_open;
+       mouse->dev.close = usb_mouse_close;
+
+       FILL_INT_URB(&mouse->irq, dev, pipe, mouse->data, maxp > 8 ? 8 : maxp,
+               usb_mouse_irq, mouse, endpoint->bInterval);
 
        input_register_device(&mouse->dev);
 
diff -urN linux-2.4.0-test1-ac4-old/drivers/usb/wacom.c linux/drivers/usb/wacom.c
--- linux-2.4.0-test1-ac4-old/drivers/usb/wacom.c       Sat May 20 20:24:15 2000
+++ linux/drivers/usb/wacom.c   Sun May 28 19:33:58 2000
@@ -1,5 +1,5 @@
 /*
- *  wacom.c  Version 0.5
+ * $Id: wacom.c,v 1.8 2000/05/28 17:33:38 vojtech Exp $
  *
  *  Copyright (c) 2000 Vojtech Pavlik          <[EMAIL PROTECTED]>
  *  Copyright (c) 2000 Andreas Bach Aaen       <[EMAIL PROTECTED]>
@@ -18,6 +18,9 @@
  *                     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
  */
 
 /*
@@ -116,6 +119,7 @@
        struct urb irq;
        struct wacom_features *features;
        int tool;
+       int open;
 };
 
 static void wacom_graphire_irq(struct urb *urb)
@@ -137,18 +141,18 @@
        switch ((data[1] >> 5) & 3) {
 
                case 0: /* Pen */
-                       input_report_btn(dev, BTN_TOOL_PEN, data[1] & 0x80);
+                       input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x80);
                        break;
 
                case 1: /* Rubber */
-                       input_report_btn(dev, BTN_TOOL_RUBBER, data[1] & 0x80);
+                       input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x80);
                        break;
 
                case 2: /* Mouse */
-                       input_report_btn(dev, BTN_TOOL_MOUSE, data[7] > 24);
-                       input_report_btn(dev, BTN_LEFT, data[1] & 0x01);
-                       input_report_btn(dev, BTN_RIGHT, data[1] & 0x02);
-                       input_report_btn(dev, BTN_MIDDLE, data[1] & 0x04);
+                       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]);
                        return;
@@ -156,9 +160,9 @@
 
        input_report_abs(dev, ABS_PRESSURE, data[6] | ((__u32)data[7] << 8));
 
-       input_report_btn(dev, BTN_TOUCH, data[1] & 0x01);
-       input_report_btn(dev, BTN_STYLUS, data[1] & 0x02);
-       input_report_btn(dev, BTN_STYLUS2, data[1] & 0x04);
+       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);
 }
 
 static void wacom_intuos_irq(struct urb *urb)
@@ -177,21 +181,23 @@
 
                switch (((__u32)data[2] << 4) | (data[3] >> 4)) {
                        case 0x012: wacom->tool = BTN_TOOL_PENCIL;      break;  /* 
Inking pen */
+                       case 0x822:
                        case 0x022: wacom->tool = BTN_TOOL_PEN;         break;  /* Pen 
*/
                        case 0x032: wacom->tool = BTN_TOOL_BRUSH;       break;  /* 
Stroke pen */
                        case 0x094: wacom->tool = BTN_TOOL_MOUSE;       break;  /* 
Mouse 4D */
                        case 0x096: wacom->tool = BTN_TOOL_LENS;        break;  /* 
Lens cursor */
+                       case 0x82a:
                        case 0x0fa: wacom->tool = BTN_TOOL_RUBBER;      break;  /* 
Eraser */
                        case 0x112: wacom->tool = BTN_TOOL_AIRBRUSH;    break;  /* 
Airbrush */
                        default:    wacom->tool = BTN_TOOL_PEN;         break;  /* 
Unknown tool */
                }                       
-               input_report_btn(dev, wacom->tool, 1);
+               input_report_key(dev, wacom->tool, 1);
                return;
        }
 
        if ((data[1] | data[2] | data[3] | data[4] | data[5] |
             data[6] | data[7] | data[8] | data[9]) == 0x80) {          /* Exit report 
*/
-               input_report_btn(dev, wacom->tool, 0);
+               input_report_key(dev, wacom->tool, 0);
                return;
        }
 
@@ -202,9 +208,9 @@
        input_report_abs(dev, ABS_TILT_X, ((data[7] << 1) & 0x7e) | (data[8] >> 7));
        input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f);
 
-       input_report_btn(dev, BTN_STYLUS, data[1] & 2);
-       input_report_btn(dev, BTN_STYLUS2, data[1] & 4);
-       input_report_btn(dev, BTN_TOUCH, t > 10);
+       input_report_key(dev, BTN_STYLUS, data[1] & 2);
+       input_report_key(dev, BTN_STYLUS2, data[1] & 4);
+       input_report_key(dev, BTN_TOUCH, t > 10);
 }
 
 #define WACOM_INTUOS_TOOLS     (BIT(BTN_TOOL_BRUSH) | BIT(BTN_TOOL_PENCIL) | 
BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS))
@@ -225,6 +231,27 @@
        { NULL , 0 }
 };
 
+static int wacom_open(struct input_dev *dev)
+{
+       struct wacom *wacom = dev->private;
+
+       if (wacom->open++)
+               return 0;
+
+       if (usb_submit_urb(&wacom->irq))
+               return -EIO;
+
+       return 0;
+}
+
+static void wacom_close(struct input_dev *dev)
+{
+       struct wacom *wacom = dev->private;
+
+       if (!--wacom->open)
+               usb_unlink_urb(&wacom->irq);
+}
+
 static void *wacom_probe(struct usb_device *dev, unsigned int ifnum)
 {
        struct usb_endpoint_descriptor *endpoint;
@@ -256,13 +283,12 @@
        wacom->dev.absmax[ABS_TILT_X] = 127;
        wacom->dev.absmax[ABS_TILT_Y] = 127;
 
+       wacom->dev.private = wacom;
+       wacom->dev.open = wacom_open;
+       wacom->dev.close = wacom_close;
+
        FILL_INT_URB(&wacom->irq, dev, usb_rcvintpipe(dev, endpoint->bEndpointAddress),
                     wacom->data, wacom->features->pktlen, wacom->features->irq, 
wacom, endpoint->bInterval);
-
-       if (usb_submit_urb(&wacom->irq)) {
-               kfree(wacom);
-               return NULL;
-       }
 
        input_register_device(&wacom->dev);
 
diff -urN linux-2.4.0-test1-ac4-old/drivers/usb/wmforce.c linux/drivers/usb/wmforce.c
--- linux-2.4.0-test1-ac4-old/drivers/usb/wmforce.c     Sat Mar 11 01:18:34 2000
+++ linux/drivers/usb/wmforce.c Sun May 28 19:33:58 2000
@@ -1,5 +1,5 @@
 /*
- *  wmforce.c  Version 0.1
+ * $Id: wmforce.c,v 1.5 2000/05/28 17:31:36 vojtech Exp $
  *
  *  Copyright (c) 2000 Vojtech Pavlik
  *
@@ -44,6 +44,7 @@
        signed char data[8];
        struct input_dev dev;
        struct urb irq;
+       int open;
 };
 
 static struct {
@@ -71,15 +72,36 @@
        input_report_abs(dev, ABS_HAT0X, wmforce_hat_to_axis[data[7] >> 4].x);
        input_report_abs(dev, ABS_HAT0Y, wmforce_hat_to_axis[data[7] >> 4].y);
 
-       input_report_key(dev, BTN_TRIGGER, !!(data[6] & 0x01));
-       input_report_key(dev, BTN_TOP,     !!(data[6] & 0x02));
-       input_report_key(dev, BTN_THUMB,   !!(data[6] & 0x04));
-       input_report_key(dev, BTN_TOP2,    !!(data[6] & 0x08));
-       input_report_key(dev, BTN_BASE,    !!(data[6] & 0x10));
-       input_report_key(dev, BTN_BASE2,   !!(data[6] & 0x20));
-       input_report_key(dev, BTN_BASE3,   !!(data[6] & 0x40));
-       input_report_key(dev, BTN_BASE4,   !!(data[6] & 0x80));
-       input_report_key(dev, BTN_BASE5,   !!(data[7] & 0x01));
+       input_report_key(dev, BTN_TRIGGER, data[6] & 0x01);
+       input_report_key(dev, BTN_TOP,     data[6] & 0x02);
+       input_report_key(dev, BTN_THUMB,   data[6] & 0x04);
+       input_report_key(dev, BTN_TOP2,    data[6] & 0x08);
+       input_report_key(dev, BTN_BASE,    data[6] & 0x10);
+       input_report_key(dev, BTN_BASE2,   data[6] & 0x20);
+       input_report_key(dev, BTN_BASE3,   data[6] & 0x40);
+       input_report_key(dev, BTN_BASE4,   data[6] & 0x80);
+       input_report_key(dev, BTN_BASE5,   data[7] & 0x01);
+}
+
+static int wmforce_open(struct input_dev *dev)
+{
+       struct wmforce *wmforce = dev->private;
+
+       if (wmforce->open++)
+               return 0;
+
+       if (usb_submit_urb(&wmforce->irq))
+               return -EIO;
+
+       return 0;
+}
+
+static void wmforce_close(struct input_dev *dev)
+{
+       struct wmforce *wmforce = dev->private;
+
+       if (!--wmforce->open)
+               usb_unlink_urb(&wmforce->irq);
 }
 
 static void *wmforce_probe(struct usb_device *dev, unsigned int ifnum)
@@ -105,29 +127,23 @@
        for (i = ABS_X; i <= ABS_Y; i++) {
                wmforce->dev.absmax[i] =  1920;
                wmforce->dev.absmin[i] = -1920;
-               wmforce->dev.absfuzz[i] = 0;
                wmforce->dev.absflat[i] = 128;
        }
 
-       wmforce->dev.absmax[ABS_THROTTLE] = 0;
-       wmforce->dev.absmin[ABS_THROTTLE] = 255;
-       wmforce->dev.absfuzz[ABS_THROTTLE] = 0;
-       wmforce->dev.absflat[ABS_THROTTLE] = 0;
+       wmforce->dev.absmax[ABS_THROTTLE] = 255;
+       wmforce->dev.absmin[ABS_THROTTLE] = 0;
 
        for (i = ABS_HAT0X; i <= ABS_HAT0Y; i++) {
                wmforce->dev.absmax[i] =  1;
                wmforce->dev.absmin[i] = -1;
-               wmforce->dev.absfuzz[i] = 0;
-               wmforce->dev.absflat[i] = 0;
        }
 
+       wmforce->dev.private = wmforce;
+       wmforce->dev.open = wmforce_open;
+       wmforce->dev.close = wmforce_close;
+
        FILL_INT_URB(&wmforce->irq, dev, usb_rcvintpipe(dev, 
endpoint->bEndpointAddress),
                        wmforce->data, 8, wmforce_irq, wmforce, endpoint->bInterval);
-
-       if (usb_submit_urb(&wmforce->irq)) {
-               kfree(wmforce);
-               return NULL;
-       }
 
        input_register_device(&wmforce->dev);
 
diff -urN linux-2.4.0-test1-ac4-old/include/linux/input.h linux/include/linux/input.h
--- linux-2.4.0-test1-ac4-old/include/linux/input.h     Fri Apr 28 02:35:05 2000
+++ linux/include/linux/input.h Sun May 28 19:36:55 2000
@@ -2,9 +2,9 @@
 #define _INPUT_H
 
 /*
- *  input.h  Version 0.1
+ * $Id: input.h,v 1.11 2000/05/28 17:36:22 vojtech Exp $
  *
- *  Copyright (c) 1999 Vojtech Pavlik
+ *  Copyright (c) 1999-2000 Vojtech Pavlik
  *
  *  Sponsored by SuSE
  */
@@ -47,16 +47,6 @@
 };
 
 /*
- * The device ID structure;
- */
-
-struct input_id {
-       __u16 bus;
-       __u16 vendor;
-       __u16 product;
-};
-
-/*
  * Protocol version.
  */
 
@@ -67,13 +57,16 @@
  */
 
 #define EVIOCGVERSION          _IOR('E', 0x01, __u32)                  /* get driver 
version */
-#define EVIOCGID               _IOR('E', 0x02, struct input_id)        /* get device 
ID */
+#define EVIOCGID               _IOR('E', 0x02, short[4])               /* get device 
+ID */
 #define EVIOCGREP              _IOR('E', 0x03, int[2])                 /* get repeat 
settings */
 #define EVIOCSREP              _IOW('E', 0x03, int[2])                 /* get repeat 
settings */
-#define EVIOCGNAME(len)                _IOC(_IOC_READ, 'E', 0x03, len)         /* get 
device name */
+#define EVIOCGKEYCODE          _IOR('E', 0x04, int[2])                 /* get keycode 
+*/
+#define EVIOCSKEYCODE          _IOW('E', 0x04, int[2])                 /* set keycode 
+*/
+#define EVIOCGKEY              _IOR('E', 0x05, int[2])                 /* get key 
+value */
+#define EVIOCGABSLIM(num)      _IOR('E', 0x10, int[5])                 /* get abs 
+event limits */ 
+#define EVIOCGABS(num)         _IOR('E', 0x11, int[2])                 /* get abs 
+value */
+#define EVIOCGNAME(len)                _IOC(_IOC_READ, 'E', 0x18, len)         /* get 
+device name */
 #define EVIOCGBIT(ev,len)      _IOC(_IOC_READ, 'E', 0x20 + ev, len)    /* get event 
bits */
-#define EVIOCGABSLIM(num)      _IOR('E', 0x40 + num, int[4])           /* get abs 
event limits */ 
-#define EVIOCGABS(num)         _IOR('E', 0x80 + num, int)              /* get abs 
value */
 
 /*
  * Event types
@@ -308,6 +301,7 @@
 #define BTN_BASE3              0x128
 #define BTN_BASE4              0x129
 #define BTN_BASE5              0x12a
+#define BTN_BASE6              0x12b
 
 #define BTN_GAMEPAD            0x130
 #define BTN_A                  0x130
@@ -364,6 +358,8 @@
 #define ABS_RZ                 0x05
 #define ABS_THROTTLE           0x06
 #define ABS_RUDDER             0x07
+#define ABS_TL                 0x08
+#define ABS_TR                 0x09
 #define ABS_HAT0X              0x10
 #define ABS_HAT0Y              0x11
 #define ABS_HAT1X              0x12
@@ -406,6 +402,20 @@
 #define SND_BELL               0x01
 #define SND_MAX                        0x07
 
+/*
+ * Bus IDs.
+ */
+
+#define BUS_PCI                        0x01
+#define BUS_ISAPNP             0x02
+#define BUS_USB                        0x03
+
+#define BUS_ISA                        0x10
+#define BUS_I8042              0x11
+#define BUS_XTKBD              0x12
+#define BUS_SERIAL             0x13
+#define BUS_GAMEPORT           0x14
+
 #ifdef __KERNEL__
 
 /*
@@ -425,7 +435,10 @@
 
        int number;
        char *name;
-       struct input_id id;
+       unsigned short idbus;
+       unsigned short idvendor;
+       unsigned short idproduct;
+       unsigned short idtype;
 
        unsigned long evbit[NBITS(EV_MAX)];
        unsigned long keybit[NBITS(KEY_MAX)];
@@ -434,7 +447,10 @@
        unsigned long ledbit[NBITS(LED_MAX)];
        unsigned long sndbit[NBITS(SND_MAX)];
 
-       unsigned char *keycode;
+       unsigned int keycodemax;
+       unsigned int keycodesize;
+       void *keycode;
+
        unsigned int repeat_key;
        struct timer_list timer;
 
@@ -500,8 +516,7 @@
 
 void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int 
value);
 
-#define input_report_key(a,b,c) input_event(a, EV_KEY, b, c)
-#define input_report_btn(a,b,c) input_event(a, EV_KEY, b, !!(c))
+#define input_report_key(a,b,c) input_event(a, EV_KEY, b, !!(c))
 #define input_report_rel(a,b,c) input_event(a, EV_REL, b, c)
 #define input_report_abs(a,b,c) input_event(a, EV_ABS, b, c)
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to