15static inline quint32 actionIntKey(
const QQuick3DXrInputAction::Action id,
const QQuick3DXrInputAction::Controller hand)
17 return quint16(id) | (quint32(hand) << 16);
22 return QString::number(hand) + name;
31void QQuick3DXrActionMapper::handleInput(QQuick3DXrInputAction::Action id, QQuick3DXrInputAction::Controller hand,
const char *shortName,
float value)
33 auto *that = instance();
34 auto set = [](
auto action,
auto value) {
35 action->setValue(value);
37 action->setPressed(value > 0.9);
40 const QLatin1StringView name(shortName);
43 QList<QQuick3DXrInputAction *> actions;
44 if (id == QQuick3DXrInputAction::CustomAction) {
45 actions = that->m_customActions.values(actionStringKey(name, hand));
47 actions = that->m_actions.values(actionIntKey(id, hand));
50 for (
const auto &action : std::as_const(actions))
51 if (action->enabled())
55QList<QPointer<QQuick3DXrHapticFeedback>>
QQuick3DXrActionMapper::getHapticEffects(QQuick3DXrInputAction::Controller hand)
57 auto *that = instance();
58 return that->m_hapticData[hand].m_hapticEffects;
64 auto *that = instance();
66 const auto &idList = action->actionId();
67 const auto hand = action->hand();
69 if (idList.isEmpty()) {
70 that->m_customActions.insert(actionStringKey(action->actionName(), hand), action);
72 for (
const auto &id : idList) {
73 if (id != QQuick3DXrInputAction::CustomAction)
74 that->m_actions.insert(actionIntKey(id, hand), action);
81 auto *that = instance();
83 that->m_hapticData[size_t(action->controller())].m_hapticEffects.append(action);
88 auto *that = instance();
90 const auto idList = action->actionId();
91 const auto hand = action->hand();
92 if (idList.isEmpty()) {
93 that->m_customActions.remove(action->actionName(), action);
95 for (
const auto &id : idList) {
96 if (id != QQuick3DXrInputAction::CustomAction)
97 that->m_actions.remove(actionIntKey(id, hand));
104 auto *that = instance();
105 QList<QPointer<QQuick3DXrHapticFeedback>> list = that->m_hapticData[size_t(action->controller())].m_hapticEffects;
106 list.removeAt(list.indexOf(action));
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
137
138
139
140
144 if (qFuzzyCompare(m_value, newValue))
151
152
153
154
155
156
165 if (m_pressed == newPressed)
167 m_pressed = newPressed;
168 emit pressedChanged();
174
175
176
177
178
187 if (m_actionName == newActionName)
189 const bool needsRemap = m_actionIds.isEmpty() && m_componentComplete;
192 m_actionName = newActionName;
195 emit actionNameChanged();
209
210
211
212
213
214
228 m_componentComplete =
true;
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
275 if (m_actionIds == newActionId)
278 if (m_componentComplete)
281 m_actionIds = newActionId;
283 if (m_componentComplete)
286 emit actionIdChanged();
290
291
292
293
294
295
296
297
298
299
300
301
310 setController(newHand);
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
338 if (m_controller == newController)
340 m_controller = newController;
341 emit controllerChanged();
346
347
348
349
350
351
360 if (m_enabled == newEnabled)
362 m_enabled = newEnabled;
363 emit enabledChanged();
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
417 QQuick3DXrActionMapper::registerHapticEffect(
this);
418 m_componentComplete =
true;
422
423
424
425
426
427
428
429
430
439 if (m_controller == newController)
441 m_controller = newController;
442 emit controllerChanged();
446
447
448
449
450
451
452
453
461 if (m_trigger == newTrigger)
466 case Condition::RisingEdge:
470 case Condition::TrailingEdge:
475 m_trigger = newTrigger;
476 emit triggerChanged();
480
481
482
483
487 return m_hapticEffect;
492 if (m_hapticEffect == newHapticEffect)
494 m_hapticEffect = newHapticEffect;
495 emit hapticEffectChanged();
499
500
501
502
503
504
505
506
507
508
509
517 if (m_condition == newCondition)
519 m_condition = newCondition;
520 emit conditionChanged();
524
525
526
533
534
535
static void registerAction(QQuick3DXrInputAction *action)
static void removeHapticEffect(QQuick3DXrHapticFeedback *action)
static void removeAction(QQuick3DXrInputAction *action)
void classBegin() override
Invoked after class creation, but before any properties have been set.
void setCondition(enum Condition newCondition)
~QQuick3DXrHapticFeedback() override
void setController(Controller newController)
void setTrigger(bool newTrigger)
enum Condition condition() const
\qmlproperty enumeration QtQuick3D.Xr::XrHapticFeedback::condition
void stop()
\qmlmethod void XrHapticFeedback::stop
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
void setHapticEffect(QQuick3DXrAbstractHapticEffect *newHapticEffect)
QQuick3DXrAbstractHapticEffect * hapticEffect() const
\qmlproperty XrHapticEffect XrHapticFeedback::hapticEffect
Controller controller() const
\qmlproperty enumeration QtQuick3D.Xr::XrHapticFeedback::controller
Combined button and popup list for selecting options.
static quint32 actionIntKey(const QQuick3DXrInputAction::Action id, const QQuick3DXrInputAction::Controller hand)
static QString actionStringKey(const QString &name, const QQuick3DXrInputAction::Controller hand)