Skip to content

Commit 6b28b8e

Browse files
committed
Updated documentation.
1 parent 82c56b5 commit 6b28b8e

2 files changed

Lines changed: 86 additions & 3 deletions

File tree

documentation/learn/engine/INPUTMANAGER.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ Get the pointer lock status.
2424

2525
An array of valid event listener types.
2626

27+
### `rawGamepads`
28+
29+
Get the raw `navigator.getGamepads()` data.
30+
31+
### `gamepads`
32+
33+
Get easy-to-use gamepad data, in the form of [`GamepadInterface` instances](#gamepadinterface).
34+
2735
---
2836

2937
## Methods
@@ -58,3 +66,78 @@ Remove a listener for clicks on a `GameObject`.
5866

5967
- `gameObjectId` — `string` The ID of the `GameObject`.
6068
- `listener` — `function` The event listener function that was added to the event listener.
69+
70+
---
71+
72+
## GamepadInterface
73+
74+
Normalizes inputs for various game controllers, providing a unified interface for interacting with them.
75+
76+
Automatically generated by `InputManager` instances when gamepads are connected to device.
77+
78+
---
79+
80+
### Properties
81+
82+
#### normalized
83+
84+
Get the inputs in a normalized format to allow identical input layouts across different controllers.
85+
86+
Return format:
87+
`{ axes, buttons }`
88+
89+
#### asXB
90+
91+
Get the inputs from an XB controller.
92+
93+
Return format:
94+
`{ axes, buttons }`
95+
96+
#### asPS
97+
98+
Get the inputs from a PS controller.
99+
100+
Return format:
101+
`{ axes, buttons }`
102+
103+
#### asNS
104+
105+
Get the inputs from an NS Pro controller.
106+
107+
Return format:
108+
`{ axes, buttons }`
109+
110+
#### axes
111+
112+
Get the controller axes (normalized to two analog sticks).
113+
114+
#### buttons
115+
116+
Get the controller buttons (normalized to a standard "XB" layout: [A/B/X/Y, d-pad, triggers/bumpers]).
117+
118+
#### raw
119+
120+
The raw gamepad data from the `InputManager`.
121+
122+
Return format:
123+
`[Gamepad, Gamepad, null, null]`
124+
125+
#### mapping
126+
127+
Get the mapping type of the gamepad.
128+
129+
#### id
130+
131+
The ID of the gamepad.
132+
133+
#### vibrationActuator
134+
135+
Access the vibration actuator of the gamepad, if available.
136+
137+
#### hapticActuators
138+
139+
Access the haptic actuators of the gamepad, if available.
140+
141+
#### hand
142+
143+
Get which hand the gamepad is associated with, if applicable.

engine/InputManager.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class GamepadInterface {
146146
if (!this.raw) return undefined;
147147

148148
const {
149-
raw: { axes, buttons, mapping },
149+
raw: { axes, buttons },
150150
} = this;
151151

152152
return {
@@ -180,7 +180,7 @@ class GamepadInterface {
180180
if (!this.raw) return undefined;
181181

182182
const {
183-
raw: { axes, buttons, mapping },
183+
raw: { axes, buttons },
184184
} = this;
185185

186186
return {
@@ -214,7 +214,7 @@ class GamepadInterface {
214214
if (!this.raw) return undefined;
215215

216216
const {
217-
raw: { axes, buttons, mapping },
217+
raw: { axes, buttons },
218218
} = this;
219219

220220
return {

0 commit comments

Comments
 (0)