12#include <qpa/qwindowsysteminterface.h>
14#include <QPointingDevice>
16#include <QGuiApplication>
18#include <QLoggingCategory>
37 int portNumber = 3333;
38 int rotationAngle = 0;
43 if (
args.
at(
i).startsWith(
"udp=")) {
45 portNumber = portString.
toInt();
46 }
else if (
args.
at(
i).startsWith(
"tcp=")) {
48 portNumber = portString.
toInt();
49 qCWarning(lcTuioHandler) <<
"TCP is not yet supported. Falling back to UDP on " << portNumber;
50 }
else if (
args.
at(
i) ==
"invertx") {
52 }
else if (
args.
at(
i) ==
"inverty") {
54 }
else if (
args.
at(
i).startsWith(
"rotate=")) {
56 int argValue = rotateArg.
toInt();
61 rotationAngle = argValue;
90 qCWarning(lcTuioHandler) <<
"Failed to bind TUIO socket: " << m_socket.errorString();
101void QTuioHandler::processPackets()
129 messages =
bundle.messages();
132 if (!msg.isValid()) {
133 qCWarning(lcTuioSet) <<
"Got invalid datagram.";
140 if (
message.addressPattern() ==
"/tuio/2Dcur") {
143 qCWarning(lcTuioHandler,
"Ignoring TUIO message with no arguments");
148 if (messageType ==
"source") {
150 }
else if (messageType ==
"alive") {
152 }
else if (messageType ==
"set") {
154 }
else if (messageType ==
"fseq") {
157 qCWarning(lcTuioHandler) <<
"Ignoring unknown TUIO message type: " << messageType;
160 }
else if (
message.addressPattern() ==
"/tuio/2Dobj") {
163 qCWarning(lcTuioHandler,
"Ignoring TUIO message with no arguments");
168 if (messageType ==
"source") {
170 }
else if (messageType ==
"alive") {
172 }
else if (messageType ==
"set") {
174 }
else if (messageType ==
"fseq") {
177 qCWarning(lcTuioHandler) <<
"Ignoring unknown TUIO message type: " << messageType;
181 qCWarning(lcTuioHandler) <<
"Ignoring unknown address pattern " <<
message.addressPattern();
197 qCWarning(lcTuioSource,
"Ignoring malformed TUIO source message (bad argument type)");
219 qCWarning(lcTuioHandler) <<
"Ignoring malformed TUIO alive message (bad argument on position" <<
i <<
arguments <<
')';
224 if (!oldActiveCursors.
contains(cursorId)) {
234 oldActiveCursors.
remove(cursorId);
252 m_activeCursors = newActiveCursors;
259 qCWarning(lcTuioSet) <<
"Ignoring malformed TUIO set message with too few arguments: " <<
arguments.
size();
270 qCWarning(lcTuioSet) <<
"Ignoring malformed TUIO set message with bad types: " <<
arguments;
282 if (
it == m_activeCursors.
end()) {
283 qCWarning(lcTuioSet) <<
"Ignoring malformed TUIO set for nonexistent cursor " << cursorId;
287 qCDebug(lcTuioSet) <<
"Processing SET for " << cursorId <<
" x: " <<
x <<
y << vx << vy << acceleration;
350 m_deadCursors.
clear();
362 qCWarning(lcTuioSource,
"Ignoring malformed TUIO source message (bad argument type)");
384 qCWarning(lcTuioHandler) <<
"Ignoring malformed TUIO alive message (bad argument on position" <<
i <<
arguments <<
')';
389 if (!oldActiveTokens.
contains(sessionId)) {
399 oldActiveTokens.
remove(sessionId);
417 m_activeTokens = newActiveTokens;
424 qCWarning(lcTuioSet) <<
"Ignoring malformed TUIO set message with too few arguments: " <<
arguments.
size();
438 qCWarning(lcTuioSet) <<
"Ignoring malformed TUIO set message with bad types: " <<
arguments;
454 if (
it == m_activeTokens.
end()) {
455 qCWarning(lcTuioSet) <<
"Ignoring malformed TUIO set for nonexistent token " << classId;
459 qCDebug(lcTuioSet) <<
"Processing SET for token " << classId <<
id <<
" @ " <<
x <<
y <<
" angle: " <<
angle <<
460 "vel" << vx << vy << angularVelocity <<
"acc" << acceleration << angularAcceleration;
524 m_deadTokens.
clear();
529#include "moc_qtuiohandler_p.cpp"
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
static QWindowList topLevelWindows()
Returns a list of the top-level windows in the application.
static QWindow * focusWindow()
Returns the QWindow that receives events tied to focus, such as key events.
The QHostAddress class provides an IP address.
void readyRead()
This signal is emitted once every time new data is available for reading from the device's current re...
qsizetype size() const noexcept
void push_back(parameter_type t)
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
iterator insert(const Key &key, const T &value)
T value(const Key &key, const T &defaultValue=T()) const
bool contains(const Key &key) const
size_type remove(const Key &key)
iterator find(const Key &key)
const_iterator constBegin() const
const_iterator constEnd() const
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
constexpr void moveCenter(const QPointF &p) noexcept
Moves the rectangle, leaving the center point at the given position.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
int toInt(bool *ok=nullptr, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
void setAcceleration(float acceleration)
void setAngularAcceleration(float angularAcceleration)
void setAcceleration(float acceleration)
void setAngle(float angle)
void setClassId(int classId)
void setAngularVelocity(float angularVelocity)
bool hasPendingDatagrams() const
Returns true if at least one datagram is waiting to be read; otherwise returns false.
qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *host=nullptr, quint16 *port=nullptr)
Receives a datagram no larger than maxSize bytes and stores it in data.
qint64 pendingDatagramSize() const
Returns the size of the first pending UDP datagram.
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
float toFloat(bool *ok=nullptr) const
Returns the variant as a float if the variant has userType() \l QMetaType::Double,...
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has userType() \l QMetaType::QByteArray or \l QMet...
The QVector2D class represents a vector or vertex in 2D space.
static bool handleTouchEvent(QWindow *window, const QPointingDevice *device, const QList< struct TouchPoint > &points, Qt::KeyboardModifiers mods=Qt::NoModifier)
static void registerInputDevice(const QInputDevice *device)
QSet< QString >::iterator it
QList< QVariant > arguments
Combined button and popup list for selecting options.
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
constexpr float qRadiansToDegrees(float radians)
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLsizei const GLchar * message
GLsizei GLsizei GLchar * source
QLatin1StringView QLatin1String
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
static QT_BEGIN_NAMESPACE bool forceDelivery
QFuture< QSet< QChar > > set
[10]
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)