Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qopenxrcontroller.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5
7
8#if !defined(Q_OS_VISIONOS)
10#endif
11
12#include "qquick3dxrview_p.h"
13
15
28
41{
42 return m_controller;
43}
44
46{
47 if (m_controller == newController)
48 return;
49 m_controller = newController;
52
53 disconnect(m_posePositionConnection);
54 disconnect(m_poseRotationConnection);
55 disconnect(m_isActiveConnection);
56 disconnect(m_inputActionConnection);
57
58 auto *input = handInput();
59 if (input) {
60 setPosition(input->posePosition());
61 setRotation(input->poseRotation());
62 setVisible(input->isActive());
63
64 m_posePositionConnection = connect(input, &QQuick3DXrHandInput::posePositionChanged, this, [this, input]{
65 setPosition(input->posePosition());
66 });
67 m_poseRotationConnection = connect(input, &QQuick3DXrHandInput::poseRotationChanged, this, [this, input]{
68 setRotation(input->poseRotation());
69 });
70 m_isActiveConnection = connect(input, &QQuick3DXrHandInput::isActiveChanged, this, [this, input]{
71 setVisible(input->isActive());
72 });
73 m_inputActionConnection = connect(input, &QQuick3DXrHandInput::inputValueChange,
74 this, [this](int id, const char *shortName, float value) {
75 if (m_actionMapper)
76 m_actionMapper->handleInput(QOpenXRActionMapper::InputAction(id), shortName, value);
77 });
78 } else {
79 setVisible(false);
80 }
81}
82
89{
90 if (m_inputManager && m_inputManager->isValid()) {
91 if (m_controller == ControllerRight)
92 return m_inputManager->rightHandInput();
93 else if (m_controller == ControllerLeft)
94 return m_inputManager->leftHandInput();
95 }
96
97 return nullptr;
98}
99
106{
107 return m_actionMapper;
108}
109
111{
112 if (m_actionMapper == newActionMapper)
113 return;
114
115 if (m_actionMapperConnection) {
116 QObject::disconnect(m_actionMapperConnection);
117 m_actionMapperConnection = {};
118 }
119
120 if (newActionMapper)
121 m_actionMapperConnection = QObject::connect(newActionMapper, &QObject::destroyed, this, [this](QObject *destroyedMapper) {
122 if (m_actionMapper == destroyedMapper) {
123 m_actionMapper = nullptr;
125 }
126 });
127
128 m_actionMapper = newActionMapper;
130}
131
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
Definition qobject.cpp:3236
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
void handleInput(InputAction id, const char *shortName, float value)
void setController(QOpenXRController::Controller newController)
void setActionMapper(QOpenXRActionMapper *newActionMapper)
QOpenXRController()
\qmltype XrController \inherits Node \inqmlmodule QtQuick3D.Xr
void controllerChanged()
void actionMapperChanged()
QOpenXRActionMapper * actionMapper
QQuick3DXrHandInput * handInput
void setRotation(const QQuaternion &rotation)
void setVisible(bool visible)
void inputValueChange(int id, const char *shortName, float value)
QQuick3DXrHandInput * leftHandInput() const
QQuick3DXrHandInput * rightHandInput() const
static QQuick3DXrInputManager * instance()
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
n void setPosition(void) \n\
GLenum GLenum GLenum input
#define emit
myObject disconnect()
[26]