Cleanup: quiet float argument to in type warning
[blender-addons.git] / viewport_vr_preview / defaults.py
blobf266b694c9b6d4664bb30842c491b875cacbfd51
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 if "bpy" in locals():
4 import importlib
5 importlib.reload(action_map)
6 else:
7 from . import action_map
9 import bpy
10 from bpy.app.handlers import persistent
11 from enum import Enum
12 import math
13 import os.path
16 # Default action maps.
17 class VRDefaultActionmaps(Enum):
18 DEFAULT = "blender_default"
19 GAMEPAD = "blender_default_gamepad"
22 # Default actions.
23 class VRDefaultActions(Enum):
24 CONTROLLER_GRIP = "controller_grip"
25 CONTROLLER_AIM = "controller_aim"
26 TELEPORT = "teleport"
27 NAV_GRAB = "nav_grab"
28 FLY = "fly"
29 FLY_FORWARD = "fly_forward"
30 FLY_BACK = "fly_back"
31 FLY_LEFT = "fly_left"
32 FLY_RIGHT = "fly_right"
33 FLY_UP = "fly_up"
34 FLY_DOWN = "fly_down"
35 FLY_TURNLEFT = "fly_turnleft"
36 FLY_TURNRIGHT = "fly_turnright"
37 NAV_RESET = "nav_reset"
38 HAPTIC = "haptic"
39 HAPTIC_LEFT = "haptic_left"
40 HAPTIC_RIGHT = "haptic_right"
41 HAPTIC_LEFTTRIGGER = "haptic_lefttrigger"
42 HAPTIC_RIGHTTRIGGER = "haptic_righttrigger"
45 # Default action bindings.
46 class VRDefaultActionbindings(Enum):
47 GAMEPAD = "gamepad"
48 HUAWEI = "huawei"
49 INDEX = "index"
50 OCULUS = "oculus"
51 REVERB_G2 = "reverb_g2"
52 SIMPLE = "simple"
53 VIVE = "vive"
54 VIVE_COSMOS = "vive_cosmos"
55 VIVE_FOCUS = "vive_focus"
56 WMR = "wmr"
59 class VRDefaultActionprofiles(Enum):
60 GAMEPAD = "/interaction_profiles/microsoft/xbox_controller"
61 HUAWEI = "/interaction_profiles/huawei/controller"
62 INDEX = "/interaction_profiles/valve/index_controller"
63 OCULUS = "/interaction_profiles/oculus/touch_controller"
64 REVERB_G2 = "/interaction_profiles/hp/mixed_reality_controller"
65 SIMPLE = "/interaction_profiles/khr/simple_controller"
66 VIVE = "/interaction_profiles/htc/vive_controller"
67 VIVE_COSMOS = "/interaction_profiles/htc/vive_cosmos_controller"
68 VIVE_FOCUS = "/interaction_profiles/htc/vive_focus3_controller"
69 WMR = "/interaction_profiles/microsoft/motion_controller"
72 def vr_defaults_actionmap_add(session_state, name):
73 am = session_state.actionmaps.new(session_state, name, True)
75 return am
78 def vr_defaults_action_add(am,
79 name,
80 user_paths,
81 op,
82 op_mode,
83 bimanual,
84 haptic_name,
85 haptic_match_user_paths,
86 haptic_duration,
87 haptic_frequency,
88 haptic_amplitude,
89 haptic_mode):
92 ami = am.actionmap_items.new(name, True)
93 if ami:
94 ami.type = 'FLOAT'
95 for path in user_paths:
96 ami.user_paths.new(path)
97 ami.op = op
98 ami.op_mode = op_mode
99 ami.bimanual = bimanual
100 ami.haptic_name = haptic_name
101 ami.haptic_match_user_paths = haptic_match_user_paths
102 ami.haptic_duration = haptic_duration
103 ami.haptic_frequency = haptic_frequency
104 ami.haptic_amplitude = haptic_amplitude
105 ami.haptic_mode = haptic_mode
107 return ami
110 def vr_defaults_pose_action_add(am,
111 name,
112 user_paths,
113 is_controller_grip,
114 is_controller_aim):
115 ami = am.actionmap_items.new(name, True)
116 if ami:
117 ami.type = 'POSE'
118 for path in user_paths:
119 ami.user_paths.new(path)
120 ami.pose_is_controller_grip = is_controller_grip
121 ami.pose_is_controller_aim = is_controller_aim
123 return ami
126 def vr_defaults_haptic_action_add(am,
127 name,
128 user_paths):
129 ami = am.actionmap_items.new(name, True)
130 if ami:
131 ami.type = 'VIBRATION'
132 for path in user_paths:
133 ami.user_paths.new(path)
135 return ami
138 def vr_defaults_actionbinding_add(ami,
139 name,
140 profile,
141 component_paths,
142 threshold,
143 axis0_region,
144 axis1_region):
145 amb = ami.bindings.new(name, True)
146 if amb:
147 amb.profile = profile
148 for path in component_paths:
149 amb.component_paths.new(path)
150 amb.threshold = threshold
151 amb.axis0_region = axis0_region
152 amb.axis1_region = axis1_region
154 return amb
157 def vr_defaults_pose_actionbinding_add(ami,
158 name,
159 profile,
160 component_paths,
161 location,
162 rotation):
163 amb = ami.bindings.new(name, True)
164 if amb:
165 amb.profile = profile
166 for path in component_paths:
167 amb.component_paths.new(path)
168 amb.pose_location = location
169 amb.pose_rotation = rotation
171 return amb
174 def vr_defaults_haptic_actionbinding_add(ami,
175 name,
176 profile,
177 component_paths):
178 amb = ami.bindings.new(name, True)
179 if amb:
180 amb.profile = profile
181 for path in component_paths:
182 amb.component_paths.new(path)
184 return amb
187 def vr_defaults_create_default(session_state):
188 am = vr_defaults_actionmap_add(session_state,
189 VRDefaultActionmaps.DEFAULT.value)
190 if not am:
191 return
193 ami = vr_defaults_pose_action_add(am,
194 VRDefaultActions.CONTROLLER_GRIP.value,
195 ["/user/hand/left",
196 "/user/hand/right"],
197 True,
198 False)
199 if ami:
200 vr_defaults_pose_actionbinding_add(ami,
201 VRDefaultActionbindings.HUAWEI.value,
202 VRDefaultActionprofiles.HUAWEI.value,
203 ["/input/grip/pose",
204 "/input/grip/pose"],
205 (0, 0, 0),
206 (0, 0, 0))
207 vr_defaults_pose_actionbinding_add(ami,
208 VRDefaultActionbindings.INDEX.value,
209 VRDefaultActionprofiles.INDEX.value,
210 ["/input/grip/pose",
211 "/input/grip/pose"],
212 (0, 0, 0),
213 (0, 0, 0))
214 vr_defaults_pose_actionbinding_add(ami,
215 VRDefaultActionbindings.OCULUS.value,
216 VRDefaultActionprofiles.OCULUS.value,
217 ["/input/grip/pose",
218 "/input/grip/pose"],
219 (0, 0, 0),
220 (0, 0, 0))
221 vr_defaults_pose_actionbinding_add(ami,
222 VRDefaultActionbindings.REVERB_G2.value,
223 VRDefaultActionprofiles.REVERB_G2.value,
224 ["/input/grip/pose",
225 "/input/grip/pose"],
226 (0, 0, 0),
227 (0, 0, 0))
228 vr_defaults_pose_actionbinding_add(ami,
229 VRDefaultActionbindings.SIMPLE.value,
230 VRDefaultActionprofiles.SIMPLE.value,
231 ["/input/grip/pose",
232 "/input/grip/pose"],
233 (0, 0, 0),
234 (0, 0, 0))
235 vr_defaults_pose_actionbinding_add(ami,
236 VRDefaultActionbindings.VIVE.value,
237 VRDefaultActionprofiles.VIVE.value,
238 ["/input/grip/pose",
239 "/input/grip/pose"],
240 (0, 0, 0),
241 (0, 0, 0))
242 vr_defaults_pose_actionbinding_add(ami,
243 VRDefaultActionbindings.VIVE_COSMOS.value,
244 VRDefaultActionprofiles.VIVE_COSMOS.value,
245 ["/input/grip/pose",
246 "/input/grip/pose"],
247 (0, 0, 0),
248 (0, 0, 0))
249 vr_defaults_pose_actionbinding_add(ami,
250 VRDefaultActionbindings.VIVE_FOCUS.value,
251 VRDefaultActionprofiles.VIVE_FOCUS.value,
252 ["/input/grip/pose",
253 "/input/grip/pose"],
254 (0, 0, 0),
255 (0, 0, 0))
256 vr_defaults_pose_actionbinding_add(ami,
257 VRDefaultActionbindings.WMR.value,
258 VRDefaultActionprofiles.WMR.value,
259 ["/input/grip/pose",
260 "/input/grip/pose"],
261 (0, 0, 0),
262 (0, 0, 0))
264 ami = vr_defaults_pose_action_add(am,
265 VRDefaultActions.CONTROLLER_AIM.value,
266 ["/user/hand/left",
267 "/user/hand/right"],
268 False,
269 True)
270 if ami:
271 vr_defaults_pose_actionbinding_add(ami,
272 VRDefaultActionbindings.HUAWEI.value,
273 VRDefaultActionprofiles.HUAWEI.value,
274 ["/input/aim/pose",
275 "/input/aim/pose"],
276 (0, 0, 0),
277 (0, 0, 0))
278 vr_defaults_pose_actionbinding_add(ami,
279 VRDefaultActionbindings.INDEX.value,
280 VRDefaultActionprofiles.INDEX.value,
281 ["/input/aim/pose",
282 "/input/aim/pose"],
283 (0, 0, 0),
284 (0, 0, 0))
285 vr_defaults_pose_actionbinding_add(ami,
286 VRDefaultActionbindings.OCULUS.value,
287 VRDefaultActionprofiles.OCULUS.value,
288 ["/input/aim/pose",
289 "/input/aim/pose"],
290 (0, 0, 0),
291 (0, 0, 0))
292 vr_defaults_pose_actionbinding_add(ami,
293 VRDefaultActionbindings.REVERB_G2.value,
294 VRDefaultActionprofiles.REVERB_G2.value,
295 ["/input/aim/pose",
296 "/input/aim/pose"],
297 (0, 0, 0),
298 (0, 0, 0))
299 vr_defaults_pose_actionbinding_add(ami,
300 VRDefaultActionbindings.SIMPLE.value,
301 VRDefaultActionprofiles.SIMPLE.value,
302 ["/input/aim/pose",
303 "/input/aim/pose"],
304 (0, 0, 0),
305 (0, 0, 0))
306 vr_defaults_pose_actionbinding_add(ami,
307 VRDefaultActionbindings.VIVE.value,
308 VRDefaultActionprofiles.VIVE.value,
309 ["/input/aim/pose",
310 "/input/aim/pose"],
311 (0, 0, 0),
312 (0, 0, 0))
313 vr_defaults_pose_actionbinding_add(ami,
314 VRDefaultActionbindings.VIVE_COSMOS.value,
315 VRDefaultActionprofiles.VIVE_COSMOS.value,
316 ["/input/aim/pose",
317 "/input/aim/pose"],
318 (0, 0, 0),
319 (0, 0, 0))
320 vr_defaults_pose_actionbinding_add(ami,
321 VRDefaultActionbindings.VIVE_FOCUS.value,
322 VRDefaultActionprofiles.VIVE_FOCUS.value,
323 ["/input/aim/pose",
324 "/input/aim/pose"],
325 (0, 0, 0),
326 (0, 0, 0))
327 vr_defaults_pose_actionbinding_add(ami,
328 VRDefaultActionbindings.WMR.value,
329 VRDefaultActionprofiles.WMR.value,
330 ["/input/aim/pose",
331 "/input/aim/pose"],
332 (0, 0, 0),
333 (0, 0, 0))
335 ami = vr_defaults_action_add(am,
336 VRDefaultActions.TELEPORT.value,
337 ["/user/hand/left",
338 "/user/hand/right"],
339 "wm.xr_navigation_teleport",
340 'MODAL',
341 False,
343 False,
344 0.0,
345 0.0,
346 0.0,
347 'PRESS')
348 if ami:
349 vr_defaults_actionbinding_add(ami,
350 VRDefaultActionbindings.HUAWEI.value,
351 VRDefaultActionprofiles.HUAWEI.value,
352 ["/input/trigger/value",
353 "/input/trigger/value"],
354 0.3,
355 'ANY',
356 'ANY')
357 vr_defaults_actionbinding_add(ami,
358 VRDefaultActionbindings.INDEX.value,
359 VRDefaultActionprofiles.INDEX.value,
360 ["/input/trigger/value",
361 "/input/trigger/value"],
362 0.3,
363 'ANY',
364 'ANY')
365 vr_defaults_actionbinding_add(ami,
366 VRDefaultActionbindings.OCULUS.value,
367 VRDefaultActionprofiles.OCULUS.value,
368 ["/input/trigger/value",
369 "/input/trigger/value"],
370 0.3,
371 'ANY',
372 'ANY')
373 vr_defaults_actionbinding_add(ami,
374 VRDefaultActionbindings.REVERB_G2.value,
375 VRDefaultActionprofiles.REVERB_G2.value,
376 ["/input/trigger/value",
377 "/input/trigger/value"],
378 0.3,
379 'ANY',
380 'ANY')
381 vr_defaults_actionbinding_add(ami,
382 VRDefaultActionbindings.SIMPLE.value,
383 VRDefaultActionprofiles.SIMPLE.value,
384 ["/input/select/click",
385 "/input/select/click"],
386 0.3,
387 'ANY',
388 'ANY')
389 vr_defaults_actionbinding_add(ami,
390 VRDefaultActionbindings.VIVE.value,
391 VRDefaultActionprofiles.VIVE.value,
392 ["/input/trigger/value",
393 "/input/trigger/value"],
394 0.3,
395 'ANY',
396 'ANY')
397 vr_defaults_actionbinding_add(ami,
398 VRDefaultActionbindings.VIVE_COSMOS.value,
399 VRDefaultActionprofiles.VIVE_COSMOS.value,
400 ["/input/trigger/value",
401 "/input/trigger/value"],
402 0.3,
403 'ANY',
404 'ANY')
405 vr_defaults_actionbinding_add(ami,
406 VRDefaultActionbindings.VIVE_FOCUS.value,
407 VRDefaultActionprofiles.VIVE_FOCUS.value,
408 ["/input/trigger/value",
409 "/input/trigger/value"],
410 0.3,
411 'ANY',
412 'ANY')
413 vr_defaults_actionbinding_add(ami,
414 VRDefaultActionbindings.WMR.value,
415 VRDefaultActionprofiles.WMR.value,
416 ["/input/trigger/value",
417 "/input/trigger/value"],
418 0.3,
419 'ANY',
420 'ANY')
422 ami = vr_defaults_action_add(am,
423 VRDefaultActions.NAV_GRAB.value,
424 ["/user/hand/left",
425 "/user/hand/right"],
426 "wm.xr_navigation_grab",
427 'MODAL',
428 True,
430 False,
431 0.0,
432 0.0,
433 0.0,
434 'PRESS')
435 if ami:
436 vr_defaults_actionbinding_add(ami,
437 VRDefaultActionbindings.HUAWEI.value,
438 VRDefaultActionprofiles.HUAWEI.value,
439 ["/input/trackpad/click",
440 "/input/trackpad/click"],
441 0.3,
442 'ANY',
443 'ANY')
444 vr_defaults_actionbinding_add(ami,
445 VRDefaultActionbindings.INDEX.value,
446 VRDefaultActionprofiles.INDEX.value,
447 ["/input/squeeze/force",
448 "/input/squeeze/force"],
449 0.5,
450 'ANY',
451 'ANY')
452 vr_defaults_actionbinding_add(ami,
453 VRDefaultActionbindings.OCULUS.value,
454 VRDefaultActionprofiles.OCULUS.value,
455 ["/input/squeeze/value",
456 "/input/squeeze/value"],
457 0.3,
458 'ANY',
459 'ANY')
460 vr_defaults_actionbinding_add(ami,
461 VRDefaultActionbindings.REVERB_G2.value,
462 VRDefaultActionprofiles.REVERB_G2.value,
463 ["/input/squeeze/value",
464 "/input/squeeze/value"],
465 0.3,
466 'ANY',
467 'ANY')
468 vr_defaults_actionbinding_add(ami,
469 VRDefaultActionbindings.SIMPLE.value,
470 VRDefaultActionprofiles.SIMPLE.value,
471 ["/input/menu/click",
472 "/input/menu/click"],
473 0.3,
474 'ANY',
475 'ANY')
476 vr_defaults_actionbinding_add(ami,
477 VRDefaultActionbindings.VIVE.value,
478 VRDefaultActionprofiles.VIVE.value,
479 ["/input/squeeze/click",
480 "/input/squeeze/click"],
481 0.3,
482 'ANY',
483 'ANY')
484 vr_defaults_actionbinding_add(ami,
485 VRDefaultActionbindings.VIVE_COSMOS.value,
486 VRDefaultActionprofiles.VIVE_COSMOS.value,
487 ["/input/squeeze/click",
488 "/input/squeeze/click"],
489 0.3,
490 'ANY',
491 'ANY')
492 vr_defaults_actionbinding_add(ami,
493 VRDefaultActionbindings.VIVE_FOCUS.value,
494 VRDefaultActionprofiles.VIVE_FOCUS.value,
495 ["/input/squeeze/click",
496 "/input/squeeze/click"],
497 0.3,
498 'ANY',
499 'ANY')
500 vr_defaults_actionbinding_add(ami,
501 VRDefaultActionbindings.WMR.value,
502 VRDefaultActionprofiles.WMR.value,
503 ["/input/squeeze/click",
504 "/input/squeeze/click"],
505 0.3,
506 'ANY',
507 'ANY')
509 ami = vr_defaults_action_add(am,
510 VRDefaultActions.FLY_FORWARD.value,
511 ["/user/hand/left"],
512 "wm.xr_navigation_fly",
513 'MODAL',
514 False,
516 False,
517 0.0,
518 0.0,
519 0.0,
520 'PRESS')
521 if ami:
522 vr_defaults_actionbinding_add(ami,
523 VRDefaultActionbindings.HUAWEI.value,
524 VRDefaultActionprofiles.HUAWEI.value,
525 ["/input/trackpad/y"],
526 0.3,
527 'POSITIVE',
528 'ANY')
529 vr_defaults_actionbinding_add(ami,
530 VRDefaultActionbindings.INDEX.value,
531 VRDefaultActionprofiles.INDEX.value,
532 ["/input/thumbstick/y"],
533 0.3,
534 'POSITIVE',
535 'ANY')
536 vr_defaults_actionbinding_add(ami,
537 VRDefaultActionbindings.OCULUS.value,
538 VRDefaultActionprofiles.OCULUS.value,
539 ["/input/thumbstick/y"],
540 0.3,
541 'POSITIVE',
542 'ANY')
543 vr_defaults_actionbinding_add(ami,
544 VRDefaultActionbindings.REVERB_G2.value,
545 VRDefaultActionprofiles.REVERB_G2.value,
546 ["/input/thumbstick/y"],
547 0.3,
548 'POSITIVE',
549 'ANY')
550 vr_defaults_actionbinding_add(ami,
551 VRDefaultActionbindings.VIVE.value,
552 VRDefaultActionprofiles.VIVE.value,
553 ["/input/trackpad/y"],
554 0.3,
555 'POSITIVE',
556 'ANY')
557 vr_defaults_actionbinding_add(ami,
558 VRDefaultActionbindings.VIVE_COSMOS.value,
559 VRDefaultActionprofiles.VIVE_COSMOS.value,
560 ["/input/thumbstick/y"],
561 0.3,
562 'POSITIVE',
563 'ANY')
564 vr_defaults_actionbinding_add(ami,
565 VRDefaultActionbindings.VIVE_FOCUS.value,
566 VRDefaultActionprofiles.VIVE_FOCUS.value,
567 ["/input/thumbstick/y"],
568 0.3,
569 'POSITIVE',
570 'ANY')
571 vr_defaults_actionbinding_add(ami,
572 VRDefaultActionbindings.WMR.value,
573 VRDefaultActionprofiles.WMR.value,
574 ["/input/thumbstick/y"],
575 0.3,
576 'POSITIVE',
577 'ANY')
579 ami = vr_defaults_action_add(am,
580 VRDefaultActions.FLY_BACK.value,
581 ["/user/hand/left"],
582 "wm.xr_navigation_fly",
583 'MODAL',
584 False,
586 False,
587 0.0,
588 0.0,
589 0.0,
590 'PRESS')
591 if ami:
592 vr_defaults_actionbinding_add(ami,
593 VRDefaultActionbindings.HUAWEI.value,
594 VRDefaultActionprofiles.HUAWEI.value,
595 ["/input/trackpad/y"],
596 0.3,
597 'NEGATIVE',
598 'ANY')
599 vr_defaults_actionbinding_add(ami,
600 VRDefaultActionbindings.INDEX.value,
601 VRDefaultActionprofiles.INDEX.value,
602 ["/input/thumbstick/y"],
603 0.3,
604 'NEGATIVE',
605 'ANY')
606 vr_defaults_actionbinding_add(ami,
607 VRDefaultActionbindings.OCULUS.value,
608 VRDefaultActionprofiles.OCULUS.value,
609 ["/input/thumbstick/y"],
610 0.3,
611 'NEGATIVE',
612 'ANY')
613 vr_defaults_actionbinding_add(ami,
614 VRDefaultActionbindings.REVERB_G2.value,
615 VRDefaultActionprofiles.REVERB_G2.value,
616 ["/input/thumbstick/y"],
617 0.3,
618 'NEGATIVE',
619 'ANY')
620 vr_defaults_actionbinding_add(ami,
621 VRDefaultActionbindings.VIVE.value,
622 VRDefaultActionprofiles.VIVE.value,
623 ["/input/trackpad/y"],
624 0.3,
625 'NEGATIVE',
626 'ANY')
627 vr_defaults_actionbinding_add(ami,
628 VRDefaultActionbindings.VIVE_COSMOS.value,
629 VRDefaultActionprofiles.VIVE_COSMOS.value,
630 ["/input/thumbstick/y"],
631 0.3,
632 'NEGATIVE',
633 'ANY')
634 vr_defaults_actionbinding_add(ami,
635 VRDefaultActionbindings.VIVE_FOCUS.value,
636 VRDefaultActionprofiles.VIVE_FOCUS.value,
637 ["/input/thumbstick/y"],
638 0.3,
639 'NEGATIVE',
640 'ANY')
641 vr_defaults_actionbinding_add(ami,
642 VRDefaultActionbindings.WMR.value,
643 VRDefaultActionprofiles.WMR.value,
644 ["/input/thumbstick/y"],
645 0.3,
646 'NEGATIVE',
647 'ANY')
649 ami = vr_defaults_action_add(am,
650 VRDefaultActions.FLY_LEFT.value,
651 ["/user/hand/left"],
652 "wm.xr_navigation_fly",
653 'MODAL',
654 False,
656 False,
657 0.0,
658 0.0,
659 0.0,
660 'PRESS')
661 if ami:
662 vr_defaults_actionbinding_add(ami,
663 VRDefaultActionbindings.HUAWEI.value,
664 VRDefaultActionprofiles.HUAWEI.value,
665 ["/input/trackpad/x"],
666 0.3,
667 'NEGATIVE',
668 'ANY')
669 vr_defaults_actionbinding_add(ami,
670 VRDefaultActionbindings.INDEX.value,
671 VRDefaultActionprofiles.INDEX.value,
672 ["/input/thumbstick/x"],
673 0.3,
674 'NEGATIVE',
675 'ANY')
676 vr_defaults_actionbinding_add(ami,
677 VRDefaultActionbindings.OCULUS.value,
678 VRDefaultActionprofiles.OCULUS.value,
679 ["/input/thumbstick/x"],
680 0.3,
681 'NEGATIVE',
682 'ANY')
683 vr_defaults_actionbinding_add(ami,
684 VRDefaultActionbindings.REVERB_G2.value,
685 VRDefaultActionprofiles.REVERB_G2.value,
686 ["/input/thumbstick/x"],
687 0.3,
688 'NEGATIVE',
689 'ANY')
690 vr_defaults_actionbinding_add(ami,
691 VRDefaultActionbindings.VIVE.value,
692 VRDefaultActionprofiles.VIVE.value,
693 ["/input/trackpad/x"],
694 0.3,
695 'NEGATIVE',
696 'ANY')
697 vr_defaults_actionbinding_add(ami,
698 VRDefaultActionbindings.VIVE_COSMOS.value,
699 VRDefaultActionprofiles.VIVE_COSMOS.value,
700 ["/input/thumbstick/x"],
701 0.3,
702 'NEGATIVE',
703 'ANY')
704 vr_defaults_actionbinding_add(ami,
705 VRDefaultActionbindings.VIVE_FOCUS.value,
706 VRDefaultActionprofiles.VIVE_FOCUS.value,
707 ["/input/thumbstick/x"],
708 0.3,
709 'NEGATIVE',
710 'ANY')
711 vr_defaults_actionbinding_add(ami,
712 VRDefaultActionbindings.WMR.value,
713 VRDefaultActionprofiles.WMR.value,
714 ["/input/thumbstick/x"],
715 0.3,
716 'NEGATIVE',
717 'ANY')
719 ami = vr_defaults_action_add(am,
720 VRDefaultActions.FLY_RIGHT.value,
721 ["/user/hand/left"],
722 "wm.xr_navigation_fly",
723 'MODAL',
724 False,
726 False,
727 0.0,
728 0.0,
729 0.0,
730 'PRESS')
731 if ami:
732 vr_defaults_actionbinding_add(ami,
733 VRDefaultActionbindings.HUAWEI.value,
734 VRDefaultActionprofiles.HUAWEI.value,
735 ["/input/trackpad/x"],
736 0.3,
737 'POSITIVE',
738 'ANY')
739 vr_defaults_actionbinding_add(ami,
740 VRDefaultActionbindings.INDEX.value,
741 VRDefaultActionprofiles.INDEX.value,
742 ["/input/thumbstick/x"],
743 0.3,
744 'POSITIVE',
745 'ANY')
746 vr_defaults_actionbinding_add(ami,
747 VRDefaultActionbindings.OCULUS.value,
748 VRDefaultActionprofiles.OCULUS.value,
749 ["/input/thumbstick/x"],
750 0.3,
751 'POSITIVE',
752 'ANY')
753 vr_defaults_actionbinding_add(ami,
754 VRDefaultActionbindings.REVERB_G2.value,
755 VRDefaultActionprofiles.REVERB_G2.value,
756 ["/input/thumbstick/x"],
757 0.3,
758 'POSITIVE',
759 'ANY')
760 vr_defaults_actionbinding_add(ami,
761 VRDefaultActionbindings.VIVE.value,
762 VRDefaultActionprofiles.VIVE.value,
763 ["/input/trackpad/x"],
764 0.3,
765 'POSITIVE',
766 'ANY')
767 vr_defaults_actionbinding_add(ami,
768 VRDefaultActionbindings.VIVE_COSMOS.value,
769 VRDefaultActionprofiles.VIVE_COSMOS.value,
770 ["/input/thumbstick/x"],
771 0.3,
772 'POSITIVE',
773 'ANY')
774 vr_defaults_actionbinding_add(ami,
775 VRDefaultActionbindings.VIVE_FOCUS.value,
776 VRDefaultActionprofiles.VIVE_FOCUS.value,
777 ["/input/thumbstick/x"],
778 0.3,
779 'POSITIVE',
780 'ANY')
781 vr_defaults_actionbinding_add(ami,
782 VRDefaultActionbindings.WMR.value,
783 VRDefaultActionprofiles.WMR.value,
784 ["/input/thumbstick/x"],
785 0.3,
786 'POSITIVE',
787 'ANY')
789 ami = vr_defaults_action_add(am,
790 VRDefaultActions.FLY_UP.value,
791 ["/user/hand/right"],
792 "wm.xr_navigation_fly",
793 'MODAL',
794 False,
796 False,
797 0.0,
798 0.0,
799 0.0,
800 'PRESS')
801 if ami:
802 vr_defaults_actionbinding_add(ami,
803 VRDefaultActionbindings.HUAWEI.value,
804 VRDefaultActionprofiles.HUAWEI.value,
805 ["/input/trackpad/y"],
806 0.3,
807 'POSITIVE',
808 'ANY')
809 vr_defaults_actionbinding_add(ami,
810 VRDefaultActionbindings.INDEX.value,
811 VRDefaultActionprofiles.INDEX.value,
812 ["/input/thumbstick/y"],
813 0.3,
814 'POSITIVE',
815 'ANY')
816 vr_defaults_actionbinding_add(ami,
817 VRDefaultActionbindings.OCULUS.value,
818 VRDefaultActionprofiles.OCULUS.value,
819 ["/input/thumbstick/y"],
820 0.3,
821 'POSITIVE',
822 'ANY')
823 vr_defaults_actionbinding_add(ami,
824 VRDefaultActionbindings.REVERB_G2.value,
825 VRDefaultActionprofiles.REVERB_G2.value,
826 ["/input/thumbstick/y"],
827 0.3,
828 'POSITIVE',
829 'ANY')
830 vr_defaults_actionbinding_add(ami,
831 VRDefaultActionbindings.VIVE.value,
832 VRDefaultActionprofiles.VIVE.value,
833 ["/input/trackpad/y"],
834 0.3,
835 'POSITIVE',
836 'ANY')
837 vr_defaults_actionbinding_add(ami,
838 VRDefaultActionbindings.VIVE_COSMOS.value,
839 VRDefaultActionprofiles.VIVE_COSMOS.value,
840 ["/input/thumbstick/y"],
841 0.3,
842 'POSITIVE',
843 'ANY')
844 vr_defaults_actionbinding_add(ami,
845 VRDefaultActionbindings.VIVE_FOCUS.value,
846 VRDefaultActionprofiles.VIVE_FOCUS.value,
847 ["/input/thumbstick/y"],
848 0.3,
849 'POSITIVE',
850 'ANY')
851 vr_defaults_actionbinding_add(ami,
852 VRDefaultActionbindings.WMR.value,
853 VRDefaultActionprofiles.WMR.value,
854 ["/input/thumbstick/y"],
855 0.3,
856 'POSITIVE',
857 'ANY')
859 ami = vr_defaults_action_add(am,
860 VRDefaultActions.FLY_DOWN.value,
861 ["/user/hand/right"],
862 "wm.xr_navigation_fly",
863 'MODAL',
864 False,
866 False,
867 0.0,
868 0.0,
869 0.0,
870 'PRESS')
871 if ami:
872 vr_defaults_actionbinding_add(ami,
873 VRDefaultActionbindings.HUAWEI.value,
874 VRDefaultActionprofiles.HUAWEI.value,
875 ["/input/trackpad/y"],
876 0.3,
877 'NEGATIVE',
878 'ANY')
879 vr_defaults_actionbinding_add(ami,
880 VRDefaultActionbindings.INDEX.value,
881 VRDefaultActionprofiles.INDEX.value,
882 ["/input/thumbstick/y"],
883 0.3,
884 'NEGATIVE',
885 'ANY')
886 vr_defaults_actionbinding_add(ami,
887 VRDefaultActionbindings.OCULUS.value,
888 VRDefaultActionprofiles.OCULUS.value,
889 ["/input/thumbstick/y"],
890 0.3,
891 'NEGATIVE',
892 'ANY')
893 vr_defaults_actionbinding_add(ami,
894 VRDefaultActionbindings.REVERB_G2.value,
895 VRDefaultActionprofiles.REVERB_G2.value,
896 ["/input/thumbstick/y"],
897 0.3,
898 'NEGATIVE',
899 'ANY')
900 vr_defaults_actionbinding_add(ami,
901 VRDefaultActionbindings.VIVE.value,
902 VRDefaultActionprofiles.VIVE.value,
903 ["/input/trackpad/y"],
904 0.3,
905 'NEGATIVE',
906 'ANY')
907 vr_defaults_actionbinding_add(ami,
908 VRDefaultActionbindings.VIVE_COSMOS.value,
909 VRDefaultActionprofiles.VIVE_COSMOS.value,
910 ["/input/thumbstick/y"],
911 0.3,
912 'NEGATIVE',
913 'ANY')
914 vr_defaults_actionbinding_add(ami,
915 VRDefaultActionbindings.VIVE_FOCUS.value,
916 VRDefaultActionprofiles.VIVE_FOCUS.value,
917 ["/input/thumbstick/y"],
918 0.3,
919 'NEGATIVE',
920 'ANY')
921 vr_defaults_actionbinding_add(ami,
922 VRDefaultActionbindings.WMR.value,
923 VRDefaultActionprofiles.WMR.value,
924 ["/input/thumbstick/y"],
925 0.3,
926 'NEGATIVE',
927 'ANY')
929 ami = vr_defaults_action_add(am,
930 VRDefaultActions.FLY_TURNLEFT.value,
931 ["/user/hand/right"],
932 "wm.xr_navigation_fly",
933 'MODAL',
934 False,
936 False,
937 0.0,
938 0.0,
939 0.0,
940 'PRESS')
941 if ami:
942 vr_defaults_actionbinding_add(ami,
943 VRDefaultActionbindings.HUAWEI.value,
944 VRDefaultActionprofiles.HUAWEI.value,
945 ["/input/trackpad/x"],
946 0.3,
947 'NEGATIVE',
948 'ANY')
949 vr_defaults_actionbinding_add(ami,
950 VRDefaultActionbindings.INDEX.value,
951 VRDefaultActionprofiles.INDEX.value,
952 ["/input/thumbstick/x"],
953 0.3,
954 'NEGATIVE',
955 'ANY')
956 vr_defaults_actionbinding_add(ami,
957 VRDefaultActionbindings.OCULUS.value,
958 VRDefaultActionprofiles.OCULUS.value,
959 ["/input/thumbstick/x"],
960 0.3,
961 'NEGATIVE',
962 'ANY')
963 vr_defaults_actionbinding_add(ami,
964 VRDefaultActionbindings.REVERB_G2.value,
965 VRDefaultActionprofiles.REVERB_G2.value,
966 ["/input/thumbstick/x"],
967 0.3,
968 'NEGATIVE',
969 'ANY')
970 vr_defaults_actionbinding_add(ami,
971 VRDefaultActionbindings.VIVE.value,
972 VRDefaultActionprofiles.VIVE.value,
973 ["/input/trackpad/x"],
974 0.3,
975 'NEGATIVE',
976 'ANY')
977 vr_defaults_actionbinding_add(ami,
978 VRDefaultActionbindings.VIVE_COSMOS.value,
979 VRDefaultActionprofiles.VIVE_COSMOS.value,
980 ["/input/thumbstick/x"],
981 0.3,
982 'NEGATIVE',
983 'ANY')
984 vr_defaults_actionbinding_add(ami,
985 VRDefaultActionbindings.VIVE_FOCUS.value,
986 VRDefaultActionprofiles.VIVE_FOCUS.value,
987 ["/input/thumbstick/x"],
988 0.3,
989 'NEGATIVE',
990 'ANY')
991 vr_defaults_actionbinding_add(ami,
992 VRDefaultActionbindings.WMR.value,
993 VRDefaultActionprofiles.WMR.value,
994 ["/input/thumbstick/x"],
995 0.3,
996 'NEGATIVE',
997 'ANY')
999 ami = vr_defaults_action_add(am,
1000 VRDefaultActions.FLY_TURNRIGHT.value,
1001 ["/user/hand/right"],
1002 "wm.xr_navigation_fly",
1003 'MODAL',
1004 False,
1006 False,
1007 0.0,
1008 0.0,
1009 0.0,
1010 'PRESS')
1011 if ami:
1012 vr_defaults_actionbinding_add(ami,
1013 VRDefaultActionbindings.HUAWEI.value,
1014 VRDefaultActionprofiles.HUAWEI.value,
1015 ["/input/trackpad/x"],
1016 0.3,
1017 'POSITIVE',
1018 'ANY')
1019 vr_defaults_actionbinding_add(ami,
1020 VRDefaultActionbindings.INDEX.value,
1021 VRDefaultActionprofiles.INDEX.value,
1022 ["/input/thumbstick/x"],
1023 0.3,
1024 'POSITIVE',
1025 'ANY')
1026 vr_defaults_actionbinding_add(ami,
1027 VRDefaultActionbindings.OCULUS.value,
1028 VRDefaultActionprofiles.OCULUS.value,
1029 ["/input/thumbstick/x"],
1030 0.3,
1031 'POSITIVE',
1032 'ANY')
1033 vr_defaults_actionbinding_add(ami,
1034 VRDefaultActionbindings.REVERB_G2.value,
1035 VRDefaultActionprofiles.REVERB_G2.value,
1036 ["/input/thumbstick/x"],
1037 0.3,
1038 'POSITIVE',
1039 'ANY')
1040 vr_defaults_actionbinding_add(ami,
1041 VRDefaultActionbindings.VIVE.value,
1042 VRDefaultActionprofiles.VIVE.value,
1043 ["/input/trackpad/x"],
1044 0.3,
1045 'POSITIVE',
1046 'ANY')
1047 vr_defaults_actionbinding_add(ami,
1048 VRDefaultActionbindings.VIVE_COSMOS.value,
1049 VRDefaultActionprofiles.VIVE_COSMOS.value,
1050 ["/input/thumbstick/x"],
1051 0.3,
1052 'POSITIVE',
1053 'ANY')
1054 vr_defaults_actionbinding_add(ami,
1055 VRDefaultActionbindings.VIVE_FOCUS.value,
1056 VRDefaultActionprofiles.VIVE_FOCUS.value,
1057 ["/input/thumbstick/x"],
1058 0.3,
1059 'POSITIVE',
1060 'ANY')
1061 vr_defaults_actionbinding_add(ami,
1062 VRDefaultActionbindings.WMR.value,
1063 VRDefaultActionprofiles.WMR.value,
1064 ["/input/thumbstick/x"],
1065 0.3,
1066 'POSITIVE',
1067 'ANY')
1069 ami = vr_defaults_action_add(am,
1070 VRDefaultActions.NAV_RESET.value,
1071 ["/user/hand/left",
1072 "/user/hand/right"],
1073 "wm.xr_navigation_reset",
1074 'PRESS',
1075 False,
1076 "haptic",
1077 True,
1078 0.3,
1079 3000.0,
1080 0.5,
1081 'PRESS')
1082 if ami:
1083 vr_defaults_actionbinding_add(ami,
1084 VRDefaultActionbindings.HUAWEI.value,
1085 VRDefaultActionprofiles.HUAWEI.value,
1086 ["/input/back/click",
1087 "/input/back/click"],
1088 0.3,
1089 'ANY',
1090 'ANY')
1091 vr_defaults_actionbinding_add(ami,
1092 VRDefaultActionbindings.INDEX.value,
1093 VRDefaultActionprofiles.INDEX.value,
1094 ["/input/a/click",
1095 "/input/a/click"],
1096 0.3,
1097 'ANY',
1098 'ANY')
1099 vr_defaults_actionbinding_add(ami,
1100 VRDefaultActionbindings.OCULUS.value,
1101 VRDefaultActionprofiles.OCULUS.value,
1102 ["/input/x/click",
1103 "/input/a/click"],
1104 0.3,
1105 'ANY',
1106 'ANY')
1107 vr_defaults_actionbinding_add(ami,
1108 VRDefaultActionbindings.REVERB_G2.value,
1109 VRDefaultActionprofiles.REVERB_G2.value,
1110 ["/input/x/click",
1111 "/input/a/click"],
1112 0.3,
1113 'ANY',
1114 'ANY')
1115 vr_defaults_actionbinding_add(ami,
1116 VRDefaultActionbindings.VIVE.value,
1117 VRDefaultActionprofiles.VIVE.value,
1118 ["/input/menu/click",
1119 "/input/menu/click"],
1120 0.3,
1121 'ANY',
1122 'ANY')
1123 vr_defaults_actionbinding_add(ami,
1124 VRDefaultActionbindings.VIVE_COSMOS.value,
1125 VRDefaultActionprofiles.VIVE_COSMOS.value,
1126 ["/input/x/click",
1127 "/input/a/click"],
1128 0.3,
1129 'ANY',
1130 'ANY')
1131 vr_defaults_actionbinding_add(ami,
1132 VRDefaultActionbindings.VIVE_FOCUS.value,
1133 VRDefaultActionprofiles.VIVE_FOCUS.value,
1134 ["/input/x/click",
1135 "/input/a/click"],
1136 0.3,
1137 'ANY',
1138 'ANY')
1139 vr_defaults_actionbinding_add(ami,
1140 VRDefaultActionbindings.WMR.value,
1141 VRDefaultActionprofiles.WMR.value,
1142 ["/input/menu/click",
1143 "/input/menu/click"],
1144 0.3,
1145 'ANY',
1146 'ANY')
1148 ami = vr_defaults_haptic_action_add(am,
1149 VRDefaultActions.HAPTIC.value,
1150 ["/user/hand/left",
1151 "/user/hand/right"])
1152 if ami:
1153 vr_defaults_haptic_actionbinding_add(ami,
1154 VRDefaultActionbindings.HUAWEI.value,
1155 VRDefaultActionprofiles.HUAWEI.value,
1156 ["/output/haptic",
1157 "/output/haptic"])
1158 vr_defaults_haptic_actionbinding_add(ami,
1159 VRDefaultActionbindings.INDEX.value,
1160 VRDefaultActionprofiles.INDEX.value,
1161 ["/output/haptic",
1162 "/output/haptic"])
1163 vr_defaults_haptic_actionbinding_add(ami,
1164 VRDefaultActionbindings.OCULUS.value,
1165 VRDefaultActionprofiles.OCULUS.value,
1166 ["/output/haptic",
1167 "/output/haptic"])
1168 vr_defaults_haptic_actionbinding_add(ami,
1169 VRDefaultActionbindings.REVERB_G2.value,
1170 VRDefaultActionprofiles.REVERB_G2.value,
1171 ["/output/haptic",
1172 "/output/haptic"])
1173 vr_defaults_haptic_actionbinding_add(ami,
1174 VRDefaultActionbindings.SIMPLE.value,
1175 VRDefaultActionprofiles.SIMPLE.value,
1176 ["/output/haptic",
1177 "/output/haptic"])
1178 vr_defaults_haptic_actionbinding_add(ami,
1179 VRDefaultActionbindings.VIVE.value,
1180 VRDefaultActionprofiles.VIVE.value,
1181 ["/output/haptic",
1182 "/output/haptic"])
1183 vr_defaults_haptic_actionbinding_add(ami,
1184 VRDefaultActionbindings.VIVE_COSMOS.value,
1185 VRDefaultActionprofiles.VIVE_COSMOS.value,
1186 ["/output/haptic",
1187 "/output/haptic"])
1188 vr_defaults_haptic_actionbinding_add(ami,
1189 VRDefaultActionbindings.VIVE_FOCUS.value,
1190 VRDefaultActionprofiles.VIVE_FOCUS.value,
1191 ["/output/haptic",
1192 "/output/haptic"])
1193 vr_defaults_haptic_actionbinding_add(ami,
1194 VRDefaultActionbindings.WMR.value,
1195 VRDefaultActionprofiles.WMR.value,
1196 ["/output/haptic",
1197 "/output/haptic"])
1200 def vr_defaults_create_default_gamepad(session_state):
1201 am = vr_defaults_actionmap_add(session_state,
1202 VRDefaultActionmaps.GAMEPAD.value)
1204 ami = vr_defaults_action_add(am,
1205 VRDefaultActions.TELEPORT.value,
1206 ["/user/gamepad"],
1207 "wm.xr_navigation_teleport",
1208 'MODAL',
1209 False,
1211 False,
1212 0.0,
1213 0.0,
1214 0.0,
1215 'PRESS')
1216 if ami:
1217 vr_defaults_actionbinding_add(ami,
1218 VRDefaultActionbindings.GAMEPAD.value,
1219 VRDefaultActionprofiles.GAMEPAD.value,
1220 ["/input/trigger_right/value"],
1221 0.3,
1222 'ANY',
1223 'ANY')
1225 ami = vr_defaults_action_add(am,
1226 VRDefaultActions.FLY.value,
1227 ["/user/gamepad"],
1228 "wm.xr_navigation_fly",
1229 'MODAL',
1230 False,
1232 False,
1233 0.0,
1234 0.0,
1235 0.0,
1236 'PRESS')
1237 if ami:
1238 vr_defaults_actionbinding_add(ami,
1239 VRDefaultActionbindings.GAMEPAD.value,
1240 VRDefaultActionprofiles.GAMEPAD.value,
1241 ["/input/trigger_left/value"],
1242 0.3,
1243 'ANY',
1244 'ANY')
1246 ami = vr_defaults_action_add(am,
1247 VRDefaultActions.FLY_FORWARD.value,
1248 ["/user/gamepad"],
1249 "wm.xr_navigation_fly",
1250 'MODAL',
1251 False,
1253 False,
1254 0.0,
1255 0.0,
1256 0.0,
1257 'PRESS')
1258 if ami:
1259 vr_defaults_actionbinding_add(ami,
1260 VRDefaultActionbindings.GAMEPAD.value,
1261 VRDefaultActionprofiles.GAMEPAD.value,
1262 ["/input/thumbstick_left/y"],
1263 0.3,
1264 'POSITIVE',
1265 'ANY')
1267 ami = vr_defaults_action_add(am,
1268 VRDefaultActions.FLY_BACK.value,
1269 ["/user/gamepad"],
1270 "wm.xr_navigation_fly",
1271 'MODAL',
1272 False,
1274 False,
1275 0.0,
1276 0.0,
1277 0.0,
1278 'PRESS')
1279 if ami:
1280 vr_defaults_actionbinding_add(ami,
1281 VRDefaultActionbindings.GAMEPAD.value,
1282 VRDefaultActionprofiles.GAMEPAD.value,
1283 ["/input/thumbstick_left/y"],
1284 0.3,
1285 'NEGATIVE',
1286 'ANY')
1288 ami = vr_defaults_action_add(am,
1289 VRDefaultActions.FLY_LEFT.value,
1290 ["/user/gamepad"],
1291 "wm.xr_navigation_fly",
1292 'MODAL',
1293 False,
1295 False,
1296 0.0,
1297 0.0,
1298 0.0,
1299 'PRESS')
1300 if ami:
1301 vr_defaults_actionbinding_add(ami,
1302 VRDefaultActionbindings.GAMEPAD.value,
1303 VRDefaultActionprofiles.GAMEPAD.value,
1304 ["/input/thumbstick_left/x"],
1305 0.3,
1306 'NEGATIVE',
1307 'ANY')
1309 ami = vr_defaults_action_add(am,
1310 VRDefaultActions.FLY_RIGHT.value,
1311 ["/user/gamepad"],
1312 "wm.xr_navigation_fly",
1313 'MODAL',
1314 False,
1316 False,
1317 0.0,
1318 0.0,
1319 0.0,
1320 'PRESS')
1321 if ami:
1322 vr_defaults_actionbinding_add(ami,
1323 VRDefaultActionbindings.GAMEPAD.value,
1324 VRDefaultActionprofiles.GAMEPAD.value,
1325 ["/input/thumbstick_left/x"],
1326 0.3,
1327 'POSITIVE',
1328 'ANY')
1330 ami = vr_defaults_action_add(am,
1331 VRDefaultActions.FLY_UP.value,
1332 ["/user/gamepad"],
1333 "wm.xr_navigation_fly",
1334 'MODAL',
1335 False,
1337 False,
1338 0.0,
1339 0.0,
1340 0.0,
1341 'PRESS')
1342 if ami:
1343 vr_defaults_actionbinding_add(ami,
1344 VRDefaultActionbindings.GAMEPAD.value,
1345 VRDefaultActionprofiles.GAMEPAD.value,
1346 ["/input/thumbstick_right/y"],
1347 0.3,
1348 'POSITIVE',
1349 'ANY')
1351 ami = vr_defaults_action_add(am,
1352 VRDefaultActions.FLY_DOWN.value,
1353 ["/user/gamepad"],
1354 "wm.xr_navigation_fly",
1355 'MODAL',
1356 False,
1358 False,
1359 0.0,
1360 0.0,
1361 0.0,
1362 'PRESS')
1363 if ami:
1364 vr_defaults_actionbinding_add(ami,
1365 VRDefaultActionbindings.GAMEPAD.value,
1366 VRDefaultActionprofiles.GAMEPAD.value,
1367 ["/input/thumbstick_right/y"],
1368 0.3,
1369 'NEGATIVE',
1370 'ANY')
1372 ami = vr_defaults_action_add(am,
1373 VRDefaultActions.FLY_TURNLEFT.value,
1374 ["/user/gamepad"],
1375 "wm.xr_navigation_fly",
1376 'MODAL',
1377 False,
1379 False,
1380 0.0,
1381 0.0,
1382 0.0,
1383 'PRESS')
1384 if ami:
1385 vr_defaults_actionbinding_add(ami,
1386 VRDefaultActionbindings.GAMEPAD.value,
1387 VRDefaultActionprofiles.GAMEPAD.value,
1388 ["/input/thumbstick_right/x"],
1389 0.3,
1390 'NEGATIVE',
1391 'ANY')
1393 ami = vr_defaults_action_add(am,
1394 VRDefaultActions.FLY_TURNRIGHT.value,
1395 ["/user/gamepad"],
1396 "wm.xr_navigation_fly",
1397 'MODAL',
1398 False,
1400 False,
1401 0.0,
1402 0.0,
1403 0.0,
1404 'PRESS')
1405 if ami:
1406 vr_defaults_actionbinding_add(ami,
1407 VRDefaultActionbindings.GAMEPAD.value,
1408 VRDefaultActionprofiles.GAMEPAD.value,
1409 ["/input/thumbstick_right/x"],
1410 0.3,
1411 'POSITIVE',
1412 'ANY')
1414 ami = vr_defaults_action_add(am,
1415 VRDefaultActions.NAV_RESET.value,
1416 ["/user/gamepad"],
1417 "wm.xr_navigation_reset",
1418 'PRESS',
1419 False,
1420 "haptic_right",
1421 True,
1422 0.3,
1423 3000.0,
1424 0.5,
1425 'PRESS')
1426 if ami:
1427 vr_defaults_actionbinding_add(ami,
1428 VRDefaultActionbindings.GAMEPAD.value,
1429 VRDefaultActionprofiles.GAMEPAD.value,
1430 ["/input/a/click"],
1431 0.3,
1432 'ANY',
1433 'ANY')
1435 ami =vr_defaults_haptic_action_add(am,
1436 VRDefaultActions.HAPTIC_LEFT.value,
1437 ["/user/gamepad"])
1438 if ami:
1439 vr_defaults_haptic_actionbinding_add(ami,
1440 VRDefaultActionbindings.GAMEPAD.value,
1441 VRDefaultActionprofiles.GAMEPAD.value,
1442 ["/output/haptic_left"])
1444 ami =vr_defaults_haptic_action_add(am,
1445 VRDefaultActions.HAPTIC_RIGHT.value,
1446 ["/user/gamepad"])
1447 if ami:
1448 vr_defaults_haptic_actionbinding_add(ami,
1449 VRDefaultActionbindings.GAMEPAD.value,
1450 VRDefaultActionprofiles.GAMEPAD.value,
1451 ["/output/haptic_right"])
1453 ami = vr_defaults_haptic_action_add(am,
1454 VRDefaultActions.HAPTIC_LEFTTRIGGER.value,
1455 ["/user/gamepad"])
1456 if ami:
1457 vr_defaults_haptic_actionbinding_add(ami,
1458 VRDefaultActionbindings.GAMEPAD.value,
1459 VRDefaultActionprofiles.GAMEPAD.value,
1460 ["/output/haptic_left_trigger"])
1462 ami = vr_defaults_haptic_action_add(am,
1463 VRDefaultActions.HAPTIC_RIGHTTRIGGER.value,
1464 ["/user/gamepad"])
1465 if ami:
1466 vr_defaults_haptic_actionbinding_add(ami,
1467 VRDefaultActionbindings.GAMEPAD.value,
1468 VRDefaultActionprofiles.GAMEPAD.value,
1469 ["/output/haptic_right_trigger"])
1472 def vr_get_default_config_path():
1473 filepath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "configs")
1474 return os.path.join(filepath, "default.py")
1477 def vr_ensure_default_actionmaps(session_state):
1478 loaded = True
1480 for name in VRDefaultActionmaps:
1481 if not session_state.actionmaps.find(session_state, name.value):
1482 loaded = False
1483 break
1485 if loaded:
1486 return loaded
1488 # Load default action maps.
1489 filepath = vr_get_default_config_path()
1491 if not os.path.exists(filepath):
1492 # Create and save default action maps.
1493 vr_defaults_create_default(session_state)
1494 vr_defaults_create_default_gamepad(session_state)
1496 action_map.vr_save_actionmaps(session_state, filepath, sort=False)
1498 loaded = action_map.vr_load_actionmaps(session_state, filepath)
1500 return loaded