summaryrefslogtreecommitdiff
path: root/src/eventcomm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/eventcomm.c')
-rw-r--r--src/eventcomm.c112
1 files changed, 37 insertions, 75 deletions
diff --git a/src/eventcomm.c b/src/eventcomm.c
index e76423f..858efeb 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -42,7 +42,6 @@
#include "synproto.h"
#include "synapticsstr.h"
#include <xf86.h>
-#include <mtdev-plumbing.h>
#include <libevdev/libevdev.h>
#ifndef INPUT_PROP_BUTTONPAD
@@ -79,7 +78,6 @@ struct eventcomm_proto_data {
BOOL need_grab;
int st_to_mt_offset[2];
double st_to_mt_scale[2];
- struct mtdev *mtdev;
int axis_map[ABS_MT_CNT];
int cur_slot;
ValuatorMask **last_mt_vals;
@@ -141,8 +139,6 @@ UninitializeTouch(InputInfoPtr pInfo)
proto_data->last_mt_vals = NULL;
}
- mtdev_close_delete(proto_data->mtdev);
- proto_data->mtdev = NULL;
proto_data->num_touches = 0;
}
@@ -157,14 +153,7 @@ InitializeTouch(InputInfoPtr pInfo)
if (!priv->has_touch)
return;
- proto_data->mtdev = mtdev_new_open(pInfo->fd);
- if (!proto_data->mtdev) {
- xf86IDrvMsg(pInfo, X_WARNING,
- "failed to create mtdev instance, ignoring touch events\n");
- return;
- }
-
- proto_data->cur_slot = proto_data->mtdev->caps.slot.value;
+ proto_data->cur_slot = libevdev_get_current_slot(proto_data->evdev);
proto_data->num_touches = 0;
proto_data->last_mt_vals = calloc(priv->num_slots, sizeof(ValuatorMask *));
@@ -505,58 +494,33 @@ SynapticsReadEvent(InputInfoPtr pInfo, struct input_event *ev)
SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
struct eventcomm_proto_data *proto_data = priv->proto_data;
int rc;
- int have_events = TRUE;
static struct timeval last_event_time;
- /* empty mtdev queue first */
- if (proto_data->mtdev && !mtdev_empty(proto_data->mtdev)) {
- mtdev_get_event(proto_data->mtdev, ev);
- return TRUE;
- }
-
- do {
- rc = libevdev_next_event(proto_data->evdev, proto_data->read_flag, ev);
- if (rc < 0) {
- if (rc != -EAGAIN) {
- LogMessageVerbSigSafe(X_ERROR, 0, "%s: Read error %d\n", pInfo->name,
- errno);
- } else if (proto_data->read_flag == LIBEVDEV_READ_FLAG_SYNC)
- proto_data->read_flag = LIBEVDEV_READ_FLAG_NORMAL;
- have_events = FALSE;
- } else {
- have_events = TRUE;
-
- /* SYN_DROPPED received in normal mode. Create a normal EV_SYN
- so we process what's in the queue atm, then ensure we sync
- next time */
- if (rc == LIBEVDEV_READ_STATUS_SYNC &&
- proto_data->read_flag == LIBEVDEV_READ_FLAG_NORMAL) {
- proto_data->read_flag = LIBEVDEV_READ_FLAG_SYNC;
- ev->type = EV_SYN;
- ev->code = SYN_REPORT;
- ev->value = 0;
- ev->time = last_event_time;
- } else if (ev->type == EV_SYN)
- last_event_time = ev->time;
-
- /* feed mtdev. nomnomnomnom */
- if (proto_data->mtdev)
- mtdev_put_event(proto_data->mtdev, ev);
- }
- } while (have_events && proto_data->mtdev && mtdev_empty(proto_data->mtdev));
+ rc = libevdev_next_event(proto_data->evdev, proto_data->read_flag, ev);
+ if (rc < 0) {
+ if (rc != -EAGAIN) {
+ LogMessageVerbSigSafe(X_ERROR, 0, "%s: Read error %d\n", pInfo->name,
+ errno);
+ } else if (proto_data->read_flag == LIBEVDEV_READ_FLAG_SYNC)
+ proto_data->read_flag = LIBEVDEV_READ_FLAG_NORMAL;
- /* loop exits if:
- - we don't have mtdev, ev is valid, rc is TRUE, let's return it
- - we have mtdev and it has events for us, get those
- - we don't have a new event and mtdev doesn't have events either.
- */
- if (have_events && proto_data->mtdev) {
- have_events = !mtdev_empty(proto_data->mtdev);
- if (have_events)
- mtdev_get_event(proto_data->mtdev, ev);
+ return FALSE;
}
- return have_events;
+ /* SYN_DROPPED received in normal mode. Create a normal EV_SYN
+ so we process what's in the queue atm, then ensure we sync
+ next time */
+ if (rc == LIBEVDEV_READ_STATUS_SYNC &&
+ proto_data->read_flag == LIBEVDEV_READ_FLAG_NORMAL) {
+ proto_data->read_flag = LIBEVDEV_READ_FLAG_SYNC;
+ ev->type = EV_SYN;
+ ev->code = SYN_REPORT;
+ ev->value = 0;
+ ev->time = last_event_time;
+ } else if (ev->type == EV_SYN)
+ last_event_time = ev->time;
+
+ return TRUE;
}
static Bool
@@ -809,20 +773,22 @@ event_query_touch(InputInfoPtr pInfo)
#endif
- for (axis = ABS_MT_SLOT + 1; axis <= ABS_MT_MAX; axis++) {
- if (!libevdev_has_event_code(dev, EV_ABS, axis))
- continue;
+ if (libevdev_has_event_code(dev, EV_ABS, ABS_MT_SLOT)) {
+ for (axis = ABS_MT_SLOT + 1; axis <= ABS_MT_MAX; axis++) {
+ if (!libevdev_has_event_code(dev, EV_ABS, axis))
+ continue;
- priv->has_touch = TRUE;
+ priv->has_touch = TRUE;
- /* X and Y axis info is handled by synaptics already and we don't
- expose the tracking ID */
- if (axis == ABS_MT_POSITION_X ||
- axis == ABS_MT_POSITION_Y ||
- axis == ABS_MT_TRACKING_ID)
- continue;
+ /* X and Y axis info is handled by synaptics already and we don't
+ expose the tracking ID */
+ if (axis == ABS_MT_POSITION_X ||
+ axis == ABS_MT_POSITION_Y ||
+ axis == ABS_MT_TRACKING_ID)
+ continue;
- priv->num_mt_axes++;
+ priv->num_mt_axes++;
+ }
}
if (priv->has_touch) {
@@ -842,11 +808,7 @@ event_query_touch(InputInfoPtr pInfo)
AXIS_LABEL_PROP_ABS_MT_PRESSURE,
};
- if (libevdev_has_event_code(dev, EV_ABS, ABS_MT_SLOT))
- priv->max_touches = libevdev_get_num_slots(dev);
- else
- priv->max_touches = SYNAPTICS_MAX_TOUCHES;
-
+ priv->max_touches = libevdev_get_num_slots(dev);
priv->touch_axes = malloc(priv->num_mt_axes *
sizeof(SynapticsTouchAxisRec));
if (!priv->touch_axes) {