added maximumTouchPoints to QTouchDevice

This was missing information which the driver can provide.

Change-Id: I2574745635d6fdf608bc5617999aec46d9312c09
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
Shawn Rutledge 2013-07-22 09:20:44 +02:00 committed by The Qt Project
parent 16579e5b84
commit 29fda24ca8
4 changed files with 27 additions and 3 deletions

View File

@ -139,6 +139,16 @@ QTouchDevice::Capabilities QTouchDevice::capabilities() const
return d->caps;
}
/*!
Returns the maximum number of simultaneous touch points (fingers) that
can be detected.
\since 5.2
*/
int QTouchDevice::maximumTouchPoints() const
{
return d->maxTouchPoints;
}
/*!
Returns the touch device name.
@ -168,6 +178,15 @@ void QTouchDevice::setCapabilities(Capabilities caps)
d->caps = caps;
}
/*!
Sets the maximum number of simultaneous touchpoints \a max
supported by the device and its driver.
*/
void QTouchDevice::setMaximumTouchPoints(int max)
{
d->maxTouchPoints = max;
}
/*!
Sets the \a name (a unique identifier) for the device. In most systems it is
enough to leave this unset and keep the default empty name. This identifier

View File

@ -75,10 +75,12 @@ public:
QString name() const;
DeviceType type() const;
Capabilities capabilities() const;
int maximumTouchPoints() const;
void setName(const QString &name);
void setType(DeviceType devType);
void setCapabilities(Capabilities caps);
void setMaximumTouchPoints(int max);
private:
QTouchDevicePrivate *d;

View File

@ -64,12 +64,14 @@ class QTouchDevicePrivate
public:
QTouchDevicePrivate()
: type(QTouchDevice::TouchScreen),
caps(QTouchDevice::Position)
caps(QTouchDevice::Position),
maxTouchPoints(1)
{ }
QTouchDevice::DeviceType type;
QTouchDevice::Capabilities caps;
QString name;
int maxTouchPoints;
static void registerDevice(QTouchDevice *dev);
static bool isRegistered(QTouchDevice *dev);

View File

@ -210,6 +210,7 @@ XInput2DeviceData *QXcbConnection::deviceForId(int id)
#ifdef XCB_USE_XINPUT22
case XITouchClass: {
XITouchClassInfo *tci = reinterpret_cast<XITouchClassInfo *>(classinfo);
dev->qtTouchDevice->setMaximumTouchPoints(tci->num_touches);
switch (tci->mode) {
case XIModeRelative:
dev->qtTouchDevice->setType(QTouchDevice::TouchPad);
@ -236,8 +237,8 @@ XInput2DeviceData *QXcbConnection::deviceForId(int id)
if (caps != 0)
QWindowSystemInterface::registerTouchDevice(dev->qtTouchDevice);
#ifdef XI2_DEBUG
qDebug("registered new device %s with %d classes",
dev->xiDeviceInfo->name, dev->xiDeviceInfo->num_classes);
qDebug("registered new device %s with %d classes and %d maximum touch points",
dev->xiDeviceInfo->name, dev->xiDeviceInfo->num_classes, dev->qtTouchDevice->maximumTouchPoints());
#endif
m_touchDevices[id] = dev;
}