Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[powerpc.git] / drivers / usb / input / hid-input.c
index 25bc85f..4c62afb 100644 (file)
@@ -29,9 +29,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/kernel.h>
-#include <linux/input.h>
-#include <linux/usb.h>
-#include <linux/usb_input.h>
+#include <linux/usb/input.h>
 
 #undef DEBUG
 
@@ -67,11 +65,9 @@ static const struct {
 #define map_rel(c)     do { usage->code = c; usage->type = EV_REL; bit = input->relbit; max = REL_MAX; } while (0)
 #define map_key(c)     do { usage->code = c; usage->type = EV_KEY; bit = input->keybit; max = KEY_MAX; } while (0)
 #define map_led(c)     do { usage->code = c; usage->type = EV_LED; bit = input->ledbit; max = LED_MAX; } while (0)
-#define map_ff(c)      do { usage->code = c; usage->type = EV_FF;  bit = input->ffbit;  max =  FF_MAX; } while (0)
 
 #define map_abs_clear(c)       do { map_abs(c); clear_bit(c, bit); } while (0)
 #define map_key_clear(c)       do { map_key(c); clear_bit(c, bit); } while (0)
-#define map_ff_effect(c)       do { set_bit(c, input->ffbit); } while (0)
 
 #ifdef CONFIG_USB_HIDINPUT_POWERBOOK
 
@@ -527,23 +523,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
 
                case HID_UP_PID:
 
-                       set_bit(EV_FF, input->evbit);
                        switch(usage->hid & HID_USAGE) {
-                               case 0x26: map_ff_effect(FF_CONSTANT);  goto ignore;
-                               case 0x27: map_ff_effect(FF_RAMP);      goto ignore;
-                               case 0x28: map_ff_effect(FF_CUSTOM);    goto ignore;
-                               case 0x30: map_ff_effect(FF_SQUARE);    map_ff_effect(FF_PERIODIC); goto ignore;
-                               case 0x31: map_ff_effect(FF_SINE);      map_ff_effect(FF_PERIODIC); goto ignore;
-                               case 0x32: map_ff_effect(FF_TRIANGLE);  map_ff_effect(FF_PERIODIC); goto ignore;
-                               case 0x33: map_ff_effect(FF_SAW_UP);    map_ff_effect(FF_PERIODIC); goto ignore;
-                               case 0x34: map_ff_effect(FF_SAW_DOWN);  map_ff_effect(FF_PERIODIC); goto ignore;
-                               case 0x40: map_ff_effect(FF_SPRING);    goto ignore;
-                               case 0x41: map_ff_effect(FF_DAMPER);    goto ignore;
-                               case 0x42: map_ff_effect(FF_INERTIA);   goto ignore;
-                               case 0x43: map_ff_effect(FF_FRICTION);  goto ignore;
-                               case 0x7e: map_ff(FF_GAIN);             break;
-                               case 0x83: input->ff_effects_max = field->value[0]; goto ignore;
-                               case 0x98: map_ff(FF_AUTOCENTER);       break;
                                case 0xa4: map_key_clear(BTN_DEAD);     break;
                                default: goto ignore;
                        }
@@ -567,16 +547,14 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                        break;
        }
 
-       set_bit(usage->type, input->evbit);
-
-       while (usage->code <= max && test_and_set_bit(usage->code, bit))
-               usage->code = find_next_zero_bit(bit, max + 1, usage->code);
-
-       if (usage->code > max)
-               goto ignore;
-
-       if (((device->quirks & (HID_QUIRK_2WHEEL_POWERMOUSE)) && (usage->hid == 0x00010032)))
-               map_rel(REL_HWHEEL);
+       if (device->quirks & HID_QUIRK_MIGHTYMOUSE) {
+               if (usage->hid == HID_GD_Z)
+                       map_rel(REL_HWHEEL);
+               else if (usage->code == BTN_1)
+                       map_key(BTN_2);
+               else if (usage->code == BTN_2)
+                       map_key(BTN_1);
+       }
 
        if ((device->quirks & (HID_QUIRK_2WHEEL_MOUSE_HACK_7 | HID_QUIRK_2WHEEL_MOUSE_HACK_5)) &&
                 (usage->type == EV_REL) && (usage->code == REL_WHEEL))
@@ -586,6 +564,15 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                || ((device->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_7) && (usage->hid == 0x00090007)))
                goto ignore;
 
+       set_bit(usage->type, input->evbit);
+
+       while (usage->code <= max && test_and_set_bit(usage->code, bit))
+               usage->code = find_next_zero_bit(bit, max + 1, usage->code);
+
+       if (usage->code > max)
+               goto ignore;
+
+
        if (usage->type == EV_ABS) {
 
                int a = field->logical_minimum;
@@ -602,7 +589,8 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
 
        }
 
-       if (usage->hat_min < usage->hat_max || usage->hat_dir) {
+       if (usage->type == EV_ABS &&
+           (usage->hat_min < usage->hat_max || usage->hat_dir)) {
                int i;
                for (i = usage->code; i < usage->code + 2 && i <= max; i++) {
                        input_set_abs_params(input, i, -1, 1, 0, 0);
@@ -647,6 +635,11 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
                return;
        }
 
+       if ((hid->quirks & HID_QUIRK_INVERT_HWHEEL) && (usage->code == REL_HWHEEL)) {
+               input_event(input, usage->type, usage->code, -value);
+               return;
+       }
+
        if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_ON) && (usage->code == REL_WHEEL)) {
                input_event(input, usage->type, REL_HWHEEL, value);
                return;
@@ -687,8 +680,7 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
        }
 
        if (usage->hid == (HID_UP_PID | 0x83UL)) { /* Simultaneous Effects Max */
-               input->ff_effects_max = value;
-               dbg("Maximum Effects - %d",input->ff_effects_max);
+               dbg("Maximum Effects - %d",value);
                return;
        }
 
@@ -737,7 +729,7 @@ static int hidinput_input_event(struct input_dev *dev, unsigned int type, unsign
        int offset;
 
        if (type == EV_FF)
-               return hid_ff_event(hid, dev, type, code, value);
+               return input_ff_event(dev, type, code, value);
 
        if (type != EV_LED)
                return -1;