iOS: Add QPointingDevice for Apple Pencil
For Apple Pencil 1st generation, it supports xTilt and yTilt capabilities. Task-number: QTBUG-128466 Change-Id: I572a303a4d213417004cacadbc7cef9c96334720 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
0a017308cc
commit
38aa7f5fe7
@ -72,6 +72,9 @@ public:
|
|||||||
QPlatformNativeInterface *nativeInterface() const override;
|
QPlatformNativeInterface *nativeInterface() const override;
|
||||||
|
|
||||||
QPointingDevice *touchDevice();
|
QPointingDevice *touchDevice();
|
||||||
|
#if QT_CONFIG(tabletevent)
|
||||||
|
QPointingDevice *pencilDevice();
|
||||||
|
#endif
|
||||||
#if QT_CONFIG(accessibility)
|
#if QT_CONFIG(accessibility)
|
||||||
QPlatformAccessibility *accessibility() const override;
|
QPlatformAccessibility *accessibility() const override;
|
||||||
#endif
|
#endif
|
||||||
@ -109,6 +112,9 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
QPlatformInputContext *m_inputContext;
|
QPlatformInputContext *m_inputContext;
|
||||||
QPointingDevice *m_touchDevice;
|
QPointingDevice *m_touchDevice;
|
||||||
|
#if QT_CONFIG(tabletevent)
|
||||||
|
QPointingDevice *m_pencilDevice = nullptr;
|
||||||
|
#endif
|
||||||
QIOSServices *m_platformServices;
|
QIOSServices *m_platformServices;
|
||||||
mutable QPlatformAccessibility *m_accessibility;
|
mutable QPlatformAccessibility *m_accessibility;
|
||||||
QFactoryLoader *m_optionalPlugins;
|
QFactoryLoader *m_optionalPlugins;
|
||||||
|
@ -104,6 +104,12 @@ void QIOSIntegration::initialize()
|
|||||||
QWindowSystemInterface::registerInputDevice(m_touchDevice);
|
QWindowSystemInterface::registerInputDevice(m_touchDevice);
|
||||||
#if QT_CONFIG(tabletevent)
|
#if QT_CONFIG(tabletevent)
|
||||||
QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(false);
|
QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(false);
|
||||||
|
m_pencilDevice = new QPointingDevice(
|
||||||
|
"Apple Pencil", 0, QInputDevice::DeviceType::Stylus, QPointingDevice::PointerType::Pen,
|
||||||
|
QInputDevice::Capability::Position | QInputDevice::Capability::Pressure
|
||||||
|
| QInputDevice::Capability::XTilt | QInputDevice::Capability::YTilt,
|
||||||
|
1, 0);
|
||||||
|
QWindowSystemInterface::registerInputDevice(m_pencilDevice);
|
||||||
#endif
|
#endif
|
||||||
QMacMimeRegistry::initializeMimeTypes();
|
QMacMimeRegistry::initializeMimeTypes();
|
||||||
|
|
||||||
@ -271,6 +277,13 @@ QPointingDevice *QIOSIntegration::touchDevice()
|
|||||||
return m_touchDevice;
|
return m_touchDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_CONFIG(tabletevent)
|
||||||
|
QPointingDevice *QIOSIntegration::pencilDevice()
|
||||||
|
{
|
||||||
|
return m_pencilDevice;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if QT_CONFIG(accessibility)
|
#if QT_CONFIG(accessibility)
|
||||||
QPlatformAccessibility *QIOSIntegration::accessibility() const
|
QPlatformAccessibility *QIOSIntegration::accessibility() const
|
||||||
{
|
{
|
||||||
|
@ -387,13 +387,15 @@ inline ulong getTimeStamp(UIEvent *event)
|
|||||||
qCDebug(lcQpaTablet) << i << ":" << timeStamp << localViewPosition << pressure << state << "azimuth" << azimuth.dx << azimuth.dy
|
qCDebug(lcQpaTablet) << i << ":" << timeStamp << localViewPosition << pressure << state << "azimuth" << azimuth.dx << azimuth.dy
|
||||||
<< "angle" << azimuthAngle << "altitude" << cTouch.altitudeAngle
|
<< "angle" << azimuthAngle << "altitude" << cTouch.altitudeAngle
|
||||||
<< "xTilt" << qBound(-60.0, altitudeAngle * azimuth.dx, 60.0) << "yTilt" << qBound(-60.0, altitudeAngle * azimuth.dy, 60.0);
|
<< "xTilt" << qBound(-60.0, altitudeAngle * azimuth.dx, 60.0) << "yTilt" << qBound(-60.0, altitudeAngle * azimuth.dy, 60.0);
|
||||||
QWindowSystemInterface::handleTabletEvent(self.platformWindow->window(), timeStamp, localViewPosition, globalScreenPosition,
|
QWindowSystemInterface::handleTabletEvent(self.platformWindow->window(), timeStamp,
|
||||||
// device, pointerType, buttons
|
// device, local, global
|
||||||
int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen), state == QEventPoint::State::Released ? Qt::NoButton : Qt::LeftButton,
|
iosIntegration->pencilDevice(), localViewPosition, globalScreenPosition,
|
||||||
|
// buttons
|
||||||
|
state == QEventPoint::State::Released ? Qt::NoButton : Qt::LeftButton,
|
||||||
// pressure, xTilt, yTilt
|
// pressure, xTilt, yTilt
|
||||||
pressure, qBound(-60.0, altitudeAngle * azimuth.dx, 60.0), qBound(-60.0, altitudeAngle * azimuth.dy, 60.0),
|
pressure, qBound(-60.0, altitudeAngle * azimuth.dx, 60.0), qBound(-60.0, altitudeAngle * azimuth.dy, 60.0),
|
||||||
// tangentialPressure, rotation, z, uid, modifiers
|
// tangentialPressure, rotation, z, modifiers
|
||||||
0, azimuthAngle, 0, 0, Qt::NoModifier);
|
0, azimuthAngle, 0, Qt::NoModifier);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user