dualsense-ts 2.1.44 → 2.2.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.
- package/dist/elements/analog.d.ts +46 -3
- package/dist/elements/analog.d.ts.map +1 -1
- package/dist/elements/analog.js +41 -14
- package/dist/elements/analog.js.map +1 -1
- package/dist/elements/axis.js +3 -3
- package/dist/elements/axis.js.map +1 -1
- package/docs/Analog.md +79 -38
- package/docs/AnalogParams.md +9 -7
- package/docs/Axis.md +29 -29
- package/docs/Brightness.md +3 -3
- package/docs/CommandScopeA.md +7 -7
- package/docs/CommandScopeB.md +6 -6
- package/docs/Dpad.md +31 -31
- package/docs/DpadParams.md +8 -8
- package/docs/DualSenseCommand.md +45 -45
- package/docs/Dualsense.md +40 -40
- package/docs/DualsenseHID.md +4 -4
- package/docs/DualsenseHIDState.md +41 -41
- package/docs/DualsenseParams.md +17 -17
- package/docs/Exports.md +12 -12
- package/docs/Haptic.md +1 -1
- package/docs/Increment.md +27 -27
- package/docs/Indicator.md +2 -2
- package/docs/Input.md +27 -27
- package/docs/InputId.md +41 -41
- package/docs/InputParams.md +4 -4
- package/docs/LedOptions.md +4 -4
- package/docs/Momentary.md +27 -27
- package/docs/Motion.md +2 -2
- package/docs/Mute.md +29 -29
- package/docs/PlayerID.md +5 -5
- package/docs/PulseOptions.md +3 -3
- package/docs/Touch.md +83 -40
- package/docs/Touchpad.md +30 -30
- package/docs/Trigger.md +32 -32
- package/docs/TriggerMode.md +10 -10
- package/docs/Unisense.md +31 -31
- package/docs/UnisenseParams.md +7 -7
- package/package.json +1 -1
- package/src/elements/analog.ts +56 -18
- package/src/elements/axis.ts +3 -3
package/docs/Unisense.md
CHANGED
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
|
|
92
92
|
#### Defined in
|
|
93
93
|
|
|
94
|
-
[src/elements/unisense.ts:22](https://github.com/nsfm/dualsense-ts/blob/
|
|
94
|
+
[src/elements/unisense.ts:22](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/unisense.ts#L22)
|
|
95
95
|
|
|
96
96
|
## Properties
|
|
97
97
|
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
|
|
121
121
|
#### Defined in
|
|
122
122
|
|
|
123
|
-
[src/input.ts:128](https://github.com/nsfm/dualsense-ts/blob/
|
|
123
|
+
[src/input.ts:128](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L128)
|
|
124
124
|
|
|
125
125
|
___
|
|
126
126
|
|
|
@@ -134,7 +134,7 @@ ___
|
|
|
134
134
|
|
|
135
135
|
#### Defined in
|
|
136
136
|
|
|
137
|
-
[src/input.ts:162](https://github.com/nsfm/dualsense-ts/blob/
|
|
137
|
+
[src/input.ts:162](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L162)
|
|
138
138
|
|
|
139
139
|
___
|
|
140
140
|
|
|
@@ -148,7 +148,7 @@ ___
|
|
|
148
148
|
|
|
149
149
|
#### Defined in
|
|
150
150
|
|
|
151
|
-
[src/input.ts:157](https://github.com/nsfm/dualsense-ts/blob/
|
|
151
|
+
[src/input.ts:157](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L157)
|
|
152
152
|
|
|
153
153
|
___
|
|
154
154
|
|
|
@@ -162,7 +162,7 @@ ___
|
|
|
162
162
|
|
|
163
163
|
#### Defined in
|
|
164
164
|
|
|
165
|
-
[src/input.ts:154](https://github.com/nsfm/dualsense-ts/blob/
|
|
165
|
+
[src/input.ts:154](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L154)
|
|
166
166
|
|
|
167
167
|
___
|
|
168
168
|
|
|
@@ -176,7 +176,7 @@ ___
|
|
|
176
176
|
|
|
177
177
|
#### Defined in
|
|
178
178
|
|
|
179
|
-
[src/input.ts:160](https://github.com/nsfm/dualsense-ts/blob/
|
|
179
|
+
[src/input.ts:160](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L160)
|
|
180
180
|
|
|
181
181
|
___
|
|
182
182
|
|
|
@@ -186,7 +186,7 @@ ___
|
|
|
186
186
|
|
|
187
187
|
#### Defined in
|
|
188
188
|
|
|
189
|
-
[src/elements/unisense.ts:19](https://github.com/nsfm/dualsense-ts/blob/
|
|
189
|
+
[src/elements/unisense.ts:19](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/unisense.ts#L19)
|
|
190
190
|
|
|
191
191
|
___
|
|
192
192
|
|
|
@@ -196,7 +196,7 @@ ___
|
|
|
196
196
|
|
|
197
197
|
#### Defined in
|
|
198
198
|
|
|
199
|
-
[src/elements/unisense.ts:18](https://github.com/nsfm/dualsense-ts/blob/
|
|
199
|
+
[src/elements/unisense.ts:18](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/unisense.ts#L18)
|
|
200
200
|
|
|
201
201
|
___
|
|
202
202
|
|
|
@@ -206,7 +206,7 @@ ___
|
|
|
206
206
|
|
|
207
207
|
#### Defined in
|
|
208
208
|
|
|
209
|
-
[src/elements/unisense.ts:20](https://github.com/nsfm/dualsense-ts/blob/
|
|
209
|
+
[src/elements/unisense.ts:20](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/unisense.ts#L20)
|
|
210
210
|
|
|
211
211
|
___
|
|
212
212
|
|
|
@@ -220,7 +220,7 @@ ___
|
|
|
220
220
|
|
|
221
221
|
#### Defined in
|
|
222
222
|
|
|
223
|
-
[src/input.ts:58](https://github.com/nsfm/dualsense-ts/blob/
|
|
223
|
+
[src/input.ts:58](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L58)
|
|
224
224
|
|
|
225
225
|
___
|
|
226
226
|
|
|
@@ -234,7 +234,7 @@ ___
|
|
|
234
234
|
|
|
235
235
|
#### Defined in
|
|
236
236
|
|
|
237
|
-
[src/input.ts:61](https://github.com/nsfm/dualsense-ts/blob/
|
|
237
|
+
[src/input.ts:61](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L61)
|
|
238
238
|
|
|
239
239
|
___
|
|
240
240
|
|
|
@@ -248,7 +248,7 @@ ___
|
|
|
248
248
|
|
|
249
249
|
#### Defined in
|
|
250
250
|
|
|
251
|
-
[src/input.ts:64](https://github.com/nsfm/dualsense-ts/blob/
|
|
251
|
+
[src/input.ts:64](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L64)
|
|
252
252
|
|
|
253
253
|
___
|
|
254
254
|
|
|
@@ -262,7 +262,7 @@ ___
|
|
|
262
262
|
|
|
263
263
|
#### Defined in
|
|
264
264
|
|
|
265
|
-
[src/elements/unisense.ts:15](https://github.com/nsfm/dualsense-ts/blob/
|
|
265
|
+
[src/elements/unisense.ts:15](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/unisense.ts#L15)
|
|
266
266
|
|
|
267
267
|
___
|
|
268
268
|
|
|
@@ -276,7 +276,7 @@ ___
|
|
|
276
276
|
|
|
277
277
|
#### Defined in
|
|
278
278
|
|
|
279
|
-
[src/input.ts:67](https://github.com/nsfm/dualsense-ts/blob/
|
|
279
|
+
[src/input.ts:67](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L67)
|
|
280
280
|
|
|
281
281
|
___
|
|
282
282
|
|
|
@@ -286,7 +286,7 @@ ___
|
|
|
286
286
|
|
|
287
287
|
#### Defined in
|
|
288
288
|
|
|
289
|
-
[src/elements/unisense.ts:17](https://github.com/nsfm/dualsense-ts/blob/
|
|
289
|
+
[src/elements/unisense.ts:17](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/unisense.ts#L17)
|
|
290
290
|
|
|
291
291
|
___
|
|
292
292
|
|
|
@@ -370,7 +370,7 @@ Input.\_\_@toStringTag@66
|
|
|
370
370
|
|
|
371
371
|
#### Defined in
|
|
372
372
|
|
|
373
|
-
[src/input.ts:149](https://github.com/nsfm/dualsense-ts/blob/
|
|
373
|
+
[src/input.ts:149](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L149)
|
|
374
374
|
|
|
375
375
|
___
|
|
376
376
|
|
|
@@ -388,7 +388,7 @@ Input.active
|
|
|
388
388
|
|
|
389
389
|
#### Defined in
|
|
390
390
|
|
|
391
|
-
[src/elements/unisense.ts:41](https://github.com/nsfm/dualsense-ts/blob/
|
|
391
|
+
[src/elements/unisense.ts:41](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/unisense.ts#L41)
|
|
392
392
|
|
|
393
393
|
## Methods
|
|
394
394
|
|
|
@@ -409,7 +409,7 @@ And decide if this is the root Input.
|
|
|
409
409
|
|
|
410
410
|
#### Defined in
|
|
411
411
|
|
|
412
|
-
[src/input.ts:168](https://github.com/nsfm/dualsense-ts/blob/
|
|
412
|
+
[src/input.ts:168](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L168)
|
|
413
413
|
|
|
414
414
|
___
|
|
415
415
|
|
|
@@ -434,7 +434,7 @@ ___
|
|
|
434
434
|
|
|
435
435
|
#### Defined in
|
|
436
436
|
|
|
437
|
-
[src/input.ts:190](https://github.com/nsfm/dualsense-ts/blob/
|
|
437
|
+
[src/input.ts:190](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L190)
|
|
438
438
|
|
|
439
439
|
___
|
|
440
440
|
|
|
@@ -459,7 +459,7 @@ ___
|
|
|
459
459
|
|
|
460
460
|
#### Defined in
|
|
461
461
|
|
|
462
|
-
[src/input.ts:194](https://github.com/nsfm/dualsense-ts/blob/
|
|
462
|
+
[src/input.ts:194](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L194)
|
|
463
463
|
|
|
464
464
|
___
|
|
465
465
|
|
|
@@ -477,7 +477,7 @@ ___
|
|
|
477
477
|
|
|
478
478
|
#### Defined in
|
|
479
479
|
|
|
480
|
-
[src/input.ts:186](https://github.com/nsfm/dualsense-ts/blob/
|
|
480
|
+
[src/input.ts:186](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L186)
|
|
481
481
|
|
|
482
482
|
___
|
|
483
483
|
|
|
@@ -508,7 +508,7 @@ ___
|
|
|
508
508
|
|
|
509
509
|
#### Defined in
|
|
510
510
|
|
|
511
|
-
[src/input.ts:199](https://github.com/nsfm/dualsense-ts/blob/
|
|
511
|
+
[src/input.ts:199](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L199)
|
|
512
512
|
|
|
513
513
|
___
|
|
514
514
|
|
|
@@ -534,7 +534,7 @@ Update the input's state and trigger all necessary callbacks.
|
|
|
534
534
|
|
|
535
535
|
#### Defined in
|
|
536
536
|
|
|
537
|
-
[src/input.ts:215](https://github.com/nsfm/dualsense-ts/blob/
|
|
537
|
+
[src/input.ts:215](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L215)
|
|
538
538
|
|
|
539
539
|
___
|
|
540
540
|
|
|
@@ -552,7 +552,7 @@ ___
|
|
|
552
552
|
|
|
553
553
|
#### Defined in
|
|
554
554
|
|
|
555
|
-
[src/input.ts:139](https://github.com/nsfm/dualsense-ts/blob/
|
|
555
|
+
[src/input.ts:139](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L139)
|
|
556
556
|
|
|
557
557
|
___
|
|
558
558
|
|
|
@@ -570,7 +570,7 @@ ___
|
|
|
570
570
|
|
|
571
571
|
#### Defined in
|
|
572
572
|
|
|
573
|
-
[src/input.ts:131](https://github.com/nsfm/dualsense-ts/blob/
|
|
573
|
+
[src/input.ts:131](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L131)
|
|
574
574
|
|
|
575
575
|
___
|
|
576
576
|
|
|
@@ -594,7 +594,7 @@ ___
|
|
|
594
594
|
|
|
595
595
|
#### Defined in
|
|
596
596
|
|
|
597
|
-
[src/input.ts:143](https://github.com/nsfm/dualsense-ts/blob/
|
|
597
|
+
[src/input.ts:143](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L143)
|
|
598
598
|
|
|
599
599
|
___
|
|
600
600
|
|
|
@@ -648,7 +648,7 @@ ___
|
|
|
648
648
|
|
|
649
649
|
#### Defined in
|
|
650
650
|
|
|
651
|
-
[src/input.ts:44](https://github.com/nsfm/dualsense-ts/blob/
|
|
651
|
+
[src/input.ts:44](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L44)
|
|
652
652
|
|
|
653
653
|
___
|
|
654
654
|
|
|
@@ -797,7 +797,7 @@ Resolves on the next change to this input's state.
|
|
|
797
797
|
|
|
798
798
|
#### Defined in
|
|
799
799
|
|
|
800
|
-
[src/input.ts:78](https://github.com/nsfm/dualsense-ts/blob/
|
|
800
|
+
[src/input.ts:78](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L78)
|
|
801
801
|
|
|
802
802
|
___
|
|
803
803
|
|
|
@@ -851,7 +851,7 @@ ___
|
|
|
851
851
|
|
|
852
852
|
#### Defined in
|
|
853
853
|
|
|
854
|
-
[src/input.ts:37](https://github.com/nsfm/dualsense-ts/blob/
|
|
854
|
+
[src/input.ts:37](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L37)
|
|
855
855
|
|
|
856
856
|
___
|
|
857
857
|
|
|
@@ -1006,7 +1006,7 @@ Resolves on the next change to this input's state.
|
|
|
1006
1006
|
|
|
1007
1007
|
#### Defined in
|
|
1008
1008
|
|
|
1009
|
-
[src/input.ts:91](https://github.com/nsfm/dualsense-ts/blob/
|
|
1009
|
+
[src/input.ts:91](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L91)
|
|
1010
1010
|
|
|
1011
1011
|
___
|
|
1012
1012
|
|
|
@@ -1250,7 +1250,7 @@ Render a convenient debugging string.
|
|
|
1250
1250
|
|
|
1251
1251
|
#### Defined in
|
|
1252
1252
|
|
|
1253
|
-
[src/input.ts:102](https://github.com/nsfm/dualsense-ts/blob/
|
|
1253
|
+
[src/input.ts:102](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L102)
|
|
1254
1254
|
|
|
1255
1255
|
___
|
|
1256
1256
|
|
package/docs/UnisenseParams.md
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
#### Defined in
|
|
28
28
|
|
|
29
|
-
[src/elements/unisense.ts:10](https://github.com/nsfm/dualsense-ts/blob/
|
|
29
|
+
[src/elements/unisense.ts:10](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/unisense.ts#L10)
|
|
30
30
|
|
|
31
31
|
___
|
|
32
32
|
|
|
@@ -36,7 +36,7 @@ ___
|
|
|
36
36
|
|
|
37
37
|
#### Defined in
|
|
38
38
|
|
|
39
|
-
[src/elements/unisense.ts:9](https://github.com/nsfm/dualsense-ts/blob/
|
|
39
|
+
[src/elements/unisense.ts:9](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/unisense.ts#L9)
|
|
40
40
|
|
|
41
41
|
___
|
|
42
42
|
|
|
@@ -50,7 +50,7 @@ ___
|
|
|
50
50
|
|
|
51
51
|
#### Defined in
|
|
52
52
|
|
|
53
|
-
[src/input.ts:6](https://github.com/nsfm/dualsense-ts/blob/
|
|
53
|
+
[src/input.ts:6](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L6)
|
|
54
54
|
|
|
55
55
|
___
|
|
56
56
|
|
|
@@ -64,7 +64,7 @@ ___
|
|
|
64
64
|
|
|
65
65
|
#### Defined in
|
|
66
66
|
|
|
67
|
-
[src/input.ts:5](https://github.com/nsfm/dualsense-ts/blob/
|
|
67
|
+
[src/input.ts:5](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L5)
|
|
68
68
|
|
|
69
69
|
___
|
|
70
70
|
|
|
@@ -78,7 +78,7 @@ ___
|
|
|
78
78
|
|
|
79
79
|
#### Defined in
|
|
80
80
|
|
|
81
|
-
[src/input.ts:8](https://github.com/nsfm/dualsense-ts/blob/
|
|
81
|
+
[src/input.ts:8](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L8)
|
|
82
82
|
|
|
83
83
|
___
|
|
84
84
|
|
|
@@ -92,7 +92,7 @@ ___
|
|
|
92
92
|
|
|
93
93
|
#### Defined in
|
|
94
94
|
|
|
95
|
-
[src/input.ts:7](https://github.com/nsfm/dualsense-ts/blob/
|
|
95
|
+
[src/input.ts:7](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L7)
|
|
96
96
|
|
|
97
97
|
___
|
|
98
98
|
|
|
@@ -102,4 +102,4 @@ ___
|
|
|
102
102
|
|
|
103
103
|
#### Defined in
|
|
104
104
|
|
|
105
|
-
[src/elements/unisense.ts:8](https://github.com/nsfm/dualsense-ts/blob/
|
|
105
|
+
[src/elements/unisense.ts:8](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/elements/unisense.ts#L8)
|
package/package.json
CHANGED
package/src/elements/analog.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { Axis } from "./axis";
|
|
2
2
|
import { Momentary } from "./momentary";
|
|
3
3
|
import { Input, InputParams } from "../input";
|
|
4
|
-
import { Radians, Degrees, Magnitude } from "../math";
|
|
4
|
+
import { Radians, Degrees, Magnitude, Force } from "../math";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for an analog joystick and its basic inputs.
|
|
8
|
+
*/
|
|
6
9
|
export interface AnalogParams extends InputParams {
|
|
7
10
|
button?: InputParams;
|
|
8
11
|
x?: InputParams;
|
|
@@ -21,65 +24,100 @@ export interface AnalogParams extends InputParams {
|
|
|
21
24
|
export class Analog extends Input<Analog> {
|
|
22
25
|
public readonly state: Analog = this;
|
|
23
26
|
|
|
27
|
+
/**
|
|
28
|
+
* The left/right position of the input.
|
|
29
|
+
*/
|
|
24
30
|
public readonly x: Axis;
|
|
31
|
+
/**
|
|
32
|
+
* The up/down position of the input.
|
|
33
|
+
*/
|
|
25
34
|
public readonly y: Axis;
|
|
35
|
+
/**
|
|
36
|
+
* Button triggered by pressing the stick.
|
|
37
|
+
*/
|
|
26
38
|
public readonly button: Momentary;
|
|
27
39
|
|
|
28
40
|
constructor(params?: AnalogParams) {
|
|
29
41
|
super(params);
|
|
42
|
+
const { button, x, y, threshold } = params || {};
|
|
30
43
|
|
|
31
|
-
this.button = new Momentary(
|
|
32
|
-
params?.button || { icon: "3", name: "Button" }
|
|
33
|
-
);
|
|
44
|
+
this.button = new Momentary(button || { icon: "3", name: "Button" });
|
|
34
45
|
this.x = new Axis(
|
|
35
|
-
|
|
46
|
+
x || { icon: "↔", name: "X", threshold: threshold || (1 / 128) * 6 }
|
|
36
47
|
);
|
|
37
48
|
this.y = new Axis(
|
|
38
|
-
|
|
49
|
+
y || { icon: "↕", name: "Y", threshold: threshold || (1 / 128) * 6 }
|
|
39
50
|
);
|
|
40
51
|
}
|
|
41
52
|
|
|
42
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Returns true if the stick is away from the idle position, or the button is pressed.
|
|
55
|
+
*/
|
|
43
56
|
public get active(): boolean {
|
|
44
|
-
return this.
|
|
57
|
+
return this.x.active || this.y.active || this.button.active;
|
|
45
58
|
}
|
|
46
59
|
|
|
47
|
-
|
|
48
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Returns a direction and magnitude representing the stick's position.
|
|
62
|
+
*/
|
|
63
|
+
public get vector(): { direction: Radians; magnitude: Magnitude } {
|
|
49
64
|
return { direction: this.direction, magnitude: this.magnitude };
|
|
50
65
|
}
|
|
51
66
|
|
|
52
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Returns an force from the stick's position.
|
|
69
|
+
*/
|
|
70
|
+
public get force(): Force {
|
|
71
|
+
return this.active
|
|
72
|
+
? Math.max(Math.min(Math.hypot(this.x.state, this.y.state), 1), -1)
|
|
73
|
+
: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Returns a magnitude from the stick's position.
|
|
78
|
+
*/
|
|
53
79
|
public get magnitude(): Magnitude {
|
|
54
|
-
return Math.
|
|
80
|
+
return Math.abs(this.force);
|
|
55
81
|
}
|
|
56
82
|
|
|
57
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Returns the stick's angle in radians.
|
|
85
|
+
*/
|
|
58
86
|
public get direction(): Radians {
|
|
59
87
|
return Math.atan2(this.y.state, this.x.state);
|
|
60
88
|
}
|
|
61
89
|
|
|
62
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Alias for `.direction`
|
|
92
|
+
*/
|
|
63
93
|
public get radians(): Radians {
|
|
64
94
|
return this.direction;
|
|
65
95
|
}
|
|
66
96
|
|
|
67
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Alias for `.direction`
|
|
99
|
+
*/
|
|
68
100
|
public get angle(): Radians {
|
|
69
101
|
return this.direction;
|
|
70
102
|
}
|
|
71
103
|
|
|
72
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Alias for `.direction` converted to degrees.
|
|
106
|
+
*/
|
|
73
107
|
public get directionDegrees(): Degrees {
|
|
74
108
|
return (this.direction * 180) / Math.PI;
|
|
75
109
|
}
|
|
76
110
|
|
|
77
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Alias for `.directionDegrees`.
|
|
113
|
+
*/
|
|
78
114
|
public get degrees(): Degrees {
|
|
79
115
|
return this.directionDegrees;
|
|
80
116
|
}
|
|
81
117
|
|
|
82
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Alias for `.directionDegrees`.
|
|
120
|
+
*/
|
|
83
121
|
public get angleDegrees(): Degrees {
|
|
84
122
|
return this.directionDegrees;
|
|
85
123
|
}
|
package/src/elements/axis.ts
CHANGED
|
@@ -5,14 +5,14 @@ export class Axis extends Input<Force> {
|
|
|
5
5
|
public state: Force = 0;
|
|
6
6
|
|
|
7
7
|
public get active(): boolean {
|
|
8
|
-
return this.
|
|
8
|
+
return Math.abs(this.state) > this.threshold;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
public get force(): Force {
|
|
12
|
-
return this.state;
|
|
12
|
+
return this.active ? this.state : 0;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
public get magnitude(): Magnitude {
|
|
16
|
-
return Math.abs(this.
|
|
16
|
+
return Math.abs(this.force);
|
|
17
17
|
}
|
|
18
18
|
}
|