1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "qquick3dxrhandinput_p.h"
5#include "qquick3dxrinputmanager_p.h"
6
7#if defined(Q_OS_VISIONOS)
8#include "visionos/qquick3dxrinputmanager_visionos_p.h"
9#else
10#include "openxr/qopenxrinputmanager_p.h"
11#endif
12
13QT_BEGIN_NAMESPACE
14
15QQuick3DXrHandInput::QQuick3DXrHandInput(QObject *parent)
16 : QObject(parent)
17{
18
19}
20
21bool QQuick3DXrHandInput::isActive() const
22{
23 return m_isActive;
24}
25
26void QQuick3DXrHandInput::setIsActive(bool isActive)
27{
28 if (m_isActive == isActive)
29 return;
30
31 m_isActive = isActive;
32 emit isActiveChanged();
33}
34
35void QQuick3DXrHandInput::setJointPositionsAndRotations(const QList<QVector3D> &newJointPositions, const QList<QQuaternion> &newJointRotations)
36{
37 m_jointPositions = newJointPositions;
38 emit jointPositionsChanged();
39 m_jointRotations = newJointRotations;
40 emit jointRotationsChanged();
41 emit jointDataUpdated();
42
43 QQuick3DXrInputManager *inputMan = QQuick3DXrInputManager::instance();
44 const auto pokeIndex = QQuick3DXrInputManagerPrivate::get(inputManager: inputMan)->getPokeJointIndex();
45
46 if (pokeIndex >= 0 && pokeIndex < m_jointPositions.size())
47 setPokePosition(m_jointPositions[pokeIndex]);
48}
49
50QList<QVector3D> QQuick3DXrHandInput::jointPositions() const
51{
52 return m_jointPositions;
53}
54
55QList<QQuaternion> QQuick3DXrHandInput::jointRotations() const
56{
57 return m_jointRotations;
58}
59
60QVector3D QQuick3DXrHandInput::pokePosition() const
61{
62 return m_pokePosition;
63}
64
65void QQuick3DXrHandInput::setPokePosition(const QVector3D &newPokePosition)
66{
67 if (m_pokePosition == newPokePosition)
68 return;
69 m_pokePosition = newPokePosition;
70 emit pokePositionChanged();
71}
72
73bool QQuick3DXrHandInput::isHandTrackingActive() const
74{
75 return m_isHandTracking;
76}
77
78void QQuick3DXrHandInput::setIsHandTrackingActive(bool newIsHandTracking)
79{
80 if (m_isHandTracking == newIsHandTracking)
81 return;
82 m_isHandTracking = newIsHandTracking;
83 emit isHandTrackingChanged();
84}
85
86QT_END_NAMESPACE
87

source code of qtquick3d/src/xr/quick3dxr/qquick3dxrhandinput.cpp