Repository navigation
Commit 024378d
Input: gamepad haptics, an active-pad answer, and a trim of dead mappings (#1738)
Adds `vibrateGamepad`, `stopGamepadVibration` and `hasGamepadVibration`,
built so game code never branches on support: an empty slot, a pad without
motors and a browser with no Gamepad API all resolve false and do nothing.
Magnitudes default to full, because the web API defaults every parameter to
zero and a bare `playEffect` is a silent no-op.
Adds `activeGamepad()`, because the index a game should rumble is not
something the browser reports. Slots are plug order, so index 0 is a guess: a
wheel or a spare pad left plugged in can hold it for a whole session while the
player presses buttons on slot 1. It follows the last pad to produce a bound
input, carrying the pad's id alongside the index so a slot refilled by a
different device is not mistaken for the original.
Removes the OUYA and Firefox Xbox 360 remappings with their two normalizers.
A remapping is consulted only for a pad the browser does not report as
"standard". Both normalizers read `this.GAMEPAD`, while `normalize_fn` is
invoked off the mapping object, so they would have thrown on the hardware they
were written for.
`unbindGamepad` takes the table the binding is in and deletes it rather than
blanking it. An axis could not be unbound at all before, since the call only
reached the button table and the two code sets collide at 0; a blanked entry
also stayed in the poll with no keycode.
Corrects the axis `threshold` documentation: it is ADDED to the deadzone
rather than used instead of it, so the documented 0.5 does not fire until 0.6
of full travel. Behaviour unchanged.
27 tests, the first for this module. Every behaviour claimed above is
mutation-tested.
Claude-Session: https://claude.ai/code/session_01NGvtaUNATVCVxD2qcbiY4t
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent db9352a commit 024378d
4 files changed
Lines changed: 869 additions & 86 deletions
File tree
- packages/melonjs
- skills/melonjs-input
- src/input
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
28 | 36 | | |
29 | 37 | | |
30 | 38 | | |
31 | 39 | | |
| 40 | + | |
32 | 41 | | |
33 | 42 | | |
34 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | | - | |
202 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
203 | 217 | | |
204 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 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 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
205 | 274 | | |
206 | 275 | | |
207 | 276 | | |
| |||
224 | 293 | | |
225 | 294 | | |
226 | 295 | | |
| 296 | + | |
| 297 | + | |
227 | 298 | | |
228 | 299 | | |
229 | 300 | | |
| |||
0 commit comments