blob: fafd53dcb0f5b321a30b667eb6268cd219585f47 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qgenericinputdevice_p.h"
#include <Qt3DInput/private/qabstractphysicaldevice_p.h>
QT_BEGIN_NAMESPACE
namespace Qt3DInput {
QGenericInputDevice::QGenericInputDevice(Qt3DCore::QNode *parent)
: QAbstractPhysicalDevice(parent)
{}
static void setHashFromVariantMap(QHash<QString, int> &hash, const QVariantMap &map)
{
hash.clear();
for (QVariantMap::const_iterator it = map.cbegin(); it != map.cend(); ++it) {
bool ok;
int value = it.value().toInt(&ok);
if (ok)
hash[it.key()] = value;
}
}
static QVariantMap hash2VariantMap(const QHash<QString, int> &hash)
{
QVariantMap ret;
for (QHash<QString, int>::const_iterator it = hash.cbegin(); it != hash.cend(); ++it)
ret[it.key()] = it.value();
return ret;
}
QVariantMap QGenericInputDevice::axesMap() const
{
Q_D(const QAbstractPhysicalDevice);
return hash2VariantMap(d->m_axesHash);
}
void QGenericInputDevice::setAxesMap(const QVariantMap &axesMap)
{
Q_D(QAbstractPhysicalDevice);
setHashFromVariantMap(d->m_axesHash, axesMap);
emit axesMapChanged();
}
QVariantMap QGenericInputDevice::buttonsMap() const
{
Q_D(const QAbstractPhysicalDevice);
return hash2VariantMap(d->m_buttonsHash);
}
void QGenericInputDevice::setButtonsMap(const QVariantMap &buttonsMap)
{
Q_D(QAbstractPhysicalDevice);
setHashFromVariantMap(d->m_buttonsHash, buttonsMap);
emit axesMapChanged();
}
} // Qt3DInput
QT_END_NAMESPACE
#include "moc_qgenericinputdevice_p.cpp"
|