aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/input.h
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2010-01-30 02:59:12 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-01-30 04:47:41 -0500
commitef7995f4e46b1677f3eaaf547316e1a910b38dcb (patch)
tree9d3fe13ae7a288f77dbc0e1b07813ce23f9106d3 /include/linux/input.h
parent45cdba4d376adfd30cfbda1b7d43110818d967cc (diff)
Input: implement input filters
Sometimes it is desirable to suppress certain events from reaching input handlers and thus user space. One such example is Mac mouse button emulation code which catches certain key presses and converts them into button clicks as if they were emitted by a virtual mouse. The original key press events should be completely suppressed, otherwise user space will be confused, and while keyboard driver does it on its own evdev is blissfully unaware of this arrangement. This patch adds notion of 'filter' to the standard input handlers, which may flag event as filtered thus preventing it from reaching other input handlers. Filters don't (nor will they ever) have a notion of priority relative to each other, input core will run all of them first and any one of them may mark event as filtered. This patch is inspired by similar patch by Matthew Garret but the implementation and intended usage are quite different. Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'include/linux/input.h')
-rw-r--r--include/linux/input.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/input.h b/include/linux/input.h
index 7be8a6537b57..6c9d3d49fa91 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -1198,6 +1198,8 @@ struct input_handle;
1198 * @event: event handler. This method is being called by input core with 1198 * @event: event handler. This method is being called by input core with
1199 * interrupts disabled and dev->event_lock spinlock held and so 1199 * interrupts disabled and dev->event_lock spinlock held and so
1200 * it may not sleep 1200 * it may not sleep
1201 * @filter: similar to @event; separates normal event handlers from
1202 * "filters".
1201 * @connect: called when attaching a handler to an input device 1203 * @connect: called when attaching a handler to an input device
1202 * @disconnect: disconnects a handler from input device 1204 * @disconnect: disconnects a handler from input device
1203 * @start: starts handler for given handle. This function is called by 1205 * @start: starts handler for given handle. This function is called by
@@ -1219,6 +1221,11 @@ struct input_handle;
1219 * same time. All of them will get their copy of input event generated by 1221 * same time. All of them will get their copy of input event generated by
1220 * the device. 1222 * the device.
1221 * 1223 *
1224 * The very same structure is used to implement input filters. Input core
1225 * allows filters to run first and will not pass event to regular handlers
1226 * if any of the filters indicate that the event should be filtered (by
1227 * returning %true from their filter() method).
1228 *
1222 * Note that input core serializes calls to connect() and disconnect() 1229 * Note that input core serializes calls to connect() and disconnect()
1223 * methods. 1230 * methods.
1224 */ 1231 */
@@ -1227,6 +1234,7 @@ struct input_handler {
1227 void *private; 1234 void *private;
1228 1235
1229 void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value); 1236 void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value);
1237 bool (*filter)(struct input_handle *handle, unsigned int type, unsigned int code, int value);
1230 int (*connect)(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id); 1238 int (*connect)(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id);
1231 void (*disconnect)(struct input_handle *handle); 1239 void (*disconnect)(struct input_handle *handle);
1232 void (*start)(struct input_handle *handle); 1240 void (*start)(struct input_handle *handle);