summaryrefslogtreecommitdiffstats
path: root/src/plugins/generic/tuiotouch/qtuiohandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/generic/tuiotouch/qtuiohandler.cpp')
-rw-r--r--src/plugins/generic/tuiotouch/qtuiohandler.cpp100
1 files changed, 33 insertions, 67 deletions
diff --git a/src/plugins/generic/tuiotouch/qtuiohandler.cpp b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
index 1ef50915d8..2815368e84 100644
--- a/src/plugins/generic/tuiotouch/qtuiohandler.cpp
+++ b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Robin Burchell <robin.burchell@viroteck.net>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2014 Robin Burchell <robin.burchell@viroteck.net>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtuiohandler_p.h"
@@ -75,7 +39,7 @@ QTuioHandler::QTuioHandler(const QString &specification)
bool invertx = false;
bool inverty = false;
- for (int i = 0; i < args.count(); ++i) {
+ for (int i = 0; i < args.size(); ++i) {
if (args.at(i).startsWith("udp=")) {
QString portString = args.at(i).section('=', 1, 1);
portNumber = portString.toInt();
@@ -95,6 +59,7 @@ QTuioHandler::QTuioHandler(const QString &specification)
case 180:
case 270:
rotationAngle = argValue;
+ break;
default:
break;
}
@@ -158,7 +123,7 @@ void QTuioHandler::processPackets()
// messages. The FSEQ frame ID is incremented for each delivered bundle,
// while redundant bundles can be marked using the frame sequence ID
// -1."
- QVector<QOscMessage> messages;
+ QList<QOscMessage> messages;
QOscBundle bundle(datagram);
if (bundle.isValid()) {
@@ -172,10 +137,10 @@ void QTuioHandler::processPackets()
messages.push_back(msg);
}
- for (const QOscMessage &message : qAsConst(messages)) {
+ for (const QOscMessage &message : std::as_const(messages)) {
if (message.addressPattern() == "/tuio/2Dcur") {
QList<QVariant> arguments = message.arguments();
- if (arguments.count() == 0) {
+ if (arguments.size() == 0) {
qCWarning(lcTuioHandler, "Ignoring TUIO message with no arguments");
continue;
}
@@ -195,7 +160,7 @@ void QTuioHandler::processPackets()
}
} else if (message.addressPattern() == "/tuio/2Dobj") {
QList<QVariant> arguments = message.arguments();
- if (arguments.count() == 0) {
+ if (arguments.size() == 0) {
qCWarning(lcTuioHandler, "Ignoring TUIO message with no arguments");
continue;
}
@@ -224,8 +189,8 @@ void QTuioHandler::processPackets()
void QTuioHandler::process2DCurSource(const QOscMessage &message)
{
QList<QVariant> arguments = message.arguments();
- if (arguments.count() != 2) {
- qCWarning(lcTuioSource) << "Ignoring malformed TUIO source message: " << arguments.count();
+ if (arguments.size() != 2) {
+ qCWarning(lcTuioSource) << "Ignoring malformed TUIO source message: " << arguments.size();
return;
}
@@ -250,7 +215,7 @@ void QTuioHandler::process2DCurAlive(const QOscMessage &message)
QMap<int, QTuioCursor> oldActiveCursors = m_activeCursors;
QMap<int, QTuioCursor> newActiveCursors;
- for (int i = 1; i < arguments.count(); ++i) {
+ for (int i = 1; i < arguments.size(); ++i) {
if (QMetaType::Type(arguments.at(i).userType()) != QMetaType::Int) {
qCWarning(lcTuioHandler) << "Ignoring malformed TUIO alive message (bad argument on position" << i << arguments << ')';
return;
@@ -260,12 +225,12 @@ void QTuioHandler::process2DCurAlive(const QOscMessage &message)
if (!oldActiveCursors.contains(cursorId)) {
// newly active
QTuioCursor cursor(cursorId);
- cursor.setState(Qt::TouchPointPressed);
+ cursor.setState(QEventPoint::State::Pressed);
newActiveCursors.insert(cursorId, cursor);
} else {
// we already know about it, remove it so it isn't marked as released
QTuioCursor cursor = oldActiveCursors.value(cursorId);
- cursor.setState(Qt::TouchPointStationary); // position change in SET will update if needed
+ cursor.setState(QEventPoint::State::Stationary); // position change in SET will update if needed
newActiveCursors.insert(cursorId, cursor);
oldActiveCursors.remove(cursorId);
}
@@ -291,8 +256,8 @@ void QTuioHandler::process2DCurAlive(const QOscMessage &message)
void QTuioHandler::process2DCurSet(const QOscMessage &message)
{
QList<QVariant> arguments = message.arguments();
- if (arguments.count() < 7) {
- qCWarning(lcTuioSet) << "Ignoring malformed TUIO set message with too few arguments: " << arguments.count();
+ if (arguments.size() < 7) {
+ qCWarning(lcTuioSet) << "Ignoring malformed TUIO set message with too few arguments: " << arguments.size();
return;
}
@@ -362,7 +327,7 @@ void QTuioHandler::process2DCurFseq(const QOscMessage &message)
Q_UNUSED(message); // TODO: do we need to do anything with the frame id?
QWindow *win = QGuiApplication::focusWindow();
- if (!win && QGuiApplication::topLevelWindows().length() > 0 && forceDelivery)
+ if (!win && QGuiApplication::topLevelWindows().size() > 0 && forceDelivery)
win = QGuiApplication::topLevelWindows().at(0);
if (!win)
@@ -371,14 +336,14 @@ void QTuioHandler::process2DCurFseq(const QOscMessage &message)
QList<QWindowSystemInterface::TouchPoint> tpl;
tpl.reserve(m_activeCursors.size() + m_deadCursors.size());
- for (const QTuioCursor &tc : qAsConst(m_activeCursors)) {
+ for (const QTuioCursor &tc : std::as_const(m_activeCursors)) {
QWindowSystemInterface::TouchPoint tp = cursorToTouchPoint(tc, win);
tpl.append(tp);
}
- for (const QTuioCursor &tc : qAsConst(m_deadCursors)) {
+ for (const QTuioCursor &tc : std::as_const(m_deadCursors)) {
QWindowSystemInterface::TouchPoint tp = cursorToTouchPoint(tc, win);
- tp.state = Qt::TouchPointReleased;
+ tp.state = QEventPoint::State::Released;
tpl.append(tp);
}
QWindowSystemInterface::handleTouchEvent(win, m_device, tpl);
@@ -389,8 +354,8 @@ void QTuioHandler::process2DCurFseq(const QOscMessage &message)
void QTuioHandler::process2DObjSource(const QOscMessage &message)
{
QList<QVariant> arguments = message.arguments();
- if (arguments.count() != 2) {
- qCWarning(lcTuioSource, ) << "Ignoring malformed TUIO source message: " << arguments.count();
+ if (arguments.size() != 2) {
+ qCWarning(lcTuioSource ) << "Ignoring malformed TUIO source message: " << arguments.size();
return;
}
@@ -415,7 +380,7 @@ void QTuioHandler::process2DObjAlive(const QOscMessage &message)
QMap<int, QTuioToken> oldActiveTokens = m_activeTokens;
QMap<int, QTuioToken> newActiveTokens;
- for (int i = 1; i < arguments.count(); ++i) {
+ for (int i = 1; i < arguments.size(); ++i) {
if (QMetaType::Type(arguments.at(i).userType()) != QMetaType::Int) {
qCWarning(lcTuioHandler) << "Ignoring malformed TUIO alive message (bad argument on position" << i << arguments << ')';
return;
@@ -425,12 +390,12 @@ void QTuioHandler::process2DObjAlive(const QOscMessage &message)
if (!oldActiveTokens.contains(sessionId)) {
// newly active
QTuioToken token(sessionId);
- token.setState(Qt::TouchPointPressed);
+ token.setState(QEventPoint::State::Pressed);
newActiveTokens.insert(sessionId, token);
} else {
// we already know about it, remove it so it isn't marked as released
QTuioToken token = oldActiveTokens.value(sessionId);
- token.setState(Qt::TouchPointStationary); // position change in SET will update if needed
+ token.setState(QEventPoint::State::Stationary); // position change in SET will update if needed
newActiveTokens.insert(sessionId, token);
oldActiveTokens.remove(sessionId);
}
@@ -456,8 +421,8 @@ void QTuioHandler::process2DObjAlive(const QOscMessage &message)
void QTuioHandler::process2DObjSet(const QOscMessage &message)
{
QList<QVariant> arguments = message.arguments();
- if (arguments.count() < 7) {
- qCWarning(lcTuioSet) << "Ignoring malformed TUIO set message with too few arguments: " << arguments.count();
+ if (arguments.size() < 7) {
+ qCWarning(lcTuioSet) << "Ignoring malformed TUIO set message with too few arguments: " << arguments.size();
return;
}
@@ -511,7 +476,6 @@ QWindowSystemInterface::TouchPoint QTuioHandler::tokenToTouchPoint(const QTuioTo
QWindowSystemInterface::TouchPoint tp;
tp.id = tc.id();
tp.uniqueId = tc.classId(); // TODO TUIO 2.0: populate a QVariant, and register the mapping from int to arbitrary UID data
- tp.flags = QTouchEvent::TouchPoint::Token;
tp.pressure = 1.0f;
tp.normalPosition = QPointF(tc.x(), tc.y());
@@ -536,7 +500,7 @@ void QTuioHandler::process2DObjFseq(const QOscMessage &message)
Q_UNUSED(message); // TODO: do we need to do anything with the frame id?
QWindow *win = QGuiApplication::focusWindow();
- if (!win && QGuiApplication::topLevelWindows().length() > 0 && forceDelivery)
+ if (!win && QGuiApplication::topLevelWindows().size() > 0 && forceDelivery)
win = QGuiApplication::topLevelWindows().at(0);
if (!win)
@@ -545,14 +509,14 @@ void QTuioHandler::process2DObjFseq(const QOscMessage &message)
QList<QWindowSystemInterface::TouchPoint> tpl;
tpl.reserve(m_activeTokens.size() + m_deadTokens.size());
- for (const QTuioToken & t : qAsConst(m_activeTokens)) {
+ for (const QTuioToken & t : std::as_const(m_activeTokens)) {
QWindowSystemInterface::TouchPoint tp = tokenToTouchPoint(t, win);
tpl.append(tp);
}
- for (const QTuioToken & t : qAsConst(m_deadTokens)) {
+ for (const QTuioToken & t : std::as_const(m_deadTokens)) {
QWindowSystemInterface::TouchPoint tp = tokenToTouchPoint(t, win);
- tp.state = Qt::TouchPointReleased;
+ tp.state = QEventPoint::State::Released;
tp.velocity = QVector2D();
tpl.append(tp);
}
@@ -563,3 +527,5 @@ void QTuioHandler::process2DObjFseq(const QOscMessage &message)
QT_END_NAMESPACE
+#include "moc_qtuiohandler_p.cpp"
+