diff options
author | Chase Douglas <chase.douglas@canonical.com> | 2012-01-19 13:05:47 -0800 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-01-26 15:48:37 +1000 |
commit | 56d32619b95eb472104068c35ea7146dccb8d1bf (patch) | |
tree | 50b90584a75859b8edc5ddd9db83d477d81606fc /src | |
parent | 7ef9150d832d6ede991c5def02d2964c8047ad4f (diff) |
Add touch device class support
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/synaptics.c | 65 | ||||
-rw-r--r-- | src/synapticsstr.h | 15 |
2 files changed, 75 insertions, 5 deletions
diff --git a/src/synaptics.c b/src/synaptics.c index 1c68358..1d963cb 100644 --- a/src/synaptics.c +++ b/src/synaptics.c @@ -937,8 +937,13 @@ DeviceClose(DeviceIntPtr dev) return RetValue; } -static void InitAxesLabels(Atom *labels, int nlabels) +static void InitAxesLabels(Atom *labels, int nlabels, + const SynapticsPrivate *priv) { +#ifdef HAVE_MULTITOUCH + int i; +#endif + memset(labels, 0, nlabels * sizeof(Atom)); switch(nlabels) { @@ -955,6 +960,15 @@ static void InitAxesLabels(Atom *labels, int nlabels) labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); break; } + +#ifdef HAVE_MULTITOUCH + for (i = 0; i < priv->num_mt_axes; i++) + { + SynapticsTouchAxisRec *axis = &priv->touch_axes[i]; + int axnum = nlabels - priv->num_mt_axes + i; + labels[axnum] = XIGetKnownProperty(axis->label); + } +#endif } static void InitButtonLabels(Atom *labels, int nlabels) @@ -1000,6 +1014,10 @@ DeviceInit(DeviceIntPtr dev) num_axes += 2; #endif +#ifdef HAVE_MULTITOUCH + num_axes += priv->num_mt_axes; +#endif + axes_labels = calloc(num_axes, sizeof(Atom)); if (!axes_labels) { @@ -1007,7 +1025,7 @@ DeviceInit(DeviceIntPtr dev) return !Success; } - InitAxesLabels(axes_labels, num_axes); + InitAxesLabels(axes_labels, num_axes, priv); InitButtonLabels(btn_labels, SYN_MAX_BUTTONS); DBG(3, "Synaptics DeviceInit called\n"); @@ -1111,12 +1129,12 @@ DeviceInit(DeviceIntPtr dev) xf86InitValuatorAxisStruct(dev, 3, axes_labels[3], 0, -1, 0, 0, 0, Relative); priv->scroll_axis_vert = 3; - - free(axes_labels); - priv->scroll_events_mask = valuator_mask_new(MAX_VALUATORS); if (!priv->scroll_events_mask) + { + free(axes_labels); return !Success; + } SetScrollValuator(dev, priv->scroll_axis_horiz, SCROLL_TYPE_HORIZONTAL, priv->synpara.scroll_dist_horiz, 0); @@ -1124,6 +1142,43 @@ DeviceInit(DeviceIntPtr dev) priv->synpara.scroll_dist_vert, 0); #endif +#ifdef HAVE_MULTITOUCH + if (priv->has_touch) + { + if (!InitTouchClassDeviceStruct(dev, priv->num_touches, + XIDependentTouch, priv->num_mt_axes)) + { + xf86IDrvMsg(pInfo, X_ERROR, + "failed to initialize touch class device\n"); + priv->has_touch = 0; + goto no_touch; + } + + for (i = 0; i < priv->num_mt_axes; i++) + { + SynapticsTouchAxisRec *axis = &priv->touch_axes[i]; + int axnum = num_axes - priv->num_mt_axes + i; + Atom atom = axes_labels[axnum]; + + if (!xf86InitValuatorAxisStruct(dev, axnum, axes_labels[axnum], + axis->min, axis->max, axis->res, 0, + axis->res, Absolute)) + { + xf86IDrvMsg(pInfo, X_WARNING, + "failed to initialize axis %s, skipping\n", + axis->label); + continue; + } + + xf86InitValuatorDefaults(dev, axnum); + } + } + +no_touch: +#endif + + free(axes_labels); + if (!alloc_shm_data(pInfo)) return !Success; diff --git a/src/synapticsstr.h b/src/synapticsstr.h index d74ebcd..d3b8607 100644 --- a/src/synapticsstr.h +++ b/src/synapticsstr.h @@ -56,6 +56,14 @@ typedef struct _SynapticsMoveHist CARD32 millis; } SynapticsMoveHistRec; +typedef struct _SynapticsTouchAxis +{ + const char *label; + int min; + int max; + int res; +} SynapticsTouchAxisRec; + enum FingerState { /* Note! The order matters. Compared with < operator. */ FS_BLOCKED = -1, FS_UNTOUCHED = 0, /* this is 0 so it's the initialized value. */ @@ -265,6 +273,13 @@ typedef struct _SynapticsPrivateRec int scroll_axis_vert; /* Vertical smooth-scrolling axis */ ValuatorMask *scroll_events_mask; /* ValuatorMask for smooth-scrolling */ #endif + +#ifdef HAVE_MULTITOUCH + Bool has_touch; /* Device has multitouch capabilities */ + int num_touches; /* Number of touches supported */ + int num_mt_axes; /* Number of multitouch axes other than X, Y */ + SynapticsTouchAxisRec *touch_axes; /* Touch axis information other than X, Y */ +#endif } SynapticsPrivate; #endif /* _SYNAPTICSSTR_H_ */ |