diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-02-03 00:08:26 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-02-04 03:25:19 -0500 |
commit | 0b7024ac4df5821347141c18e680b7166bc1cb20 (patch) | |
tree | 7a61e55e66bdd39351b3ec39ecef367588b47170 /drivers/input/joydev.c | |
parent | 1e87a43080a259a0e9739377708ece163b08de8d (diff) |
Input: add match() method to input hanlders
Get rid of blacklist in input handler structure and instead allow
handlers to define their own match() method to perform fine-grained
filtering of supported devices.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/joydev.c')
-rw-r--r-- | drivers/input/joydev.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c index b1bd6dd32286..63e71f2a7acc 100644 --- a/drivers/input/joydev.c +++ b/drivers/input/joydev.c | |||
@@ -775,6 +775,20 @@ static void joydev_cleanup(struct joydev *joydev) | |||
775 | input_close_device(handle); | 775 | input_close_device(handle); |
776 | } | 776 | } |
777 | 777 | ||
778 | |||
779 | static bool joydev_match(struct input_handler *handler, struct input_dev *dev) | ||
780 | { | ||
781 | /* Avoid touchpads and touchscreens */ | ||
782 | if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_TOUCH, dev->keybit)) | ||
783 | return false; | ||
784 | |||
785 | /* Avoid tablets, digitisers and similar devices */ | ||
786 | if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_DIGI, dev->keybit)) | ||
787 | return false; | ||
788 | |||
789 | return true; | ||
790 | } | ||
791 | |||
778 | static int joydev_connect(struct input_handler *handler, struct input_dev *dev, | 792 | static int joydev_connect(struct input_handler *handler, struct input_dev *dev, |
779 | const struct input_device_id *id) | 793 | const struct input_device_id *id) |
780 | { | 794 | { |
@@ -894,22 +908,6 @@ static void joydev_disconnect(struct input_handle *handle) | |||
894 | put_device(&joydev->dev); | 908 | put_device(&joydev->dev); |
895 | } | 909 | } |
896 | 910 | ||
897 | static const struct input_device_id joydev_blacklist[] = { | ||
898 | { | ||
899 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | | ||
900 | INPUT_DEVICE_ID_MATCH_KEYBIT, | ||
901 | .evbit = { BIT_MASK(EV_KEY) }, | ||
902 | .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) }, | ||
903 | }, /* Avoid itouchpads and touchscreens */ | ||
904 | { | ||
905 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | | ||
906 | INPUT_DEVICE_ID_MATCH_KEYBIT, | ||
907 | .evbit = { BIT_MASK(EV_KEY) }, | ||
908 | .keybit = { [BIT_WORD(BTN_DIGI)] = BIT_MASK(BTN_DIGI) }, | ||
909 | }, /* Avoid tablets, digitisers and similar devices */ | ||
910 | { } /* Terminating entry */ | ||
911 | }; | ||
912 | |||
913 | static const struct input_device_id joydev_ids[] = { | 911 | static const struct input_device_id joydev_ids[] = { |
914 | { | 912 | { |
915 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | | 913 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT | |
@@ -936,13 +934,13 @@ MODULE_DEVICE_TABLE(input, joydev_ids); | |||
936 | 934 | ||
937 | static struct input_handler joydev_handler = { | 935 | static struct input_handler joydev_handler = { |
938 | .event = joydev_event, | 936 | .event = joydev_event, |
937 | .match = joydev_match, | ||
939 | .connect = joydev_connect, | 938 | .connect = joydev_connect, |
940 | .disconnect = joydev_disconnect, | 939 | .disconnect = joydev_disconnect, |
941 | .fops = &joydev_fops, | 940 | .fops = &joydev_fops, |
942 | .minor = JOYDEV_MINOR_BASE, | 941 | .minor = JOYDEV_MINOR_BASE, |
943 | .name = "joydev", | 942 | .name = "joydev", |
944 | .id_table = joydev_ids, | 943 | .id_table = joydev_ids, |
945 | .blacklist = joydev_blacklist, | ||
946 | }; | 944 | }; |
947 | 945 | ||
948 | static int __init joydev_init(void) | 946 | static int __init joydev_init(void) |