summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2010-09-08 10:59:12 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2010-10-11 08:44:26 +1000
commit684426a9d2b4850ae80c824d4afe1e95875eee21 (patch)
tree229c0c4de16e89681b38808a9ae2547e87845abd
parent9664e5a48723e7085fc3ece2aa13f8696f631a3d (diff)
De-duplicate event queue access.
Factor out access to the next queue element in a static function to be reused for button and key presses. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
-rw-r--r--src/evdev.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/src/evdev.c b/src/evdev.c
index 854ef3c..e5b3065 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -268,12 +268,26 @@ static int wheel_down_button = 5;
static int wheel_left_button = 6;
static int wheel_right_button = 7;
+static EventQueuePtr
+EvdevNextInQueue(InputInfoPtr pInfo)
+{
+ EvdevPtr pEvdev = pInfo->private;
+
+ if (pEvdev->num_queue >= EVDEV_MAXQUEUE)
+ {
+ xf86Msg(X_NONE, "%s: dropping event due to full queue!\n", pInfo->name);
+ return NULL;
+ }
+
+ pEvdev->num_queue++;
+ return &pEvdev->queue[pEvdev->num_queue - 1];
+}
+
void
EvdevQueueKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value)
{
int code = ev->code + MIN_KEYCODE;
EventQueuePtr pQueue;
- EvdevPtr pEvdev = pInfo->private;
/* Filter all repeated events from device.
We'll do softrepeat in the server, but only since 1.6 */
@@ -289,36 +303,26 @@ EvdevQueueKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value)
)
return;
- if (pEvdev->num_queue >= EVDEV_MAXQUEUE)
+ if ((pQueue = EvdevNextInQueue(pInfo)))
{
- xf86Msg(X_NONE, "%s: dropping event due to full queue!\n", pInfo->name);
- return;
+ pQueue->type = EV_QUEUE_KEY;
+ pQueue->key = code;
+ pQueue->val = value;
}
-
- pQueue = &pEvdev->queue[pEvdev->num_queue];
- pQueue->type = EV_QUEUE_KEY;
- pQueue->key = code;
- pQueue->val = value;
- pEvdev->num_queue++;
}
void
EvdevQueueButtonEvent(InputInfoPtr pInfo, int button, int value)
{
EventQueuePtr pQueue;
- EvdevPtr pEvdev = pInfo->private;
- if (pEvdev->num_queue >= EVDEV_MAXQUEUE)
+ if ((pQueue = EvdevNextInQueue(pInfo)))
{
- xf86Msg(X_NONE, "%s: dropping event due to full queue!\n", pInfo->name);
- return;
+ pQueue->type = EV_QUEUE_BTN;
+ pQueue->key = button;
+ pQueue->val = value;
}
- pQueue = &pEvdev->queue[pEvdev->num_queue];
- pQueue->type = EV_QUEUE_BTN;
- pQueue->key = button;
- pQueue->val = value;
- pEvdev->num_queue++;
}
/**