13static inline quint32 actionIntKey(
const QQuick3DXrInputAction::Action id,
const QQuick3DXrInputAction::Controller hand)
15 return quint16(id) | (quint32(hand) << 16);
20 return QString::number(hand) + name;
29void QQuick3DXrActionMapper::handleInput(QQuick3DXrInputAction::Action id, QQuick3DXrInputAction::Controller hand,
const char *shortName,
float value)
31 auto *that = instance();
32 auto set = [](
auto action,
auto value) {
33 action->setValue(value);
35 action->setPressed(value > 0.9);
38 const QLatin1StringView name(shortName);
41 QList<QQuick3DXrInputAction *> actions;
42 if (id == QQuick3DXrInputAction::CustomAction) {
43 actions = that->m_customActions.values(actionStringKey(name, hand));
45 actions = that->m_actions.values(actionIntKey(id, hand));
48 for (
const auto &action : std::as_const(actions))
49 if (action->enabled())
53QList<QPointer<QQuick3DXrHapticFeedback>>
QQuick3DXrActionMapper::getHapticEffects(QQuick3DXrInputAction::Controller hand)
55 auto *that = instance();
56 return that->m_hapticData[hand].m_hapticEffects;
62 auto *that = instance();
64 const auto &idList = action->actionId();
65 const auto hand = action->hand();
67 if (idList.isEmpty()) {
68 that->m_customActions.insert(actionStringKey(action->actionName(), hand), action);
70 for (
const auto &id : idList) {
71 if (id != QQuick3DXrInputAction::CustomAction)
72 that->m_actions.insert(actionIntKey(id, hand), action);
79 auto *that = instance();
81 that->m_hapticData[size_t(action->controller())].m_hapticEffects.append(action);
86 auto *that = instance();
88 const auto idList = action->actionId();
89 const auto hand = action->hand();
90 if (idList.isEmpty()) {
91 that->m_customActions.remove(action->actionName(), action);
93 for (
const auto &id : idList) {
94 if (id != QQuick3DXrInputAction::CustomAction)
95 that->m_actions.remove(actionIntKey(id, hand));
102 auto *that = instance();
103 QList<QPointer<QQuick3DXrHapticFeedback>> list = that->m_hapticData[size_t(action->controller())].m_hapticEffects;
104 list.removeAt(list.indexOf(action));
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
135
136
137
138
142 if (qFuzzyCompare(m_value, newValue))
149
150
151
152
153
154
163 if (m_pressed == newPressed)
165 m_pressed = newPressed;
166 emit pressedChanged();
172
173
174
175
176
185 if (m_actionName == newActionName)
187 const bool needsRemap = m_actionIds.isEmpty() && m_componentComplete;
190 m_actionName = newActionName;
193 emit actionNameChanged();
207
208
209
210
211
212
226 m_componentComplete =
true;
230
231
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
273 if (m_actionIds == newActionId)
276 if (m_componentComplete)
279 m_actionIds = newActionId;
281 if (m_componentComplete)
284 emit actionIdChanged();
288
289
290
291
292
293
294
295
296
297
298
299
308 setController(newHand);
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
336 if (m_controller == newController)
338 m_controller = newController;
339 emit controllerChanged();
344
345
346
347
348
349
358 if (m_enabled == newEnabled)
360 m_enabled = newEnabled;
361 emit enabledChanged();
366
367
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
415 QQuick3DXrActionMapper::registerHapticEffect(
this);
416 m_componentComplete =
true;
420
421
422
423
424
425
426
427
428
437 if (m_controller == newController)
439 m_controller = newController;
440 emit controllerChanged();
444
445
446
447
448
449
450
451
459 if (m_trigger == newTrigger)
464 case Condition::RisingEdge:
468 case Condition::TrailingEdge:
473 m_trigger = newTrigger;
474 emit triggerChanged();
478
479
480
481
485 return m_hapticEffect;
490 if (m_hapticEffect == newHapticEffect)
492 m_hapticEffect = newHapticEffect;
493 emit hapticEffectChanged();
497
498
499
500
501
502
503
504
505
506
507
515 if (m_condition == newCondition)
517 m_condition = newCondition;
518 emit conditionChanged();
522
523
524
531
532
533
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
static quint32 actionIntKey(const QQuick3DXrInputAction::Action id, const QQuick3DXrInputAction::Controller hand)
static QString actionStringKey(const QString &name, const QQuick3DXrInputAction::Controller hand)