Merge pull request #12152 from gcalero/android_touchevents

Android touchevents
This commit is contained in:
Bradley Austin Davis 2018-01-11 20:39:55 -05:00 committed by GitHub
commit 800b7963f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 3 deletions

View file

@ -498,14 +498,16 @@ TexturePointer Texture::build(const ktx::KTXDescriptor& descriptor) {
GPUKTXPayload gpuktxKeyValue;
if (!GPUKTXPayload::findInKeyValues(descriptor.keyValues, gpuktxKeyValue)) {
qCWarning(gpulogging) << "Could not find GPUKTX key values.";
#if defined(Q_OS_ANDROID)
// FIXME use sensible defaults based on the texture type and format
gpuktxKeyValue._usageType = TextureUsageType::RESOURCE;
gpuktxKeyValue._usage = Texture::Usage::Builder().withColor().withAlpha().build();
#else
qCWarning(gpulogging) << "Could not find GPUKTX key values.";
return TexturePointer();
#endif
}
auto texture = create(gpuktxKeyValue._usageType,
type,
texelFormat,

View file

@ -1097,6 +1097,27 @@ bool OffscreenQmlSurface::eventFilter(QObject* originalDestination, QEvent* even
}
break;
}
#if defined(Q_OS_ANDROID)
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd: {
QTouchEvent *originalEvent = static_cast<QTouchEvent *>(event);
QTouchEvent *fakeEvent = new QTouchEvent(*originalEvent);
auto newTouchPoints = fakeEvent->touchPoints();
for (size_t i = 0; i < newTouchPoints.size(); ++i) {
const auto &originalPoint = originalEvent->touchPoints()[i];
auto &newPoint = newTouchPoints[i];
newPoint.setPos(originalPoint.pos());
}
fakeEvent->setTouchPoints(newTouchPoints);
if (QCoreApplication::sendEvent(_quickWindow, fakeEvent)) {
qInfo() << __FUNCTION__ << "sent fake touch event:" << fakeEvent->type()
<< "_quickWindow handled it... accepted:" << fakeEvent->isAccepted();
return false; //event->isAccepted();
}
break;
}
#endif
default:
break;
}