diff options
author | Dmitry Torokhov <dtor@insightbb.com> | 2007-04-25 00:53:18 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2007-04-25 00:53:18 -0400 |
commit | 534565f254490227e3bec20d50f387800960acd9 (patch) | |
tree | 7e4a8ec054f21e9d709e5dd25fb8a4a0673cc1bb | |
parent | b9973954c5f3264a2afa6ec357adb542f4b76e06 (diff) |
Input: add input_set_capability() helper
Add input_set_capability() helper used to indicate that an input
device supports a certain event without need to manipulate bitmaps
directly.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r-- | drivers/input/input.c | 56 | ||||
-rw-r--r-- | include/linux/input.h | 2 |
2 files changed, 58 insertions, 0 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c index 173c2861ec58..915e9ab7cab0 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -1046,6 +1046,62 @@ void input_free_device(struct input_dev *dev) | |||
1046 | } | 1046 | } |
1047 | EXPORT_SYMBOL(input_free_device); | 1047 | EXPORT_SYMBOL(input_free_device); |
1048 | 1048 | ||
1049 | /** | ||
1050 | * input_set_capability - mark device as capable of a certain event | ||
1051 | * @dev: device that is capable of emitting or accepting event | ||
1052 | * @type: type of the event (EV_KEY, EV_REL, etc...) | ||
1053 | * @code: event code | ||
1054 | * | ||
1055 | * In addition to setting up corresponding bit in appropriate capability | ||
1056 | * bitmap the function also adjusts dev->evbit. | ||
1057 | */ | ||
1058 | void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code) | ||
1059 | { | ||
1060 | switch (type) { | ||
1061 | case EV_KEY: | ||
1062 | __set_bit(code, dev->keybit); | ||
1063 | break; | ||
1064 | |||
1065 | case EV_REL: | ||
1066 | __set_bit(code, dev->relbit); | ||
1067 | break; | ||
1068 | |||
1069 | case EV_ABS: | ||
1070 | __set_bit(code, dev->absbit); | ||
1071 | break; | ||
1072 | |||
1073 | case EV_MSC: | ||
1074 | __set_bit(code, dev->mscbit); | ||
1075 | break; | ||
1076 | |||
1077 | case EV_SW: | ||
1078 | __set_bit(code, dev->swbit); | ||
1079 | break; | ||
1080 | |||
1081 | case EV_LED: | ||
1082 | __set_bit(code, dev->ledbit); | ||
1083 | break; | ||
1084 | |||
1085 | case EV_SND: | ||
1086 | __set_bit(code, dev->sndbit); | ||
1087 | break; | ||
1088 | |||
1089 | case EV_FF: | ||
1090 | __set_bit(code, dev->ffbit); | ||
1091 | break; | ||
1092 | |||
1093 | default: | ||
1094 | printk(KERN_ERR | ||
1095 | "input_set_capability: unknown type %u (code %u)\n", | ||
1096 | type, code); | ||
1097 | dump_stack(); | ||
1098 | return; | ||
1099 | } | ||
1100 | |||
1101 | __set_bit(type, dev->evbit); | ||
1102 | } | ||
1103 | EXPORT_SYMBOL(input_set_capability); | ||
1104 | |||
1049 | int input_register_device(struct input_dev *dev) | 1105 | int input_register_device(struct input_dev *dev) |
1050 | { | 1106 | { |
1051 | static atomic_t input_no = ATOMIC_INIT(0); | 1107 | static atomic_t input_no = ATOMIC_INIT(0); |
diff --git a/include/linux/input.h b/include/linux/input.h index 7b6d7c408b07..1789ee9df4dd 100644 --- a/include/linux/input.h +++ b/include/linux/input.h | |||
@@ -1160,6 +1160,8 @@ static inline void input_sync(struct input_dev *dev) | |||
1160 | input_event(dev, EV_SYN, SYN_REPORT, 0); | 1160 | input_event(dev, EV_SYN, SYN_REPORT, 0); |
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code); | ||
1164 | |||
1163 | static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat) | 1165 | static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat) |
1164 | { | 1166 | { |
1165 | dev->absmin[axis] = min; | 1167 | dev->absmin[axis] = min; |