From 1f641d75edba7394201c1c53938215bae696791b Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Thu, 23 Jul 2009 13:19:49 +0300 Subject: evdev: Only send the events at synchronization time. Instead of just posting the button/key press/release events to the server as soon as they arrive, add them to an internal queue and post them once we receive an EV_SYN synchronization event. The motion events are always sent first, followed by the queued events. There will be one motion event and possibly many queued button/key events posted every EV_SYN event. Note that the size of the event queue (EVDEV_MAXQUEUE) is arbitrary and you may change it. If we receive more events than the queue can handle, those events are dropped and a warning message printed. Tested on my Lenovo T400 using evdev for all input devices; keyboard, touchpad, and trackpoint. Signed-off-by: Peter Hutterer --- src/evdev.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/evdev.h') diff --git a/src/evdev.h b/src/evdev.h index 5b95369..23ee003 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -54,6 +54,7 @@ #endif #define EVDEV_MAXBUTTONS 32 +#define EVDEV_MAXQUEUE 32 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3 #define HAVE_PROPERTIES 1 @@ -87,6 +88,16 @@ typedef struct { int traveled_distance; } WheelAxis, *WheelAxisPtr; +/* Event queue used to defer keyboard/button events until EV_SYN time. */ +typedef struct { + enum { + EV_QUEUE_KEY, /* xf86PostKeyboardEvent() */ + EV_QUEUE_BTN, /* xf86PostButtonEvent() */ + } type; + int key; /* May be either a key code or button number. */ + int val; /* State of the key/button; pressed or released. */ +} EventQueueRec, *EventQueuePtr; + typedef struct { const char *device; int grabDevice; /* grab the event device? */ @@ -103,6 +114,9 @@ typedef struct { BOOL invert_x; BOOL invert_y; + int delta[REL_CNT]; + unsigned int abs, rel; + /* XKB stuff has to be per-device rather than per-driver */ #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5 XkbComponentNamesRec xkbnames; @@ -159,6 +173,10 @@ typedef struct { /* minor/major number */ dev_t min_maj; + + /* Event queue used to defer keyboard/button events until EV_SYN time. */ + int num_queue; + EventQueueRec queue[EVDEV_MAXQUEUE]; } EvdevRec, *EvdevPtr; unsigned int EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, int code); -- cgit v1.2.3