diff options
| -rw-r--r-- | drivers/input/joydev.c | 70 |
1 files changed, 64 insertions, 6 deletions
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c index 29d677c714d2..7b29a8944039 100644 --- a/drivers/input/joydev.c +++ b/drivers/input/joydev.c | |||
| @@ -747,6 +747,68 @@ static void joydev_cleanup(struct joydev *joydev) | |||
| 747 | input_close_device(handle); | 747 | input_close_device(handle); |
| 748 | } | 748 | } |
| 749 | 749 | ||
| 750 | /* | ||
| 751 | * These codes are copied from from hid-ids.h, unfortunately there is no common | ||
| 752 | * usb_ids/bt_ids.h header. | ||
| 753 | */ | ||
| 754 | #define USB_VENDOR_ID_SONY 0x054c | ||
| 755 | #define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268 | ||
| 756 | #define USB_DEVICE_ID_SONY_PS4_CONTROLLER 0x05c4 | ||
| 757 | #define USB_DEVICE_ID_SONY_PS4_CONTROLLER_2 0x09cc | ||
| 758 | #define USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE 0x0ba0 | ||
| 759 | |||
| 760 | #define USB_VENDOR_ID_THQ 0x20d6 | ||
| 761 | #define USB_DEVICE_ID_THQ_PS3_UDRAW 0xcb17 | ||
| 762 | |||
| 763 | #define ACCEL_DEV(vnd, prd) \ | ||
| 764 | { \ | ||
| 765 | .flags = INPUT_DEVICE_ID_MATCH_VENDOR | \ | ||
| 766 | INPUT_DEVICE_ID_MATCH_PRODUCT | \ | ||
| 767 | INPUT_DEVICE_ID_MATCH_PROPBIT, \ | ||
| 768 | .vendor = (vnd), \ | ||
| 769 | .product = (prd), \ | ||
| 770 | .propbit = { BIT_MASK(INPUT_PROP_ACCELEROMETER) }, \ | ||
| 771 | } | ||
| 772 | |||
| 773 | static const struct input_device_id joydev_blacklist[] = { | ||
| 774 | /* Avoid touchpads and touchscreens */ | ||
| 775 | { | ||
| 776 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | | ||
| 777 | INPUT_DEVICE_ID_MATCH_KEYBIT, | ||
| 778 | .evbit = { BIT_MASK(EV_KEY) }, | ||
| 779 | .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) }, | ||
| 780 | }, | ||
| 781 | /* Avoid tablets, digitisers and similar devices */ | ||
| 782 | { | ||
| 783 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | | ||
| 784 | INPUT_DEVICE_ID_MATCH_KEYBIT, | ||
| 785 | .evbit = { BIT_MASK(EV_KEY) }, | ||
| 786 | .keybit = { [BIT_WORD(BTN_DIGI)] = BIT_MASK(BTN_DIGI) }, | ||
| 787 | }, | ||
| 788 | /* Disable accelerometers on composite devices */ | ||
| 789 | ACCEL_DEV(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER), | ||
| 790 | ACCEL_DEV(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER), | ||
| 791 | ACCEL_DEV(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_2), | ||
| 792 | ACCEL_DEV(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE), | ||
| 793 | ACCEL_DEV(USB_VENDOR_ID_THQ, USB_DEVICE_ID_THQ_PS3_UDRAW), | ||
| 794 | { /* sentinel */ } | ||
| 795 | }; | ||
| 796 | |||
| 797 | static bool joydev_dev_is_blacklisted(struct input_dev *dev) | ||
| 798 | { | ||
| 799 | const struct input_device_id *id; | ||
| 800 | |||
| 801 | for (id = joydev_blacklist; id->flags; id++) { | ||
| 802 | if (input_match_device_id(dev, id)) { | ||
| 803 | dev_dbg(&dev->dev, | ||
| 804 | "joydev: blacklisting '%s'\n", dev->name); | ||
| 805 | return true; | ||
| 806 | } | ||
| 807 | } | ||
| 808 | |||
| 809 | return false; | ||
| 810 | } | ||
| 811 | |||
| 750 | static bool joydev_dev_is_absolute_mouse(struct input_dev *dev) | 812 | static bool joydev_dev_is_absolute_mouse(struct input_dev *dev) |
| 751 | { | 813 | { |
| 752 | DECLARE_BITMAP(jd_scratch, KEY_CNT); | 814 | DECLARE_BITMAP(jd_scratch, KEY_CNT); |
| @@ -807,12 +869,8 @@ static bool joydev_dev_is_absolute_mouse(struct input_dev *dev) | |||
| 807 | 869 | ||
| 808 | static bool joydev_match(struct input_handler *handler, struct input_dev *dev) | 870 | static bool joydev_match(struct input_handler *handler, struct input_dev *dev) |
| 809 | { | 871 | { |
| 810 | /* Avoid touchpads and touchscreens */ | 872 | /* Disable blacklisted devices */ |
| 811 | if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_TOUCH, dev->keybit)) | 873 | if (joydev_dev_is_blacklisted(dev)) |
| 812 | return false; | ||
| 813 | |||
| 814 | /* Avoid tablets, digitisers and similar devices */ | ||
| 815 | if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_DIGI, dev->keybit)) | ||
| 816 | return false; | 874 | return false; |
| 817 | 875 | ||
| 818 | /* Avoid absolute mice */ | 876 | /* Avoid absolute mice */ |
