dualsense-ts 2.2.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +9 -2
  2. package/dist/comparators.d.ts +13 -0
  3. package/dist/comparators.d.ts.map +1 -0
  4. package/dist/comparators.js +27 -0
  5. package/dist/comparators.js.map +1 -0
  6. package/dist/dualsense.d.ts +10 -1
  7. package/dist/dualsense.d.ts.map +1 -1
  8. package/dist/dualsense.js +46 -45
  9. package/dist/dualsense.js.map +1 -1
  10. package/dist/elements/analog.d.ts +1 -1
  11. package/dist/elements/analog.d.ts.map +1 -1
  12. package/dist/elements/analog.js +13 -3
  13. package/dist/elements/analog.js.map +1 -1
  14. package/dist/elements/dpad.d.ts +1 -1
  15. package/dist/elements/dpad.d.ts.map +1 -1
  16. package/dist/elements/dpad.js +6 -5
  17. package/dist/elements/dpad.js.map +1 -1
  18. package/dist/elements/touch.d.ts +1 -1
  19. package/dist/elements/touch.d.ts.map +1 -1
  20. package/dist/elements/touch.js.map +1 -1
  21. package/dist/elements/touchpad.d.ts +1 -1
  22. package/dist/elements/touchpad.d.ts.map +1 -1
  23. package/dist/elements/touchpad.js.map +1 -1
  24. package/dist/elements/trigger.d.ts.map +1 -1
  25. package/dist/elements/trigger.js +1 -1
  26. package/dist/elements/trigger.js.map +1 -1
  27. package/dist/elements/unisense.d.ts +1 -1
  28. package/dist/elements/unisense.d.ts.map +1 -1
  29. package/dist/elements/unisense.js +12 -5
  30. package/dist/elements/unisense.js.map +1 -1
  31. package/dist/hid/dualsense_hid.d.ts +16 -58
  32. package/dist/hid/dualsense_hid.d.ts.map +1 -1
  33. package/dist/hid/dualsense_hid.js +25 -101
  34. package/dist/hid/dualsense_hid.js.map +1 -1
  35. package/dist/hid/hid_provider.d.ts +86 -0
  36. package/dist/hid/hid_provider.d.ts.map +1 -0
  37. package/dist/hid/hid_provider.js +45 -0
  38. package/dist/hid/hid_provider.js.map +1 -0
  39. package/dist/hid/index.d.ts +4 -1
  40. package/dist/hid/index.d.ts.map +1 -1
  41. package/dist/hid/index.js +4 -1
  42. package/dist/hid/index.js.map +1 -1
  43. package/dist/hid/node_hid_provider.d.ts +11 -0
  44. package/dist/hid/node_hid_provider.d.ts.map +1 -0
  45. package/dist/hid/node_hid_provider.js +97 -0
  46. package/dist/hid/node_hid_provider.js.map +1 -0
  47. package/dist/hid/platform_hid_provider.d.ts +4 -0
  48. package/dist/hid/platform_hid_provider.d.ts.map +1 -0
  49. package/dist/hid/platform_hid_provider.js +7 -0
  50. package/dist/hid/platform_hid_provider.js.map +1 -0
  51. package/dist/hid/web_hid_provider.d.ts +10 -0
  52. package/dist/hid/web_hid_provider.d.ts.map +1 -0
  53. package/dist/hid/web_hid_provider.js +102 -0
  54. package/dist/hid/web_hid_provider.js.map +1 -0
  55. package/dist/{hid/ids.d.ts → id.d.ts} +6 -2
  56. package/dist/id.d.ts.map +1 -0
  57. package/dist/{hid/ids.js → id.js} +1 -1
  58. package/dist/id.js.map +1 -0
  59. package/dist/index.d.ts +2 -0
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +2 -0
  62. package/dist/index.js.map +1 -1
  63. package/dist/input.d.ts +81 -36
  64. package/dist/input.d.ts.map +1 -1
  65. package/dist/input.js +128 -89
  66. package/dist/input.js.map +1 -1
  67. package/docs/Analog.md +81 -131
  68. package/docs/AnalogParams.md +7 -9
  69. package/docs/Axis.md +72 -79
  70. package/docs/Brightness.md +8 -8
  71. package/docs/CommandScopeA.md +16 -16
  72. package/docs/CommandScopeB.md +14 -14
  73. package/docs/Dpad.md +74 -81
  74. package/docs/DpadParams.md +8 -8
  75. package/docs/DualSenseCommand.md +45 -45
  76. package/docs/Dualsense.md +83 -90
  77. package/docs/DualsenseHID.md +47 -42
  78. package/docs/DualsenseHIDState.md +41 -41
  79. package/docs/DualsenseParams.md +17 -17
  80. package/docs/Exports.md +18 -21
  81. package/docs/Haptic.md +1 -1
  82. package/docs/Home.md +29 -31
  83. package/docs/Indicator.md +2 -2
  84. package/docs/Input.md +70 -79
  85. package/docs/InputId.md +84 -84
  86. package/docs/InputParams.md +4 -4
  87. package/docs/LedOptions.md +10 -10
  88. package/docs/Momentary.md +70 -77
  89. package/docs/Motion.md +2 -2
  90. package/docs/Mute.md +71 -89
  91. package/docs/PlayerID.md +12 -12
  92. package/docs/PulseOptions.md +8 -8
  93. package/docs/Touchpad.md +120 -94
  94. package/docs/Trigger.md +75 -82
  95. package/docs/TriggerMode.md +22 -22
  96. package/docs/Unisense.md +74 -81
  97. package/docs/UnisenseParams.md +7 -7
  98. package/package.json +16 -10
  99. package/src/comparators.ts +26 -0
  100. package/src/dualsense.ts +61 -58
  101. package/src/elements/analog.spec.ts +17 -0
  102. package/src/elements/analog.ts +14 -8
  103. package/src/elements/axis.spec.ts +31 -0
  104. package/src/elements/dpad.ts +7 -6
  105. package/src/elements/touch.ts +1 -1
  106. package/src/elements/touchpad.ts +1 -1
  107. package/src/elements/trigger.ts +1 -1
  108. package/src/elements/unisense.ts +16 -15
  109. package/src/hid/dualsense_hid.ts +25 -156
  110. package/src/hid/{dualsense_hid.spec.ts → hid_provider.spec.ts} +1 -1
  111. package/src/hid/hid_provider.ts +100 -0
  112. package/src/hid/index.ts +4 -1
  113. package/src/hid/node_hid_provider.ts +108 -0
  114. package/src/hid/platform_hid_provider.ts +4 -0
  115. package/src/hid/web_hid_provider.ts +116 -0
  116. package/src/{hid/ids.ts → id.ts} +6 -1
  117. package/src/index.ts +2 -0
  118. package/src/input.ts +178 -142
  119. package/src/readme.spec.ts +6 -8
  120. package/webpack.config.js +42 -0
  121. package/dist/hid/ids.d.ts.map +0 -1
  122. package/dist/hid/ids.js.map +0 -1
  123. package/docs/Increment.md +0 -1554
  124. package/docs/Touch.md +0 -1824
