xr_action_map.rst 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. .. _doc_xr_action_map:
  2. The XR action map
  3. =================
  4. Godot has an action map feature as part of the XR system.
  5. At this point in time this system is part of the OpenXR module.
  6. There are plans to encompass WebXR into this in the near future hence we call it
  7. the XR action map system in this document.
  8. It implements the built-in action map system of OpenXR mostly exactly as it is offered.
  9. The XR action map system exposes input, positional data and output for XR controllers
  10. to your game/application.
  11. It does this by exposing named actions that can be tailored to your game/application
  12. and binding these to the actual inputs and outputs on your XR devices.
  13. As the XR action map is currently part of the OpenXR module, OpenXR needs to be enabled
  14. in your project settings to expose it:
  15. .. image:: img/openxr_settings.webp
  16. You will then find the XR Action Map interface in the bottom of the screen:
  17. .. image:: img/xr_action_map.webp
  18. .. note::
  19. Godot's built-in input system has many things in common with the XR action map system.
  20. In fact our original idea was to add functionality to the existing input system and
  21. expose the data to the OpenXR action map system.
  22. We may revisit that idea at some point but as it turns out there were just too many
  23. problems to overcome.
  24. To name a few:
  25. * Godot's input system mainly centers around button inputs, XR adds triggers, axis,
  26. poses and haptics (output) into the mix.
  27. This would greatly complicate the input system with features that won't work for
  28. normal controllers or contrast with the current approach.
  29. It was felt this would lead to confusion for the majority of Godot users.
  30. * Godot's input system works with raw input data that is parsed and triggers emitting
  31. actions.
  32. This input data is made available to the end user.
  33. OpenXR completely hides raw data and does all the parsing for us, we only get
  34. access to already parsed action data.
  35. This inconsistency is likely to lead to bugs when an unsuspecting user tries to use
  36. an XR device as a normal input device.
  37. * Godot's input system allows changes to what inputs are bound to actions in runtime,
  38. OpenXR does not.
  39. * Godot's input system is based on device ids which are meaningless in OpenXR.
  40. This does mean that a game/application that mixes traditional inputs with XR
  41. controllers will have a separation.
  42. For most applications either one or the other is used and this is not seen as a problem.
  43. In the end, it's a limitation of the system.
  44. The default action map
  45. ----------------------
  46. Godot will automatically create a default action map if no action map file is found.
  47. .. warning::
  48. This default map was designed to help developers port their XR games/applications from
  49. Godot 3 to Godot 4.
  50. As a result this map essentially binds all known inputs on all controllers supported by
  51. default, to actions one on one.
  52. This is not a good example of setting up an action map.
  53. It does allow a new developer to have a starting point when they want to become
  54. familiar with Godot XR.
  55. It prevents having to design a proper action map for their game/application first.
  56. For this walkthrough we're going to start with a blank action map.
  57. You can delete the "Godot action set" entry at the top by pressing the trash can icon.
  58. This will clear out all actions.
  59. You might also want to remove the controllers that you do not wish to setup,
  60. more on this later.
  61. Action sets
  62. -----------
  63. .. note::
  64. Before we dive in, you will see the term XR runtime used throughout this document.
  65. With XR runtime we mean the software that is controlling and interacting with
  66. the AR or VR headset.
  67. The XR runtime then exposes this to us through an API such as OpenXR.
  68. So:
  69. * for Steam this is SteamVR,
  70. * for Meta on desktop this is the Oculus Client (including when using Quest link),
  71. * for Meta on Quest this is the Quest's native OpenXR client,
  72. * on Linux this could be Monado, etc.
  73. The action map allows us to organize our actions in sets.
  74. Each set can be enabled or disabled on its own.
  75. The concept here is that you could have different sets that provide bindings
  76. in different scenarios.
  77. You could have:
  78. * a ``Character control`` set for when you're walking around,
  79. * a ``Vehicle control`` set for when you're operating a vehicle,
  80. * a ``Menu`` set for when a menu is open.
  81. Only the action set applicable to the current state of your game/application
  82. can then be enabled.
  83. This is especially important if you wish to bind the same input on a controller
  84. to a different action.
  85. For instance:
  86. * in your ``Character control`` set you may have an action ``Jump``,
  87. * in your ``Vehicle control`` set you may have an action ``Accelerate``,
  88. * in your ``Menu`` set you may have an action ``Select``.
  89. All are bound to the trigger on your controller.
  90. OpenXR will only bind an input or output to a single action.
  91. If the same input or output is bound to multiple actions the one in the active action set
  92. with the highest priority will be the one updated/used.
  93. So in our above example it will thus be important that only one action set is active.
  94. For your first XR game/application we highly recommend starting with just
  95. a single action set and to not over-engineer things.
  96. For our walkthrough in this document we will thus create a single action set
  97. called ``my_first_action_set``.
  98. We do this by pressing the ``Add action set`` button:
  99. .. image:: img/xr_my_first_action_set.webp
  100. The columns in our table are as follows:
  101. .. list-table::
  102. :class: wrap-normal
  103. :width: 100%
  104. :widths: 7 23 70
  105. :header-rows: 1
  106. * - Col
  107. - Value
  108. - Description
  109. * - 1
  110. - my_first_action_set
  111. - This is the internal name of the action set.
  112. OpenXR doesn't specify specific restrictions on this name other then size, however
  113. some XR runtimes will not like spaces or special characters.
  114. * - 2
  115. - My first action set
  116. - This is a human-readable name for the action set.
  117. Some XR runtimes will display this name to the end user, for example in
  118. configuration dialogs.
  119. * - 3
  120. - 0
  121. - This is the priority of the action set.
  122. If multiple active action sets have actions bound to the same controllers inputs or
  123. outputs, the action set with the highest priority value will determine the action
  124. that is updated.
  125. Actions
  126. -------
  127. In the XR action map, actions are the entities that your game/application will
  128. interact with.
  129. For instance, we can define an action ``Shoot`` and the input bound to that action will
  130. trigger the ``button_pressed`` signal on the relevant :ref:`XRController3D <class_xrcontroller3d>`
  131. node in your scene with ``Shoot`` as the ``name`` parameter of the signal.
  132. You can also poll the current state of an action.
  133. :ref:`XRController3D <class_xrcontroller3d>` for instance has
  134. an ``is_button_pressed`` method.
  135. Actions can be used for both input and output and each action has a type that defines
  136. its behavior.
  137. * The ``Bool`` type is used for discrete input like buttons.
  138. * The ``Float`` type is used for analogue input like triggers.
  139. These two are special as they are the only ones that are interchangeable.
  140. OpenXR will handle conversions between ``Bool`` and ``Float`` inputs and actions.
  141. You can get the value of a ``Float`` type action by calling the method ``get_float`` on
  142. your :ref:`XRController3D <class_xrcontroller3d>` node.
  143. It emits the ``input_float_changed`` signal when changed.
  144. .. note::
  145. Where analogue inputs are queried as buttons a threshold is applied.
  146. This threshold is currently managed exclusively by the XR runtime.
  147. There are plans to extend Godot to provide some level of control over these thresholds
  148. in the future.
  149. The ``Vector2`` type defines the input as an axis input.
  150. Touchpads, thumbsticks and similar inputs are exposed as vectors.
  151. You can get the value of a ``Vector2`` type action by calling the method ``get_vector2``
  152. on your :ref:`XRController3D <class_xrcontroller3d>` node.
  153. It emits the ``input_vector2_changed`` signal when changed.
  154. The ``Pose`` type defines a spatially tracked input.
  155. Multiple "pose" inputs are available in OpenXR: ``aim``, ``grip`` and ``palm``.
  156. Your :ref:`XRController3D <class_xrcontroller3d>` node is automatically positioned based
  157. on the pose action assigned to ``pose`` property of this node.
  158. More about poses later.
  159. .. note::
  160. The OpenXR implementation in Godot also exposes a special pose called ``Skeleton``.
  161. This is part of the hand tracking implementation.
  162. This pose is exposed through the ``skeleton`` action that is supported outside of the
  163. action map system.
  164. It is thus always present if hand tracking is supported.
  165. You don't need to bind actions to this pose to use it.
  166. Finally, the only output type is ``Haptic`` and it allows us to set the intensity of
  167. haptic feedback, such as controller vibration.
  168. Controllers can have multiple haptic outputs and support for haptic vests is coming
  169. to OpenXR.
  170. So lets add an action for our aim pose, we do this by clicking on the ``+`` button for
  171. our action set:
  172. .. image:: img/xr_aim_pose.webp
  173. The columns in our table are as follows:
  174. .. list-table::
  175. :class: wrap-normal
  176. :width: 100%
  177. :widths: 7 23 70
  178. :header-rows: 1
  179. * - Col
  180. - Value
  181. - Description
  182. * - 1
  183. - aim_pose
  184. - This is the internal name of the action.
  185. OpenXR doesn't specify specific restrictions on this name other then size, however
  186. some XR runtimes will not like spaces or special characters.
  187. * - 2
  188. - Aim pose
  189. - This is a human-readable name for the action.
  190. Some XR runtimes will display this name to the end user, for example in
  191. configuration dialogs.
  192. * - 3
  193. - Pose
  194. - The type of this action.
  195. OpenXR defines a number of bindable input poses that are commonly available
  196. for controllers.
  197. There are no rules for which poses are supported for different controllers.
  198. The poses OpenXR currently defines are:
  199. * The aim pose on most controllers is positioned slightly in front of the controller
  200. and aims forward.
  201. This is a great pose to use for laser pointers or to align the muzzle of a weapon
  202. with.
  203. * The grip pose on most controllers is positioned where the grip button is placed on
  204. the controller.
  205. The orientation of this pose differs between controllers and can differ for the same
  206. controller on different XR runtimes.
  207. * The palm pose on most controllers is positioned in the center of the palm of the hand
  208. holding the controller.
  209. This is a new pose that is not available on all XR runtimes.
  210. .. note::
  211. If hand tracking is used, there are currently big differences in implementations
  212. between the different XR runtimes.
  213. As a result the action map is currently not suitable for hand tracking. Work is being
  214. done on this so stay tuned.
  215. Let's complete our list of actions for a very simple shooting game/application:
  216. .. image:: img/xr_all_actions.webp
  217. The actions we have added are:
  218. * movement, which allows the user to move around outside of normal room scale tracking.
  219. * grab, which detects that the user wants to hold something.
  220. * shoot, which detects that the user wants to fire the weapon they are holding.
  221. * haptic, which allows us to output haptic feedback.
  222. Now note that we don't distinguish between the left and right hand.
  223. This is something that is determined at the next stage.
  224. We've implemented the action system in such a way that you can bind the same action
  225. to both hands.
  226. The appropriate :ref:`XRController3D <class_xrcontroller3d>` node will emit the signal.
  227. .. warning::
  228. For both grab and shoot we've used the ``Bool`` type.
  229. As mentioned before, OpenXR does automatic conversions from an analogue controls
  230. however not all XR Runtimes currently apply sensible thresholds.
  231. We recommend as a workaround to use the ``Float`` type when interacting with triggers
  232. and grip buttons and apply your own threshold.
  233. For buttons like A/B/X/Y and similar where there is no analogue option, the ``Bool``
  234. type works fine.
  235. .. note::
  236. You can bind the same action to multiple inputs for the same controller on the same
  237. profile.
  238. In this case the XR runtime will attempt to combine the inputs.
  239. * For ``Bool`` inputs, this will perform an ``OR`` operation between the buttons.
  240. * For ``Float`` inputs, this will take the highest value of the bound inputs.
  241. * The behavior for ``Pose`` inputs is undefined, but the first bound input is likely to
  242. be used.
  243. You shouldn't bind multiple actions of the same action set to the same controller input.
  244. If you do this, or if actions are bound from multiple action sets but they have
  245. overlapping priorities, the behavior is undefined.
  246. The XR runtime may simply not accept your action map, or it may take this on a first
  247. come first serve basis.
  248. We are still investigating the restrictions around binding multiple actions to the same
  249. output as this scenario makes sense.
  250. The OpenXR specification seems to not allow this.
  251. Now that we have our basic actions defined, it's time to hook them up.
  252. Profiles
  253. --------
  254. In OpenXR controller bindings are captured in so-called "Interaction Profiles".
  255. We've shortened it to "Profiles" because it takes up less space.
  256. This generic name is chosen because controllers don't cover the entire system.
  257. Currently there are also profiles for trackers, remotes and tracked pens.
  258. There are also provisions for devices such as treadmills, haptic vests and such even though those are not part of the specification yet.
  259. .. warning::
  260. It is important to know that OpenXR has strict checking on supported devices.
  261. The core specification identifies a number of controllers and similar devices with
  262. their supported inputs and outputs.
  263. Every XR runtime must accept these interaction profiles even if they aren't applicable.
  264. New devices are added through extensions and XR runtimes must specify which ones they
  265. support.
  266. XR runtimes that do not support a device added through extensions will not accept these
  267. profiles.
  268. XR runtimes that do not support added input or output types will often crash if
  269. supplied.
  270. As such Godot keeps meta data of all available devices, their inputs and outputs and
  271. which extension adds support for them.
  272. You can create interaction profiles for all devices you wish to support.
  273. Godot will filter out those not supported by the XR runtime the user is using.
  274. This does mean that in order to support new devices, you might need to update to a more
  275. recent version of Godot.
  276. It is however also important to note that the action map has been designed
  277. with this in mind.
  278. When new devices enter the market, or when your users use devices that you
  279. do not have access to, the action map system relies on the XR runtime.
  280. It is the XR runtime's job to choose the best fitting interaction profile that has
  281. been specified and adapt it for the controller the user is using.
  282. How the XR runtime does this is left to the implementation of the runtime and there
  283. are thus vast differences between the runtimes.
  284. Some runtimes might even permit users to edit the bindings themselves.
  285. A common approach for a runtime is to look for a matching interaction profile first.
  286. If this is not found it will check the most common profiles such as that of
  287. the "Touch controller" and do a conversion.
  288. If all else fails, it will check the generic :ref:`"Simple controller" <doc_xr_action_map_simple>`.
  289. .. note::
  290. There is an important conclusion to be made here:
  291. When a controller is found, and the action map is applied to it, the XR runtime is not
  292. limited to the exact configurations you set up in Godot's action map editor.
  293. While the runtime will generally choose a suitable mapping based on one of the bindings
  294. you set up in the action map, it can deviate from it.
  295. For example, when the Touch controller profile is used any of the following scenarios
  296. could be true:
  297. * we could be using a Quest 1 controller,
  298. * we could be using a Quest 2 controller,
  299. * we could be using a Quest Pro controller but no Quest Pro profile was given or the
  300. XR runtime being used does not support the Quest Pro controller,
  301. * it could be a completely different controller for which no profile was given but
  302. the XR runtime is using the touch bindings as a base.
  303. Ergo, there currently is no way to know with certainty,
  304. which controller the user is actually using.
  305. .. warning::
  306. Finally, and this trips up a lot of people, the bindings aren't set in stone.
  307. It is fully allowed, and even expected, that an XR runtime allows a user
  308. to customise the bindings.
  309. At the moment none of the XR runtimes offer this functionality though SteamVR has
  310. an existing UI from OpenVRs action map system that is still accessible.
  311. This is actively being worked on however.
  312. Our first controller binding
  313. ----------------------------
  314. Let's set up our first controller binding, using the Touch controller as an example.
  315. Press "Add profile", find the Touch controller, and add it.
  316. If it is not in the list, then it may already have been added.
  317. .. image:: img/xr_add_touch_controller.webp
  318. Our UI now shows panels for both the left and right controllers.
  319. The panels contain all of the possible inputs and outputs for each controller.
  320. We can use the ``+`` next to each entry to bind it to an action:
  321. .. image:: img/xr_select_action.webp
  322. Let's finish our configuration:
  323. .. image:: img/xr_touch_completed.webp
  324. Each action is bound the given input or output for both controllers to indicate that
  325. we support the action on either controller.
  326. The exception is the movement action which is bound only to the right hand controller.
  327. It is likely that we would want to use the left hand thumbstick for a different purpose,
  328. say a teleport function.
  329. In developing your game/application you have to account for the possibility that
  330. the user changes the binding and binds the movement to the left hand thumbstick.
  331. Also note that our shoot and grab boolean actions are linked to inputs of type ``Float``.
  332. As mentioned before OpenXR will do conversions between the two, but do read the warning
  333. given on that subject earlier in this document.
  334. .. note::
  335. Some of the inputs seem to appear in our list multiple times.
  336. For instance we can find the ``X`` button twice, once as ``X click`` and then
  337. as ``X touch``.
  338. This is due to the Touch controller having a capacitive sensor.
  339. * ``X touch`` will be true if the user is merely touching the X button.
  340. * ``X click`` will be true when the user is actually pressing down on the button.
  341. Similarly for the thumbstick we have:
  342. * ``Thumbstick touch`` which will be true if the user is touching the thumbstick.
  343. * ``Thumbstick`` which gives a value for the direction the thumbstick is pushed to.
  344. * ``Thumbstick click`` which is true when the user is pressing down on the thumbstick.
  345. It is important to note that only a select number of XR controllers support
  346. touch sensors or have click features on thumbsticks.
  347. Keep that in mind when designing your game/application.
  348. Make sure these are used for optional features of your game/application.
  349. .. _doc_xr_action_map_simple:
  350. The simple controller
  351. ---------------------
  352. The "Simple controller" is a generic controller that OpenXR offers as a fallback.
  353. We'll apply our mapping:
  354. .. image:: img/xr_simple_controller.webp
  355. As becomes painfully clear, the simple controller is often far too simple
  356. and falls short for anything but the simplest of VR games/applications.
  357. This is why many XR runtimes only use it as a last resort and will attempt
  358. to use bindings from one of the more popular systems as a fallback first.
  359. .. note::
  360. Due to the simple controller likely not covering the needs of your game,
  361. it is tempting to provide bindings for every controller supported by OpenXR.
  362. The default action map seems to suggest this as a valid course of action.
  363. As mentioned before, the default action map was designed for ease of migration
  364. from Godot 3.
  365. It is the recommendation from the OpenXR Working Group that only bindings
  366. for controllers actually tested by the developer are setup.
  367. The XR runtimes are designed with this in mind.
  368. They can perform a better job of rebinding a provided binding than
  369. a developer can make educated guesses.
  370. Especially as the developer can't test if this leads to a comfortable experience
  371. for the end user.
  372. This is our advice as well: limit your action map to the interaction profiles
  373. for devices you have actually tested your game with.
  374. The Oculus Touch controller is widely used as a fallback controller by many runtimes.
  375. If you are able to test your game using a Meta Rift or Quest and add this profile
  376. there is a high probability your game will work with other headsets.
  377. Binding Modifiers
  378. -----------------
  379. One of the main goals of the action map is to remove the need for the application
  380. to know the hardware used.
  381. However, sometimes the hardware has physical differences that require inputs to
  382. be altered in ways other than how they are bound to actions.
  383. This need ranges from setting thresholds, to altering the inputs available
  384. on a controller.
  385. Binding modifiers are not enabled by default and require enabling in
  386. the OpenXR project settings.
  387. Also there is no guarantee that these modifiers are supported by every runtime.
  388. You will need to consult the support for the runtimes you are targeting
  389. and decide whether to rely on the modifiers or implement some form of fallback mechanism.
  390. If you are targeting multiple runtimes that have support for the same controllers,
  391. you may need to create separate action maps for each runtime.
  392. You can control which action map Godot uses by using different export templates
  393. for each runtime and using a custom :ref:`feature tag <doc_feature_tags>`
  394. to set the action map.
  395. In Godot, binding modifiers are divided into two groups:
  396. modifiers that work on the interaction profile level,
  397. and modifiers that work on individual bindings.
  398. Binding modifiers on an interaction profile
  399. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  400. Binding modifiers that are applied to the whole interaction profile can be accessed
  401. through the modifier button on the right side of the interaction profile editor.
  402. .. image:: img/openxr_ip_binding_modifier.webp
  403. You can add a new modifier by pressing the ``Add binding modifier`` button.
  404. .. warning::
  405. As Godot doesn't know which controllers and runtimes support a modifier,
  406. there is no restriction to adding modifiers.
  407. Unsupported modifiers will be ignored.
  408. Dpad Binding modifier
  409. ^^^^^^^^^^^^^^^^^^^^^
  410. The dpad binding modifier adds new inputs to an interaction profile for each joystick
  411. and thumbpad input on this controller.
  412. It turns the input into a dpad with separate up, down, left and right inputs
  413. that are exposed as buttons:
  414. .. image:: img/openxr_thumbstick_dpad.webp
  415. .. note::
  416. Inputs related to extensions are denoted with an asterix.
  417. In order to use the dpad binding modifier you need to enable
  418. the dpad binding modifier extension in project settings:
  419. .. image:: img/openxr_project_settings_dpad_modifier.webp
  420. Enabling the extension is enough to make this functionality work using default settings.
  421. Adding the modifier is optional and allows you to fine tune the way
  422. the dpad functionality behaves.
  423. You can add the modifier multiple times to set different settings for different inputs.
  424. .. image:: img/openxr_dpad_modifier.webp
  425. These settings are used as follows:
  426. * ``Action Set`` defines the action set to which these settings are applied.
  427. * ``Input Path`` defines the original input that is mapped to the new dpad inputs.
  428. * ``Threshold`` specifies the threshold value that will enable a dpad action,
  429. e.g. a value of ``0.6`` means that if the distance from center goes above ``0.6``
  430. the dpad action is pressed.
  431. * ``Threshold Released`` specifies the threshold value that will disable a dpad action,
  432. e.g. a value of ``0.4`` means that if the distance from center goes below ``0.4``
  433. the dpad action is released.
  434. * ``Center Region`` specifies the distance from center that enabled the center action,
  435. this is only supported for trackpads.
  436. * ``Wedge Angle`` specifies the angle of each wedge.
  437. A value of ``90 degrees`` or lower means that up, down, left and right each have
  438. a separate slice in which they are in the pressed state.
  439. A value above ``90 degrees`` means that the slices overlap and that multiple
  440. actions can be in the pressed state.
  441. * ``Is Sticky``, when enabled means that an action stays in the pressed state until
  442. the thumbstick or trackpad moves into another wedge even if it has left the wedge
  443. for that action.
  444. * ``On Haptic`` lets us define a haptic output that is automatically activated
  445. when an action becomes pressed.
  446. * ``Off Haptic`` lets us define a haptic output that is automatically activated
  447. when a action is released.
  448. Binding modifiers on individual bindings
  449. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  450. Binding modifiers that are applied to individual bindings can be accessed through
  451. the binding modifier button next to action attached to an input:
  452. .. image:: img/openxr_action_binding_modifier.webp
  453. You can add a new modifier by pressing the ``Add binding modifier`` button.
  454. .. warning::
  455. As Godot doesn't know which inputs on each runtime support a modifier,
  456. there is no restriction to adding modifiers.
  457. If the modifier extension is unsupported, modifiers will be filtered out at runtime.
  458. Modifiers added to the wrong input may result in a runtime error.
  459. You should test your action map on the actual hardware and runtime to verify
  460. the proper setup.
  461. Analog threshold modifier
  462. ^^^^^^^^^^^^^^^^^^^^^^^^^
  463. The analog threshold modifier allows you to specify the thresholds used for any analog
  464. input, like the trigger, that has a boolean input. This controls when the input is in
  465. the pressed state.
  466. In order to use this modifier you must enable the analog threshold extension in
  467. the project settings:
  468. .. image:: img/openxr_project_settings_analog_threshold_modifier.webp
  469. The analog threshold modifier has the following settings:
  470. .. image:: img/openxr_analog_threshold_modifier.webp
  471. These are defined as follows:
  472. * ``On Threshold`` specifies the threshold value that will enable the action,
  473. e.g. a value of ``0.6`` means that when the analog value gets above ``0.6``
  474. the action is set to the pressed state.
  475. * ``Off Threshold`` specifies the threshold value that will disable the action,
  476. e.g. a value of ``0.4`` means that when the analog value goes below ``0.4``
  477. the action is set in to the released state.
  478. * ``On Haptic`` lets us define a haptic output that is automatically activated
  479. when the input is pressed.
  480. * ``Off Haptic`` lets us define a haptic output that is automatically activated
  481. when the input is released.
  482. Haptics on modifiers
  483. ~~~~~~~~~~~~~~~~~~~~
  484. Modifiers can support automatic haptic output that is triggered when thresholds
  485. are reached.
  486. .. note::
  487. Currently both available modifiers support this feature however there is no rule future
  488. modifiers also have this capability.
  489. Only one type of haptic feedback is supported but in the future other options
  490. may become available.
  491. Haptic vibration
  492. ^^^^^^^^^^^^^^^^
  493. The haptic vibration allows us to specify a simple haptic pulse:
  494. .. image:: img/openxr_haptic_vibration.webp
  495. It has the following options:
  496. * ``Duration`` is the duration of the pulse in nanoseconds. ``-1`` lets the runtime
  497. choose an optimal value for a short pulse suitable for the current hardware.
  498. * ``Frequency`` is the frequency of the pulse in Hz. ``0`` lets the runtime choose
  499. an optimal frequency for a short pulse suitable for the current hardware.
  500. * ``Amplitude`` is the amplitude of the pulse.