1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QINPUTDEVICE_P_H
5#define QINPUTDEVICE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtGui/private/qtguiglobal_p.h>
19#include <QtGui/qinputdevice.h>
20#include "private/qobject_p.h"
21
22QT_BEGIN_NAMESPACE
23
24class Q_GUI_EXPORT QInputDevicePrivate : public QObjectPrivate
25{
26 Q_DECLARE_PUBLIC(QInputDevice)
27public:
28 QInputDevicePrivate(const QString &name, qint64 winSysId, QInputDevice::DeviceType type,
29 QInputDevice::Capabilities caps = QInputDevice::Capability::None,
30 const QString &seatName = QString())
31 : name(name), seatName(seatName), systemId(winSysId), capabilities(caps),
32 deviceType(type)
33 {
34 // if the platform doesn't provide device IDs, make one up,
35 // but try to avoid clashing with OS-provided 32-bit IDs
36 static qint64 nextId = qint64(1) << 33;
37 if (!systemId)
38 systemId = nextId++;
39 }
40 ~QInputDevicePrivate() override;
41
42 QString name;
43 QString seatName;
44 QString busId;
45 QRect availableVirtualGeometry;
46 void *qqExtra = nullptr; // Qt Quick can store arbitrary device-specific data here
47 qint64 systemId = 0;
48 QInputDevice::Capabilities capabilities = QInputDevice::Capability::None;
49 QInputDevice::DeviceType deviceType = QInputDevice::DeviceType::Unknown;
50 bool pointingDeviceType = false;
51
52 static void registerDevice(const QInputDevice *dev);
53 static void unregisterDevice(const QInputDevice *dev);
54 static bool isRegistered(const QInputDevice *dev);
55 static const QInputDevice *fromId(qint64 systemId);
56
57 void setAvailableVirtualGeometry(QRect a)
58 {
59 if (a == availableVirtualGeometry)
60 return;
61
62 availableVirtualGeometry = a;
63 capabilities |= QInputDevice::Capability::NormalizedPosition;
64 Q_Q(QInputDevice);
65 Q_EMIT q->availableVirtualGeometryChanged(area: availableVirtualGeometry);
66 }
67
68 inline static QInputDevicePrivate *get(QInputDevice *q)
69 {
70 return static_cast<QInputDevicePrivate *>(QObjectPrivate::get(o: q));
71 }
72
73 inline static const QInputDevicePrivate *get(const QInputDevice *q)
74 {
75 return static_cast<const QInputDevicePrivate *>(QObjectPrivate::get(o: q));
76 }
77};
78
79QT_END_NAMESPACE
80
81#endif // QINPUTDEVICE_P_H
82

source code of qtbase/src/gui/kernel/qinputdevice_p.h