package/docs/Touch.md DELETED
@@ -1,1824 +0,0 @@
1
- # Class: Touch
2
-
3
- Represents a touchpad touch, treated like an analog joystick input
4
- with [0,0] representing the center of the touchpad.
5
-
6
- ## Hierarchy
7
-
8
- - [`Analog`](../wiki/Analog)
9
-
10
- ↳ **`Touch`**
11
-
12
- ## Table of contents
13
-
14
- ### Constructors
15
-
16
- - [constructor](../wiki/Touch#constructor)
17
-
18
- ### Properties
19
-
20
- - [[InputChanged]](../wiki/Touch#%5Binputchanged%5D)
21
- - [[InputChildless]](../wiki/Touch#%5Binputchildless%5D)
22
- - [[InputIcon]](../wiki/Touch#%5Binputicon%5D)
23
- - [[InputName]](../wiki/Touch#%5Binputname%5D)
24
- - [[InputParent]](../wiki/Touch#%5Binputparent%5D)
25
- - [button](../wiki/Touch#button)
26
- - [contact](../wiki/Touch#contact)
27
- - [id](../wiki/Touch#id)
28
- - [lastChange](../wiki/Touch#lastchange)
29
- - [lastInput](../wiki/Touch#lastinput)
30
- - [state](../wiki/Touch#state)
31
- - [threshold](../wiki/Touch#threshold)
32
- - [tracker](../wiki/Touch#tracker)
33
- - [x](../wiki/Touch#x)
34
- - [y](../wiki/Touch#y)
35
- - [captureRejectionSymbol](../wiki/Touch#capturerejectionsymbol)
36
- - [captureRejections](../wiki/Touch#capturerejections)
37
- - [defaultMaxListeners](../wiki/Touch#defaultmaxlisteners)
38
- - [errorMonitor](../wiki/Touch#errormonitor)
39
-
40
- ### Accessors
41
-
42
- - [[toStringTag]](../wiki/Touch#%5Btostringtag%5D)
43
- - [active](../wiki/Touch#active)
44
- - [angle](../wiki/Touch#angle)
45
- - [angleDegrees](../wiki/Touch#angledegrees)
46
- - [degrees](../wiki/Touch#degrees)
47
- - [direction](../wiki/Touch#direction)
48
- - [directionDegrees](../wiki/Touch#directiondegrees)
49
- - [force](../wiki/Touch#force)
50
- - [magnitude](../wiki/Touch#magnitude)
51
- - [radians](../wiki/Touch#radians)
52
- - [vector](../wiki/Touch#vector)
53
-
54
- ### Methods
55
-
56
- - [[InputAdopt]](../wiki/Touch#%5Binputadopt%5D)
57
- - [[InputChangedPrimitive]](../wiki/Touch#%5Binputchangedprimitive%5D)
58
- - [[InputChangedThreshold]](../wiki/Touch#%5Binputchangedthreshold%5D)
59
- - [[InputChangedVirtual]](../wiki/Touch#%5Binputchangedvirtual%5D)
60
- - [[InputSetComparison]](../wiki/Touch#%5Binputsetcomparison%5D)
61
- - [[InputSet]](../wiki/Touch#%5Binputset%5D)
62
- - [[asyncIterator]](../wiki/Touch#%5Basynciterator%5D)
63
- - [[custom]](../wiki/Touch#%5Bcustom%5D)
64
- - [[toPrimitive]](../wiki/Touch#%5Btoprimitive%5D)
65
- - [addListener](../wiki/Touch#addlistener)
66
- - [emit](../wiki/Touch#emit)
67
- - [eventNames](../wiki/Touch#eventnames)
68
- - [getMaxListeners](../wiki/Touch#getmaxlisteners)
69
- - [listenerCount](../wiki/Touch#listenercount)
70
- - [listeners](../wiki/Touch#listeners)
71
- - [next](../wiki/Touch#next)
72
- - [off](../wiki/Touch#off)
73
- - [on](../wiki/Touch#on)
74
- - [once](../wiki/Touch#once)
75
- - [prependListener](../wiki/Touch#prependlistener)
76
- - [prependOnceListener](../wiki/Touch#prependoncelistener)
77
- - [promise](../wiki/Touch#promise)
78
- - [rawListeners](../wiki/Touch#rawlisteners)
79
- - [removeAllListeners](../wiki/Touch#removealllisteners)
80
- - [removeListener](../wiki/Touch#removelistener)
81
- - [setMaxListeners](../wiki/Touch#setmaxlisteners)
82
- - [toString](../wiki/Touch#tostring)
83
- - [getEventListeners](../wiki/Touch#geteventlisteners)
84
- - [listenerCount](../wiki/Touch#listenercount-1)
85
- - [on](../wiki/Touch#on-1)
86
- - [once](../wiki/Touch#once-1)
87
- - [setMaxListeners](../wiki/Touch#setmaxlisteners-1)
88
-
89
- ## Constructors
90
-
91
- ### constructor
92
-
93
- • **new Touch**(`params?`)
94
-
95
- #### Parameters
96
-
97
- | Name | Type |
98
- | :------ | :------ |
99
- | `params?` | [`AnalogParams`](../wiki/AnalogParams) |
100
-
101
- #### Inherited from
102
-
103
- [Analog](../wiki/Analog).[constructor](../wiki/Analog#constructor)
104
-
105
- #### Defined in
106
-
107
- [src/elements/analog.ts:40](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/analog.ts#L40)
108
-
109
- ## Properties
110
-
111
- ### [InputChanged]
112
-
113
- • **[InputChanged]**: (`state`: [`Analog`](../wiki/Analog), `newState`: [`Analog`](../wiki/Analog)) => `boolean`
114
-
115
- #### Type declaration
116
-
117
- ▸ (`state`, `newState`): `boolean`
118
-
119
- ##### Parameters
120
-
121
- | Name | Type |
122
- | :------ | :------ |
123
- | `state` | [`Analog`](../wiki/Analog) |
124
- | `newState` | [`Analog`](../wiki/Analog) |
125
-
126
- ##### Returns
127
-
128
- `boolean`
129
-
130
- #### Inherited from
131
-
132
- [Analog](../wiki/Analog).[[InputChanged]](../wiki/Analog#%5Binputchanged%5D)
133
-
134
- #### Defined in
135
-
136
- [src/input.ts:128](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L128)
137
-
138
- ___
139
-
140
- ### [InputChildless]
141
-
142
- • **[InputChildless]**: `boolean` = `true`
143
-
144
- #### Inherited from
145
-
146
- [Analog](../wiki/Analog).[[InputChildless]](../wiki/Analog#%5Binputchildless%5D)
147
-
148
- #### Defined in
149
-
150
- [src/input.ts:162](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L162)
151
-
152
- ___
153
-
154
- ### [InputIcon]
155
-
156
- • `Readonly` **[InputIcon]**: `string`
157
-
158
- #### Inherited from
159
-
160
- [Analog](../wiki/Analog).[[InputIcon]](../wiki/Analog#%5Binputicon%5D)
161
-
162
- #### Defined in
163
-
164
- [src/input.ts:157](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L157)
165
-
166
- ___
167
-
168
- ### [InputName]
169
-
170
- • `Readonly` **[InputName]**: `string`
171
-
172
- #### Inherited from
173
-
174
- [Analog](../wiki/Analog).[[InputName]](../wiki/Analog#%5Binputname%5D)
175
-
176
- #### Defined in
177
-
178
- [src/input.ts:154](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L154)
179
-
180
- ___
181
-
182
- ### [InputParent]
183
-
184
- • `Optional` **[InputParent]**: [`Input`](../wiki/Input)<`unknown`\>
185
-
186
- #### Inherited from
187
-
188
- [Analog](../wiki/Analog).[[InputParent]](../wiki/Analog#%5Binputparent%5D)
189
-
190
- #### Defined in
191
-
192
- [src/input.ts:160](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L160)
193
-
194
- ___
195
-
196
- ### button
197
-
198
- • `Readonly` **button**: [`Momentary`](../wiki/Momentary)
199
-
200
- Button triggered by pressing the stick.
201
-
202
- #### Inherited from
203
-
204
- [Analog](../wiki/Analog).[button](../wiki/Analog#button)
205
-
206
- #### Defined in
207
-
208
- [src/elements/analog.ts:38](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/analog.ts#L38)
209
-
210
- ___
211
-
212
- ### contact
213
-
214
- • `Readonly` **contact**: [`Momentary`](../wiki/Momentary)
215
-
216
- #### Defined in
217
-
218
- [src/elements/touch.ts:10](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/touch.ts#L10)
219
-
220
- ___
221
-
222
- ### id
223
-
224
- • `Readonly` **id**: `symbol`
225
-
226
- #### Inherited from
227
-
228
- [Analog](../wiki/Analog).[id](../wiki/Analog#id)
229
-
230
- #### Defined in
231
-
232
- [src/input.ts:58](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L58)
233
-
234
- ___
235
-
236
- ### lastChange
237
-
238
- • **lastChange**: `number`
239
-
240
- #### Inherited from
241
-
242
- [Analog](../wiki/Analog).[lastChange](../wiki/Analog#lastchange)
243
-
244
- #### Defined in
245
-
246
- [src/input.ts:61](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L61)
247
-
248
- ___
249
-
250
- ### lastInput
251
-
252
- • **lastInput**: `number`
253
-
254
- #### Inherited from
255
-
256
- [Analog](../wiki/Analog).[lastInput](../wiki/Analog#lastinput)
257
-
258
- #### Defined in
259
-
260
- [src/input.ts:64](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L64)
261
-
262
- ___
263
-
264
- ### state
265
-
266
- • `Readonly` **state**: [`Touch`](../wiki/Touch)
267
-
268
- #### Overrides
269
-
270
- [Analog](../wiki/Analog).[state](../wiki/Analog#state)
271
-
272
- #### Defined in
273
-
274
- [src/elements/touch.ts:9](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/touch.ts#L9)
275
-
276
- ___
277
-
278
- ### threshold
279
-
280
- • **threshold**: `number` = `0`
281
-
282
- #### Inherited from
283
-
284
- [Analog](../wiki/Analog).[threshold](../wiki/Analog#threshold)
285
-
286
- #### Defined in
287
-
288
- [src/input.ts:67](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L67)
289
-
290
- ___
291
-
292
- ### tracker
293
-
294
- • `Readonly` **tracker**: [`Increment`](../wiki/Increment)
295
-
296
- #### Defined in
297
-
298
- [src/elements/touch.ts:11](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/touch.ts#L11)
299
-
300
- ___
301
-
302
- ### x
303
-
304
- • `Readonly` **x**: [`Axis`](../wiki/Axis)
305
-
306
- The left/right position of the input.
307
-
308
- #### Inherited from
309
-
310
- [Analog](../wiki/Analog).[x](../wiki/Analog#x)
311
-
312
- #### Defined in
313
-
314
- [src/elements/analog.ts:30](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/analog.ts#L30)
315
-
316
- ___
317
-
318
- ### y
319
-
320
- • `Readonly` **y**: [`Axis`](../wiki/Axis)
321
-
322
- The up/down position of the input.
323
-
324
- #### Inherited from
325
-
326
- [Analog](../wiki/Analog).[y](../wiki/Analog#y)
327
-
328
- #### Defined in
329
-
330
- [src/elements/analog.ts:34](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/analog.ts#L34)
331
-
332
- ___
333
-
334
- ### captureRejectionSymbol
335
-
336
- ▪ `Static` `Readonly` **captureRejectionSymbol**: typeof [`captureRejectionSymbol`](../wiki/Dualsense#capturerejectionsymbol)
337
-
338
- #### Inherited from
339
-
340
- [Analog](../wiki/Analog).[captureRejectionSymbol](../wiki/Analog#capturerejectionsymbol)
341
-
342
- #### Defined in
343
-
344
- node_modules/@types/node/events.d.ts:291
345
-
346
- ___
347
-
348
- ### captureRejections
349
-
350
- ▪ `Static` **captureRejections**: `boolean`
351
-
352
- Sets or gets the default captureRejection value for all emitters.
353
-
354
- #### Inherited from
355
-
356
- [Analog](../wiki/Analog).[captureRejections](../wiki/Analog#capturerejections)
357
-
358
- #### Defined in
359
-
360
- node_modules/@types/node/events.d.ts:296
361
-
362
- ___
363
-
364
- ### defaultMaxListeners
365
-
366
- ▪ `Static` **defaultMaxListeners**: `number`
367
-
368
- #### Inherited from
369
-
370
- [Analog](../wiki/Analog).[defaultMaxListeners](../wiki/Analog#defaultmaxlisteners)
371
-
372
- #### Defined in
373
-
374
- node_modules/@types/node/events.d.ts:297
375
-
376
- ___
377
-
378
- ### errorMonitor
379
-
380
- ▪ `Static` `Readonly` **errorMonitor**: typeof [`errorMonitor`](../wiki/Dualsense#errormonitor)
381
-
382
- This symbol shall be used to install a listener for only monitoring `'error'`
383
- events. Listeners installed using this symbol are called before the regular
384
- `'error'` listeners are called.
385
-
386
- Installing a listener using this symbol does not change the behavior once an
387
- `'error'` event is emitted, therefore the process will still crash if no
388
- regular `'error'` listener is installed.
389
-
390
- #### Inherited from
391
-
392
- [Analog](../wiki/Analog).[errorMonitor](../wiki/Analog#errormonitor)
393
-
394
- #### Defined in
395
-
396
- node_modules/@types/node/events.d.ts:290
397
-
398
- ## Accessors
399
-
400
- ### [toStringTag]
401
-
402
- • `get` **[toStringTag]**(): `string`
403
-
404
- #### Returns
405
-
406
- `string`
407
-
408
- #### Inherited from
409
-
410
- Analog.\_\_@toStringTag@66
411
-
412
- #### Defined in
413
-
414
- [src/input.ts:149](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L149)
415
-
416
- ___
417
-
418
- ### active
419
-
420
- • `get` **active**(): `boolean`
421
-
422
- #### Returns
423
-
424
- `boolean`
425
-
426
- #### Overrides
427
-
428
- Analog.active
429
-
430
- #### Defined in
431
-
432
- [src/elements/touch.ts:13](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/touch.ts#L13)
433
-
434
- ___
435
-
436
- ### angle
437
-
438
- • `get` **angle**(): `number`
439
-
440
- Alias for `.direction`
441
-
442
- #### Returns
443
-
444
- `number`
445
-
446
- #### Inherited from
447
-
448
- Analog.angle
449
-
450
- #### Defined in
451
-
452
- [src/elements/analog.ts:100](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/analog.ts#L100)
453
-
454
- ___
455
-
456
- ### angleDegrees
457
-
458
- • `get` **angleDegrees**(): `number`
459
-
460
- Alias for `.directionDegrees`.
461
-
462
- #### Returns
463
-
464
- `number`
465
-
466
- #### Inherited from
467
-
468
- Analog.angleDegrees
469
-
470
- #### Defined in
471
-
472
- [src/elements/analog.ts:121](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/analog.ts#L121)
473
-
474
- ___
475
-
476
- ### degrees
477
-
478
- • `get` **degrees**(): `number`
479
-
480
- Alias for `.directionDegrees`.
481
-
482
- #### Returns
483
-
484
- `number`
485
-
486
- #### Inherited from
487
-
488
- Analog.degrees
489
-
490
- #### Defined in
491
-
492
- [src/elements/analog.ts:114](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/analog.ts#L114)
493
-
494
- ___
495
-
496
- ### direction
497
-
498
- • `get` **direction**(): `number`
499
-
500
- Returns the stick's angle in radians.
501
-
502
- #### Returns
503
-
504
- `number`
505
-
506
- #### Inherited from
507
-
508
- Analog.direction
509
-
510
- #### Defined in
511
-
512
- [src/elements/analog.ts:86](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/analog.ts#L86)
513
-
514
- ___
515
-
516
- ### directionDegrees
517
-
518
- • `get` **directionDegrees**(): `number`
519
-
520
- Alias for `.direction` converted to degrees.
521
-
522
- #### Returns
523
-
524
- `number`
525
-
526
- #### Inherited from
527
-
528
- Analog.directionDegrees
529
-
530
- #### Defined in
531
-
532
- [src/elements/analog.ts:107](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/analog.ts#L107)
533
-
534
- ___
535
-
536
- ### force
537
-
538
- • `get` **force**(): `number`
539
-
540
- Returns an force from the stick's position.
541
-
542
- #### Returns
543
-
544
- `number`
545
-
546
- #### Inherited from
547
-
548
- Analog.force
549
-
550
- #### Defined in
551
-
552
- [src/elements/analog.ts:70](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/analog.ts#L70)
553
-
554
- ___
555
-
556
- ### magnitude
557
-
558
- • `get` **magnitude**(): `number`
559
-
560
- Returns a magnitude from the stick's position.
561
-
562
- #### Returns
563
-
564
- `number`
565
-
566
- #### Inherited from
567
-
568
- Analog.magnitude
569
-
570
- #### Defined in
571
-
572
- [src/elements/analog.ts:79](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/analog.ts#L79)
573
-
574
- ___
575
-
576
- ### radians
577
-
578
- • `get` **radians**(): `number`
579
-
580
- Alias for `.direction`
581
-
582
- #### Returns
583
-
584
- `number`
585
-
586
- #### Inherited from
587
-
588
- Analog.radians
589
-
590
- #### Defined in
591
-
592
- [src/elements/analog.ts:93](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/analog.ts#L93)
593
-
594
- ___
595
-
596
- ### vector
597
-
598
- • `get` **vector**(): `Object`
599
-
600
- Returns a direction and magnitude representing the stick's position.
601
-
602
- #### Returns
603
-
604
- `Object`
605
-
606
- | Name | Type |
607
- | :------ | :------ |
608
- | `direction` | `number` |
609
- | `magnitude` | `number` |
610
-
611
- #### Inherited from
612
-
613
- Analog.vector
614
-
615
- #### Defined in
616
-
617
- [src/elements/analog.ts:63](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/analog.ts#L63)
618
-
619
- ## Methods
620
-
621
- ### [InputAdopt]
622
-
623
- ▸ **[InputAdopt]**(): `void`
624
-
625
- Cascade events from nested Inputs.
626
- And decide if this is the root Input.
627
-
628
- #### Returns
629
-
630
- `void`
631
-
632
- #### Inherited from
633
-
634
- [Analog](../wiki/Analog).[[InputAdopt]](../wiki/Analog#%5Binputadopt%5D)
635
-
636
- #### Defined in
637
-
638
- [src/input.ts:168](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L168)
639
-
640
- ___
641
-
642
- ### [InputChangedPrimitive]
643
-
644
- ▸ **[InputChangedPrimitive]**(`state`, `newState`): `boolean`
645
-
646
- #### Parameters
647
-
648
- | Name | Type |
649
- | :------ | :------ |
650
- | `state` | [`Analog`](../wiki/Analog) |
651
- | `newState` | [`Analog`](../wiki/Analog) |
652
-
653
- #### Returns
654
-
655
- `boolean`
656
-
657
- #### Inherited from
658
-
659
- [Analog](../wiki/Analog).[[InputChangedPrimitive]](../wiki/Analog#%5Binputchangedprimitive%5D)
660
-
661
- #### Defined in
662
-
663
- [src/input.ts:190](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L190)
664
-
665
- ___
666
-
667
- ### [InputChangedThreshold]
668
-
669
- ▸ **[InputChangedThreshold]**(`state`, `newState`): `boolean`
670
-
671
- #### Parameters
672
-
673
- | Name | Type |
674
- | :------ | :------ |
675
- | `state` | `number` |
676
- | `newState` | `number` |
677
-
678
- #### Returns
679
-
680
- `boolean`
681
-
682
- #### Inherited from
683
-
684
- [Analog](../wiki/Analog).[[InputChangedThreshold]](../wiki/Analog#%5Binputchangedthreshold%5D)
685
-
686
- #### Defined in
687
-
688
- [src/input.ts:194](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L194)
689
-
690
- ___
691
-
692
- ### [InputChangedVirtual]
693
-
694
- ▸ **[InputChangedVirtual]**(): `boolean`
695
-
696
- #### Returns
697
-
698
- `boolean`
699
-
700
- #### Inherited from
701
-
702
- [Analog](../wiki/Analog).[[InputChangedVirtual]](../wiki/Analog#%5Binputchangedvirtual%5D)
703
-
704
- #### Defined in
705
-
706
- [src/input.ts:186](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L186)
707
-
708
- ___
709
-
710
- ### [InputSetComparison]
711
-
712
- ▸ **[InputSetComparison]**(): (`state`: [`Analog`](../wiki/Analog), `newState`: [`Analog`](../wiki/Analog)) => `boolean`
713
-
714
- #### Returns
715
-
716
- `fn`
717
-
718
- ▸ (`state`, `newState`): `boolean`
719
-
720
- ##### Parameters
721
-
722
- | Name | Type |
723
- | :------ | :------ |
724
- | `state` | [`Analog`](../wiki/Analog) |
725
- | `newState` | [`Analog`](../wiki/Analog) |
726
-
727
- ##### Returns
728
-
729
- `boolean`
730
-
731
- #### Inherited from
732
-
733
- [Analog](../wiki/Analog).[[InputSetComparison]](../wiki/Analog#%5Binputsetcomparison%5D)
734
-
735
- #### Defined in
736
-
737
- [src/input.ts:199](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L199)
738
-
739
- ___
740
-
741
- ### [InputSet]
742
-
743
- ▸ **[InputSet]**(`state`): `void`
744
-
745
- Update the input's state and trigger all necessary callbacks.
746
-
747
- #### Parameters
748
-
749
- | Name | Type |
750
- | :------ | :------ |
751
- | `state` | [`Analog`](../wiki/Analog) |
752
-
753
- #### Returns
754
-
755
- `void`
756
-
757
- #### Inherited from
758
-
759
- [Analog](../wiki/Analog).[[InputSet]](../wiki/Analog#%5Binputset%5D)
760
-
761
- #### Defined in
762
-
763
- [src/input.ts:215](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L215)
764
-
765
- ___
766
-
767
- ### [asyncIterator]
768
-
769
- ▸ **[asyncIterator]**(): `AsyncIterator`<[`Touch`](../wiki/Touch), `any`, `undefined`\>
770
-
771
- #### Returns
772
-
773
- `AsyncIterator`<[`Touch`](../wiki/Touch), `any`, `undefined`\>
774
-
775
- #### Inherited from
776
-
777
- [Analog](../wiki/Analog).[[asyncIterator]](../wiki/Analog#%5Basynciterator%5D)
778
-
779
- #### Defined in
780
-
781
- [src/input.ts:139](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L139)
782
-
783
- ___
784
-
785
- ### [custom]
786
-
787
- ▸ **[custom]**(): `string`
788
-
789
- #### Returns
790
-
791
- `string`
792
-
793
- #### Inherited from
794
-
795
- [Analog](../wiki/Analog).[[custom]](../wiki/Analog#%5Bcustom%5D)
796
-
797
- #### Defined in
798
-
799
- [src/input.ts:131](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L131)
800
-
801
- ___
802
-
803
- ### [toPrimitive]
804
-
805
- ▸ **[toPrimitive]**(`hint`): `string` \| `number`
806
-
807
- #### Parameters
808
-
809
- | Name | Type |
810
- | :------ | :------ |
811
- | `hint` | ``"string"`` \| ``"number"`` \| ``"default"`` |
812
-
813
- #### Returns
814
-
815
- `string` \| `number`
816
-
817
- #### Inherited from
818
-
819
- [Analog](../wiki/Analog).[[toPrimitive]](../wiki/Analog#%5Btoprimitive%5D)
820
-
821
- #### Defined in
822
-
823
- [src/input.ts:143](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L143)
824
-
825
- ___
826
-
827
- ### addListener
828
-
829
- ▸ **addListener**(`eventName`, `listener`): [`Touch`](../wiki/Touch)
830
-
831
- Alias for `emitter.on(eventName, listener)`.
832
-
833
- **`since`** v0.1.26
834
-
835
- #### Parameters
836
-
837
- | Name | Type |
838
- | :------ | :------ |
839
- | `eventName` | `string` \| `symbol` |
840
- | `listener` | (...`args`: `any`[]) => `void` |
841
-
842
- #### Returns
843
-
844
- [`Touch`](../wiki/Touch)
845
-
846
- #### Inherited from
847
-
848
- [Analog](../wiki/Analog).[addListener](../wiki/Analog#addlistener)
849
-
850
- #### Defined in
851
-
852
- node_modules/@types/node/events.d.ts:317
853
-
854
- ___
855
-
856
- ### emit
857
-
858
- ▸ **emit**(`event`, ...`args`): `boolean`
859
-
860
- #### Parameters
861
-
862
- | Name | Type |
863
- | :------ | :------ |
864
- | `event` | [`InputEvent`](../wiki/Exports#inputevent) |
865
- | `...args` | [[`Input`](../wiki/Input)<[`Analog`](../wiki/Analog)\>, [`Input`](../wiki/Input)<`unknown`\> \| [`Input`](../wiki/Input)<[`Analog`](../wiki/Analog)\>] |
866
-
867
- #### Returns
868
-
869
- `boolean`
870
-
871
- #### Inherited from
872
-
873
- [Analog](../wiki/Analog).[emit](../wiki/Analog#emit)
874
-
875
- #### Defined in
876
-
877
- [src/input.ts:44](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L44)
878
-
879
- ___
880
-
881
- ### eventNames
882
-
883
- ▸ **eventNames**(): (`string` \| `symbol`)[]
884
-
885
- Returns an array listing the events for which the emitter has registered
886
- listeners. The values in the array are strings or `Symbol`s.
887
-
888
- ```js
889
- const EventEmitter = require('events');
890
- const myEE = new EventEmitter();
891
- myEE.on('foo', () => {});
892
- myEE.on('bar', () => {});
893
-
894
- const sym = Symbol('symbol');
895
- myEE.on(sym, () => {});
896
-
897
- console.log(myEE.eventNames());
898
- // Prints: [ 'foo', 'bar', Symbol(symbol) ]
899
- ```
900
-
901
- **`since`** v6.0.0
902
-
903
- #### Returns
904
-
905
- (`string` \| `symbol`)[]
906
-
907
- #### Inherited from
908
-
909
- [Analog](../wiki/Analog).[eventNames](../wiki/Analog#eventnames)
910
-
911
- #### Defined in
912
-
913
- node_modules/@types/node/events.d.ts:632
914
-
915
- ___
916
-
917
- ### getMaxListeners
918
-
919
- ▸ **getMaxListeners**(): `number`
920
-
921
- Returns the current max listener value for the `EventEmitter` which is either
922
- set by `emitter.setMaxListeners(n)` or defaults to [defaultMaxListeners](../wiki/Touch#defaultmaxlisteners).
923
-
924
- **`since`** v1.0.0
925
-
926
- #### Returns
927
-
928
- `number`
929
-
930
- #### Inherited from
931
-
932
- [Analog](../wiki/Analog).[getMaxListeners](../wiki/Analog#getmaxlisteners)
933
-
934
- #### Defined in
935
-
936
- node_modules/@types/node/events.d.ts:489
937
-
938
- ___
939
-
940
- ### listenerCount
941
-
942
- ▸ **listenerCount**(`eventName`): `number`
943
-
944
- Returns the number of listeners listening to the event named `eventName`.
945
-
946
- **`since`** v3.2.0
947
-
948
- #### Parameters
949
-
950
- | Name | Type | Description |
951
- | :------ | :------ | :------ |
952
- | `eventName` | `string` \| `symbol` | The name of the event being listened for |
953
-
954
- #### Returns
955
-
956
- `number`
957
-
958
- #### Inherited from
959
-
960
- [Analog](../wiki/Analog).[listenerCount](../wiki/Analog#listenercount)
961
-
962
- #### Defined in
963
-
964
- node_modules/@types/node/events.d.ts:579
965
-
966
- ___
967
-
968
- ### listeners
969
-
970
- ▸ **listeners**(`eventName`): `Function`[]
971
-
972
- Returns a copy of the array of listeners for the event named `eventName`.
973
-
974
- ```js
975
- server.on('connection', (stream) => {
976
- console.log('someone connected!');
977
- });
978
- console.log(util.inspect(server.listeners('connection')));
979
- // Prints: [ [Function] ]
980
- ```
981
-
982
- **`since`** v0.1.26
983
-
984
- #### Parameters
985
-
986
- | Name | Type |
987
- | :------ | :------ |
988
- | `eventName` | `string` \| `symbol` |
989
-
990
- #### Returns
991
-
992
- `Function`[]
993
-
994
- #### Inherited from
995
-
996
- [Analog](../wiki/Analog).[listeners](../wiki/Analog#listeners)
997
-
998
- #### Defined in
999
-
1000
- node_modules/@types/node/events.d.ts:502
1001
-
1002
- ___
1003
-
1004
- ### next
1005
-
1006
- ▸ **next**(`type?`): `Promise`<`IteratorResult`<[`Touch`](../wiki/Touch), `any`\>\>
1007
-
1008
- Resolves on the next change to this input's state.
1009
-
1010
- #### Parameters
1011
-
1012
- | Name | Type | Default value |
1013
- | :------ | :------ | :------ |
1014
- | `type` | ``"change"`` \| ``"press"`` \| ``"release"`` | `"change"` |
1015
-
1016
- #### Returns
1017
-
1018
- `Promise`<`IteratorResult`<[`Touch`](../wiki/Touch), `any`\>\>
1019
-
1020
- #### Inherited from
1021
-
1022
- [Analog](../wiki/Analog).[next](../wiki/Analog#next)
1023
-
1024
- #### Defined in
1025
-
1026
- [src/input.ts:78](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L78)
1027
-
1028
- ___
1029
-
1030
- ### off
1031
-
1032
- ▸ **off**(`eventName`, `listener`): [`Touch`](../wiki/Touch)
1033
-
1034
- Alias for `emitter.removeListener()`.
1035
-
1036
- **`since`** v10.0.0
1037
-
1038
- #### Parameters
1039
-
1040
- | Name | Type |
1041
- | :------ | :------ |
1042
- | `eventName` | `string` \| `symbol` |
1043
- | `listener` | (...`args`: `any`[]) => `void` |
1044
-
1045
- #### Returns
1046
-
1047
- [`Touch`](../wiki/Touch)
1048
-
1049
- #### Inherited from
1050
-
1051
- [Analog](../wiki/Analog).[off](../wiki/Analog#off)
1052
-
1053
- #### Defined in
1054
-
1055
- node_modules/@types/node/events.d.ts:462
1056
-
1057
- ___
1058
-
1059
- ### on
1060
-
1061
- ▸ **on**(`event`, `listener`): [`Touch`](../wiki/Touch)
1062
-
1063
- #### Parameters
1064
-
1065
- | Name | Type |
1066
- | :------ | :------ |
1067
- | `event` | [`InputEvent`](../wiki/Exports#inputevent) |
1068
- | `listener` | (`input`: [`Input`](../wiki/Input)<[`Analog`](../wiki/Analog)\>, `changed`: [`Input`](../wiki/Input)<`unknown`\>) => `unknown` |
1069
-
1070
- #### Returns
1071
-
1072
- [`Touch`](../wiki/Touch)
1073
-
1074
- #### Inherited from
1075
-
1076
- [Analog](../wiki/Analog).[on](../wiki/Analog#on)
1077
-
1078
- #### Defined in
1079
-
1080
- [src/input.ts:37](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L37)
1081
-
1082
- ___
1083
-
1084
- ### once
1085
-
1086
- ▸ **once**(`eventName`, `listener`): [`Touch`](../wiki/Touch)
1087
-
1088
- Adds a **one-time**`listener` function for the event named `eventName`. The
1089
- next time `eventName` is triggered, this listener is removed and then invoked.
1090
-
1091
- ```js
1092
- server.once('connection', (stream) => {
1093
- console.log('Ah, we have our first user!');
1094
- });
1095
- ```
1096
-
1097
- Returns a reference to the `EventEmitter`, so that calls can be chained.
1098
-
1099
- By default, event listeners are invoked in the order they are added. The`emitter.prependOnceListener()` method can be used as an alternative to add the
1100
- event listener to the beginning of the listeners array.
1101
-
1102
- ```js
1103
- const myEE = new EventEmitter();
1104
- myEE.once('foo', () => console.log('a'));
1105
- myEE.prependOnceListener('foo', () => console.log('b'));
1106
- myEE.emit('foo');
1107
- // Prints:
1108
- // b
1109
- // a
1110
- ```
1111
-
1112
- **`since`** v0.3.0
1113
-
1114
- #### Parameters
1115
-
1116
- | Name | Type | Description |
1117
- | :------ | :------ | :------ |
1118
- | `eventName` | `string` \| `symbol` | The name of the event. |
1119
- | `listener` | (...`args`: `any`[]) => `void` | The callback function |
1120
-
1121
- #### Returns
1122
-
1123
- [`Touch`](../wiki/Touch)
1124
-
1125
- #### Inherited from
1126
-
1127
- [Analog](../wiki/Analog).[once](../wiki/Analog#once)
1128
-
1129
- #### Defined in
1130
-
1131
- node_modules/@types/node/events.d.ts:377
1132
-
1133
- ___
1134
-
1135
- ### prependListener
1136
-
1137
- ▸ **prependListener**(`eventName`, `listener`): [`Touch`](../wiki/Touch)
1138
-
1139
- Adds the `listener` function to the _beginning_ of the listeners array for the
1140
- event named `eventName`. No checks are made to see if the `listener` has
1141
- already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
1142
- times.
1143
-
1144
- ```js
1145
- server.prependListener('connection', (stream) => {
1146
- console.log('someone connected!');
1147
- });
1148
- ```
1149
-
1150
- Returns a reference to the `EventEmitter`, so that calls can be chained.
1151
-
1152
- **`since`** v6.0.0
1153
-
1154
- #### Parameters
1155
-
1156
- | Name | Type | Description |
1157
- | :------ | :------ | :------ |
1158
- | `eventName` | `string` \| `symbol` | The name of the event. |
1159
- | `listener` | (...`args`: `any`[]) => `void` | The callback function |
1160
-
1161
- #### Returns
1162
-
1163
- [`Touch`](../wiki/Touch)
1164
-
1165
- #### Inherited from
1166
-
1167
- [Analog](../wiki/Analog).[prependListener](../wiki/Analog#prependlistener)
1168
-
1169
- #### Defined in
1170
-
1171
- node_modules/@types/node/events.d.ts:597
1172
-
1173
- ___
1174
-
1175
- ### prependOnceListener
1176
-
1177
- ▸ **prependOnceListener**(`eventName`, `listener`): [`Touch`](../wiki/Touch)
1178
-
1179
- Adds a **one-time**`listener` function for the event named `eventName` to the_beginning_ of the listeners array. The next time `eventName` is triggered, this
1180
- listener is removed, and then invoked.
1181
-
1182
- ```js
1183
- server.prependOnceListener('connection', (stream) => {
1184
- console.log('Ah, we have our first user!');
1185
- });
1186
- ```
1187
-
1188
- Returns a reference to the `EventEmitter`, so that calls can be chained.
1189
-
1190
- **`since`** v6.0.0
1191
-
1192
- #### Parameters
1193
-
1194
- | Name | Type | Description |
1195
- | :------ | :------ | :------ |
1196
- | `eventName` | `string` \| `symbol` | The name of the event. |
1197
- | `listener` | (...`args`: `any`[]) => `void` | The callback function |
1198
-
1199
- #### Returns
1200
-
1201
- [`Touch`](../wiki/Touch)
1202
-
1203
- #### Inherited from
1204
-
1205
- [Analog](../wiki/Analog).[prependOnceListener](../wiki/Analog#prependoncelistener)
1206
-
1207
- #### Defined in
1208
-
1209
- node_modules/@types/node/events.d.ts:613
1210
-
1211
- ___
1212
-
1213
- ### promise
1214
-
1215
- ▸ **promise**(`type?`): `Promise`<[`Touch`](../wiki/Touch)\>
1216
-
1217
- Resolves on the next change to this input's state.
1218
-
1219
- #### Parameters
1220
-
1221
- | Name | Type | Default value |
1222
- | :------ | :------ | :------ |
1223
- | `type` | ``"change"`` \| ``"press"`` \| ``"release"`` | `"change"` |
1224
-
1225
- #### Returns
1226
-
1227
- `Promise`<[`Touch`](../wiki/Touch)\>
1228
-
1229
- #### Inherited from
1230
-
1231
- [Analog](../wiki/Analog).[promise](../wiki/Analog#promise)
1232
-
1233
- #### Defined in
1234
-
1235
- [src/input.ts:91](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L91)
1236
-
1237
- ___
1238
-
1239
- ### rawListeners
1240
-
1241
- ▸ **rawListeners**(`eventName`): `Function`[]
1242
-
1243
- Returns a copy of the array of listeners for the event named `eventName`,
1244
- including any wrappers (such as those created by `.once()`).
1245
-
1246
- ```js
1247
- const emitter = new EventEmitter();
1248
- emitter.once('log', () => console.log('log once'));
1249
-
1250
- // Returns a new Array with a function `onceWrapper` which has a property
1251
- // `listener` which contains the original listener bound above
1252
- const listeners = emitter.rawListeners('log');
1253
- const logFnWrapper = listeners[0];
1254
-
1255
- // Logs "log once" to the console and does not unbind the `once` event
1256
- logFnWrapper.listener();
1257
-
1258
- // Logs "log once" to the console and removes the listener
1259
- logFnWrapper();
1260
-
1261
- emitter.on('log', () => console.log('log persistently'));
1262
- // Will return a new Array with a single function bound by `.on()` above
1263
- const newListeners = emitter.rawListeners('log');
1264
-
1265
- // Logs "log persistently" twice
1266
- newListeners[0]();
1267
- emitter.emit('log');
1268
- ```
1269
-
1270
- **`since`** v9.4.0
1271
-
1272
- #### Parameters
1273
-
1274
- | Name | Type |
1275
- | :------ | :------ |
1276
- | `eventName` | `string` \| `symbol` |
1277
-
1278
- #### Returns
1279
-
1280
- `Function`[]
1281
-
1282
- #### Inherited from
1283
-
1284
- [Analog](../wiki/Analog).[rawListeners](../wiki/Analog#rawlisteners)
1285
-
1286
- #### Defined in
1287
-
1288
- node_modules/@types/node/events.d.ts:532
1289
-
1290
- ___
1291
-
1292
- ### removeAllListeners
1293
-
1294
- ▸ **removeAllListeners**(`event?`): [`Touch`](../wiki/Touch)
1295
-
1296
- Removes all listeners, or those of the specified `eventName`.
1297
-
1298
- It is bad practice to remove listeners added elsewhere in the code,
1299
- particularly when the `EventEmitter` instance was created by some other
1300
- component or module (e.g. sockets or file streams).
1301
-
1302
- Returns a reference to the `EventEmitter`, so that calls can be chained.
1303
-
1304
- **`since`** v0.1.26
1305
-
1306
- #### Parameters
1307
-
1308
- | Name | Type |
1309
- | :------ | :------ |
1310
- | `event?` | `string` \| `symbol` |
1311
-
1312
- #### Returns
1313
-
1314
- [`Touch`](../wiki/Touch)
1315
-
1316
- #### Inherited from
1317
-
1318
- [Analog](../wiki/Analog).[removeAllListeners](../wiki/Analog#removealllisteners)
1319
-
1320
- #### Defined in
1321
-
1322
- node_modules/@types/node/events.d.ts:473
1323
-
1324
- ___
1325
-
1326
- ### removeListener
1327
-
1328
- ▸ **removeListener**(`eventName`, `listener`): [`Touch`](../wiki/Touch)
1329
-
1330
- Removes the specified `listener` from the listener array for the event named`eventName`.
1331
-
1332
- ```js
1333
- const callback = (stream) => {
1334
- console.log('someone connected!');
1335
- };
1336
- server.on('connection', callback);
1337
- // ...
1338
- server.removeListener('connection', callback);
1339
- ```
1340
-
1341
- `removeListener()` will remove, at most, one instance of a listener from the
1342
- listener array. If any single listener has been added multiple times to the
1343
- listener array for the specified `eventName`, then `removeListener()` must be
1344
- called multiple times to remove each instance.
1345
-
1346
- Once an event is emitted, all listeners attached to it at the
1347
- time of emitting are called in order. This implies that any`removeListener()` or `removeAllListeners()` calls _after_ emitting and_before_ the last listener finishes execution will
1348
- not remove them from`emit()` in progress. Subsequent events behave as expected.
1349
-
1350
- ```js
1351
- const myEmitter = new MyEmitter();
1352
-
1353
- const callbackA = () => {
1354
- console.log('A');
1355
- myEmitter.removeListener('event', callbackB);
1356
- };
1357
-
1358
- const callbackB = () => {
1359
- console.log('B');
1360
- };
1361
-
1362
- myEmitter.on('event', callbackA);
1363
-
1364
- myEmitter.on('event', callbackB);
1365
-
1366
- // callbackA removes listener callbackB but it will still be called.
1367
- // Internal listener array at time of emit [callbackA, callbackB]
1368
- myEmitter.emit('event');
1369
- // Prints:
1370
- // A
1371
- // B
1372
-
1373
- // callbackB is now removed.
1374
- // Internal listener array [callbackA]
1375
- myEmitter.emit('event');
1376
- // Prints:
1377
- // A
1378
- ```
1379
-
1380
- Because listeners are managed using an internal array, calling this will
1381
- change the position indices of any listener registered _after_ the listener
1382
- being removed. This will not impact the order in which listeners are called,
1383
- but it means that any copies of the listener array as returned by
1384
- the `emitter.listeners()` method will need to be recreated.
1385
-
1386
- When a single function has been added as a handler multiple times for a single
1387
- event (as in the example below), `removeListener()` will remove the most
1388
- recently added instance. In the example the `once('ping')`listener is removed:
1389
-
1390
- ```js
1391
- const ee = new EventEmitter();
1392
-
1393
- function pong() {
1394
- console.log('pong');
1395
- }
1396
-
1397
- ee.on('ping', pong);
1398
- ee.once('ping', pong);
1399
- ee.removeListener('ping', pong);
1400
-
1401
- ee.emit('ping');
1402
- ee.emit('ping');
1403
- ```
1404
-
1405
- Returns a reference to the `EventEmitter`, so that calls can be chained.
1406
-
1407
- **`since`** v0.1.26
1408
-
1409
- #### Parameters
1410
-
1411
- | Name | Type |
1412
- | :------ | :------ |
1413
- | `eventName` | `string` \| `symbol` |
1414
- | `listener` | (...`args`: `any`[]) => `void` |
1415
-
1416
- #### Returns
1417
-
1418
- [`Touch`](../wiki/Touch)
1419
-
1420
- #### Inherited from
1421
-
1422
- [Analog](../wiki/Analog).[removeListener](../wiki/Analog#removelistener)
1423
-
1424
- #### Defined in
1425
-
1426
- node_modules/@types/node/events.d.ts:457
1427
-
1428
- ___
1429
-
1430
- ### setMaxListeners
1431
-
1432
- ▸ **setMaxListeners**(`n`): [`Touch`](../wiki/Touch)
1433
-
1434
- By default `EventEmitter`s will print a warning if more than `10` listeners are
1435
- added for a particular event. This is a useful default that helps finding
1436
- memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
1437
- modified for this specific `EventEmitter` instance. The value can be set to`Infinity` (or `0`) to indicate an unlimited number of listeners.
1438
-
1439
- Returns a reference to the `EventEmitter`, so that calls can be chained.
1440
-
1441
- **`since`** v0.3.5
1442
-
1443
- #### Parameters
1444
-
1445
- | Name | Type |
1446
- | :------ | :------ |
1447
- | `n` | `number` |
1448
-
1449
- #### Returns
1450
-
1451
- [`Touch`](../wiki/Touch)
1452
-
1453
- #### Inherited from
1454
-
1455
- [Analog](../wiki/Analog).[setMaxListeners](../wiki/Analog#setmaxlisteners)
1456
-
1457
- #### Defined in
1458
-
1459
- node_modules/@types/node/events.d.ts:483
1460
-
1461
- ___
1462
-
1463
- ### toString
1464
-
1465
- ▸ **toString**(): `string`
1466
-
1467
- Render a convenient debugging string.
1468
-
1469
- #### Returns
1470
-
1471
- `string`
1472
-
1473
- #### Inherited from
1474
-
1475
- [Analog](../wiki/Analog).[toString](../wiki/Analog#tostring)
1476
-
1477
- #### Defined in
1478
-
1479
- [src/input.ts:102](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L102)
1480
-
1481
- ___
1482
-
1483
- ### getEventListeners
1484
-
1485
- ▸ `Static` **getEventListeners**(`emitter`, `name`): `Function`[]
1486
-
1487
- Returns a copy of the array of listeners for the event named `eventName`.
1488
-
1489
- For `EventEmitter`s this behaves exactly the same as calling `.listeners` on
1490
- the emitter.
1491
-
1492
- For `EventTarget`s this is the only way to get the event listeners for the
1493
- event target. This is useful for debugging and diagnostic purposes.
1494
-
1495
- ```js
1496
- const { getEventListeners, EventEmitter } = require('events');
1497
-
1498
- {
1499
- const ee = new EventEmitter();
1500
- const listener = () => console.log('Events are fun');
1501
- ee.on('foo', listener);
1502
- getEventListeners(ee, 'foo'); // [listener]
1503
- }
1504
- {
1505
- const et = new EventTarget();
1506
- const listener = () => console.log('Events are fun');
1507
- et.addEventListener('foo', listener);
1508
- getEventListeners(et, 'foo'); // [listener]
1509
- }
1510
- ```
1511
-
1512
- **`since`** v15.2.0, v14.17.0
1513
-
1514
- #### Parameters
1515
-
1516
- | Name | Type |
1517
- | :------ | :------ |
1518
- | `emitter` | `EventEmitter` \| `DOMEventTarget` |
1519
- | `name` | `string` \| `symbol` |
1520
-
1521
- #### Returns
1522
-
1523
- `Function`[]
1524
-
1525
- #### Inherited from
1526
-
1527
- [Analog](../wiki/Analog).[getEventListeners](../wiki/Analog#geteventlisteners)
1528
-
1529
- #### Defined in
1530
-
1531
- node_modules/@types/node/events.d.ts:262
1532
-
1533
- ___
1534
-
1535
- ### listenerCount
1536
-
1537
- ▸ `Static` **listenerCount**(`emitter`, `eventName`): `number`
1538
-
1539
- A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`.
1540
-
1541
- ```js
1542
- const { EventEmitter, listenerCount } = require('events');
1543
- const myEmitter = new EventEmitter();
1544
- myEmitter.on('event', () => {});
1545
- myEmitter.on('event', () => {});
1546
- console.log(listenerCount(myEmitter, 'event'));
1547
- // Prints: 2
1548
- ```
1549
-
1550
- **`since`** v0.9.12
1551
-
1552
- **`deprecated`** Since v3.2.0 - Use `listenerCount` instead.
1553
-
1554
- #### Parameters
1555
-
1556
- | Name | Type | Description |
1557
- | :------ | :------ | :------ |
1558
- | `emitter` | `EventEmitter` | The emitter to query |
1559
- | `eventName` | `string` \| `symbol` | The event name |
1560
-
1561
- #### Returns
1562
-
1563
- `number`
1564
-
1565
- #### Inherited from
1566
-
1567
- [Analog](../wiki/Analog).[listenerCount](../wiki/Analog#listenercount-1)
1568
-
1569
- #### Defined in
1570
-
1571
- node_modules/@types/node/events.d.ts:234
1572
-
1573
- ___
1574
-
1575
- ### on
1576
-
1577
- ▸ `Static` **on**(`emitter`, `eventName`, `options?`): `AsyncIterableIterator`<`any`\>
1578
-
1579
- ```js
1580
- const { on, EventEmitter } = require('events');
1581
-
1582
- (async () => {
1583
- const ee = new EventEmitter();
1584
-
1585
- // Emit later on
1586
- process.nextTick(() => {
1587
- ee.emit('foo', 'bar');
1588
- ee.emit('foo', 42);
1589
- });
1590
-
1591
- for await (const event of on(ee, 'foo')) {
1592
- // The execution of this inner block is synchronous and it
1593
- // processes one event at a time (even with await). Do not use
1594
- // if concurrent execution is required.
1595
- console.log(event); // prints ['bar'] [42]
1596
- }
1597
- // Unreachable here
1598
- })();
1599
- ```
1600
-
1601
- Returns an `AsyncIterator` that iterates `eventName` events. It will throw
1602
- if the `EventEmitter` emits `'error'`. It removes all listeners when
1603
- exiting the loop. The `value` returned by each iteration is an array
1604
- composed of the emitted event arguments.
1605
-
1606
- An `AbortSignal` can be used to cancel waiting on events:
1607
-
1608
- ```js
1609
- const { on, EventEmitter } = require('events');
1610
- const ac = new AbortController();
1611
-
1612
- (async () => {
1613
- const ee = new EventEmitter();
1614
-
1615
- // Emit later on
1616
- process.nextTick(() => {
1617
- ee.emit('foo', 'bar');
1618
- ee.emit('foo', 42);
1619
- });
1620
-
1621
- for await (const event of on(ee, 'foo', { signal: ac.signal })) {
1622
- // The execution of this inner block is synchronous and it
1623
- // processes one event at a time (even with await). Do not use
1624
- // if concurrent execution is required.
1625
- console.log(event); // prints ['bar'] [42]
1626
- }
1627
- // Unreachable here
1628
- })();
1629
-
1630
- process.nextTick(() => ac.abort());
1631
- ```
1632
-
1633
- **`since`** v13.6.0, v12.16.0
1634
-
1635
- #### Parameters
1636
-
1637
- | Name | Type | Description |
1638
- | :------ | :------ | :------ |
1639
- | `emitter` | `EventEmitter` | - |
1640
- | `eventName` | `string` | The name of the event being listened for |
1641
- | `options?` | `StaticEventEmitterOptions` | - |
1642
-
1643
- #### Returns
1644
-
1645
- `AsyncIterableIterator`<`any`\>
1646
-
1647
- that iterates `eventName` events emitted by the `emitter`
1648
-
1649
- #### Inherited from
1650
-
1651
- [Analog](../wiki/Analog).[on](../wiki/Analog#on-1)
1652
-
1653
- #### Defined in
1654
-
1655
- node_modules/@types/node/events.d.ts:217
1656
-
1657
- ___
1658
-
1659
- ### once
1660
-
1661
- ▸ `Static` **once**(`emitter`, `eventName`, `options?`): `Promise`<`any`[]\>
1662
-
1663
- Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
1664
- event or that is rejected if the `EventEmitter` emits `'error'` while waiting.
1665
- The `Promise` will resolve with an array of all the arguments emitted to the
1666
- given event.
1667
-
1668
- This method is intentionally generic and works with the web platform [EventTarget](https://dom.spec.whatwg.org/#interface-eventtarget) interface, which has no special`'error'` event
1669
- semantics and does not listen to the `'error'` event.
1670
-
1671
- ```js
1672
- const { once, EventEmitter } = require('events');
1673
-
1674
- async function run() {
1675
- const ee = new EventEmitter();
1676
-
1677
- process.nextTick(() => {
1678
- ee.emit('myevent', 42);
1679
- });
1680
-
1681
- const [value] = await once(ee, 'myevent');
1682
- console.log(value);
1683
-
1684
- const err = new Error('kaboom');
1685
- process.nextTick(() => {
1686
- ee.emit('error', err);
1687
- });
1688
-
1689
- try {
1690
- await once(ee, 'myevent');
1691
- } catch (err) {
1692
- console.log('error happened', err);
1693
- }
1694
- }
1695
-
1696
- run();
1697
- ```
1698
-
1699
- The special handling of the `'error'` event is only used when `events.once()`is used to wait for another event. If `events.once()` is used to wait for the
1700
- '`error'` event itself, then it is treated as any other kind of event without
1701
- special handling:
1702
-
1703
- ```js
1704
- const { EventEmitter, once } = require('events');
1705
-
1706
- const ee = new EventEmitter();
1707
-
1708
- once(ee, 'error')
1709
- .then(([err]) => console.log('ok', err.message))
1710
- .catch((err) => console.log('error', err.message));
1711
-
1712
- ee.emit('error', new Error('boom'));
1713
-
1714
- // Prints: ok boom
1715
- ```
1716
-
1717
- An `AbortSignal` can be used to cancel waiting for the event:
1718
-
1719
- ```js
1720
- const { EventEmitter, once } = require('events');
1721
-
1722
- const ee = new EventEmitter();
1723
- const ac = new AbortController();
1724
-
1725
- async function foo(emitter, event, signal) {
1726
- try {
1727
- await once(emitter, event, { signal });
1728
- console.log('event emitted!');
1729
- } catch (error) {
1730
- if (error.name === 'AbortError') {
1731
- console.error('Waiting for the event was canceled!');
1732
- } else {
1733
- console.error('There was an error', error.message);
1734
- }
1735
- }
1736
- }
1737
-
1738
- foo(ee, 'foo', ac.signal);
1739
- ac.abort(); // Abort waiting for the event
1740
- ee.emit('foo'); // Prints: Waiting for the event was canceled!
1741
- ```
1742
-
1743
- **`since`** v11.13.0, v10.16.0
1744
-
1745
- #### Parameters
1746
-
1747
- | Name | Type |
1748
- | :------ | :------ |
1749
- | `emitter` | `NodeEventTarget` |
1750
- | `eventName` | `string` \| `symbol` |
1751
- | `options?` | `StaticEventEmitterOptions` |
1752
-
1753
- #### Returns
1754
-
1755
- `Promise`<`any`[]\>
1756
-
1757
- #### Inherited from
1758
-
1759
- [Analog](../wiki/Analog).[once](../wiki/Analog#once-1)
1760
-
1761
- #### Defined in
1762
-
1763
- node_modules/@types/node/events.d.ts:157
1764
-
1765
- ▸ `Static` **once**(`emitter`, `eventName`, `options?`): `Promise`<`any`[]\>
1766
-
1767
- #### Parameters
1768
-
1769
- | Name | Type |
1770
- | :------ | :------ |
1771
- | `emitter` | `DOMEventTarget` |
1772
- | `eventName` | `string` |
1773
- | `options?` | `StaticEventEmitterOptions` |
1774
-
1775
- #### Returns
1776
-
1777
- `Promise`<`any`[]\>
1778
-
1779
- #### Inherited from
1780
-
1781
- [Analog](../wiki/Analog).[once](../wiki/Analog#once-1)
1782
-
1783
- #### Defined in
1784
-
1785
- node_modules/@types/node/events.d.ts:158
1786
-
1787
- ___
1788
-
1789
- ### setMaxListeners
1790
-
1791
- ▸ `Static` **setMaxListeners**(`n?`, ...`eventTargets`): `void`
1792
-
1793
- ```js
1794
- const {
1795
- setMaxListeners,
1796
- EventEmitter
1797
- } = require('events');
1798
-
1799
- const target = new EventTarget();
1800
- const emitter = new EventEmitter();
1801
-
1802
- setMaxListeners(5, target, emitter);
1803
- ```
1804
-
1805
- **`since`** v15.4.0
1806
-
1807
- #### Parameters
1808
-
1809
- | Name | Type | Description |
1810
- | :------ | :------ | :------ |
1811
- | `n?` | `number` | A non-negative number. The maximum number of listeners per `EventTarget` event. |
1812
- | `...eventTargets` | (`EventEmitter` \| `DOMEventTarget`)[] | - |
1813
-
1814
- #### Returns
1815
-
1816
- `void`
1817
-
1818
- #### Inherited from
1819
-
1820
- [Analog](../wiki/Analog).[setMaxListeners](../wiki/Analog#setmaxlisteners-1)
1821
-
1822
- #### Defined in
1823
-
1824
- node_modules/@types/node/events.d.ts:280