Skip to content

Commit 8bfc432

Browse files
committed
Merge branch 'main' of https://github.com/pmndrs/xr
2 parents 2f08a5a + 1e49d03 commit 8bfc432

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

docs/getting-started/all-hooks.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ Inputs are a key aspect of react-three/fiber. The following hooks provide access
5454

5555
### `useXRInputSourceEvent`
5656

57-
Hook for listening to xr input source events.
57+
Hook for listening to xr input source events. [List of events](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSourceEvent).
58+
59+
- `inputSource`: The input source to listen to, or 'all' to listen to all input sources
60+
- `event`: The event to listen to. ([List of events](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSourceEvent))
61+
- `fn`: Callback function called when the event is triggered.
62+
- `deps`: Retriggers the binding of the event when the dependencies change.
63+
64+
ex: `useXRInputSourceEvent('all', "selectstart", (event) => console.log(event))`
5865

5966
### `useXRInputSourceStateContext`
6067

docs/tutorials/gamepad.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ description: How to use the XRControllers gamepad?
44
nav: 13
55
---
66

7-
All XR controllers are part of the state inside the xr store. The existing controllers can be read using the `useXR` hook. Alternatively, a specific xr controller can be retrived using `useXRController("left")`.
7+
All XR controllers are part of the state inside the xr store. The existing controllers can be read using the `useXR` hook. Alternatively, a specific xr controller can be retrived using `useXRInputSourceState("controller", "left")`.
88

99
The xr controller state contains the gamepad state. Based on the name of one specific component, its state can be polled every frame. The following example shows how to read the thumbstick of the right controller to implement locomotion in combination with the `XROrigin`.
1010

11-
To keep the code snipped focussed on the gamepad API, the locomotion does not happen relative to the users head rotation. This can be added by retrieving the users head position from reading the camera world quaternion and extracting the users rotation on the y axis.
11+
To keep the code snipped focussed on the gamepad API, the locomotion does not happen relative to the users head rotation. This can be added by retrieving the users head position from reading the camera world quaternion and extracting the users rotation on the y axis. (There is also a [useXRControllerLocomotion](../getting-started/all-hooks.md#usexrcontrollerlocomotion) hook available to help avoid implementing locomotion from scratch if that is the end goal).
1212

1313
```tsx
1414
const store = createXRStore()

packages/react/xr/src/input.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ export function useXRInputSourceStateContext<T extends keyof XRInputSourceStateM
4848
}
4949

5050
/**
51-
* hook for listening to xr input source events
51+
* Hook for listening to xr input source events
52+
* @param inputSource The input source to listen to, or 'all' to listen to all input sources
53+
* @param event The event to listen to. ([List of events](https://developer.mozilla.org/en-US/docs/Web/API/XRInputSourceEvent))
54+
* @param fn Callback function called when the event is triggered.
55+
* @param deps Retriggers the binding of the event when the dependencies change.
5256
*/
5357
export function useXRInputSourceEvent(
5458
inputSource: XRInputSource | 'all' | undefined,

0 commit comments

Comments
 (0)