dualsense-ts 2.2.0 → 2.2.1

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 (47) hide show
  1. package/dist/elements/analog.js +2 -2
  2. package/dist/elements/analog.js.map +1 -1
  3. package/dist/elements/unisense.js +1 -1
  4. package/dist/elements/unisense.js.map +1 -1
  5. package/dist/input.d.ts +27 -0
  6. package/dist/input.d.ts.map +1 -1
  7. package/dist/input.js +9 -3
  8. package/dist/input.js.map +1 -1
  9. package/docs/Analog.md +81 -131
  10. package/docs/AnalogParams.md +7 -9
  11. package/docs/Axis.md +72 -79
  12. package/docs/Brightness.md +8 -8
  13. package/docs/CommandScopeA.md +16 -16
  14. package/docs/CommandScopeB.md +14 -14
  15. package/docs/Dpad.md +74 -81
  16. package/docs/DpadParams.md +8 -8
  17. package/docs/DualSenseCommand.md +45 -45
  18. package/docs/Dualsense.md +83 -90
  19. package/docs/DualsenseHID.md +47 -42
  20. package/docs/DualsenseHIDState.md +41 -41
  21. package/docs/DualsenseParams.md +17 -17
  22. package/docs/Exports.md +18 -21
  23. package/docs/Haptic.md +1 -1
  24. package/docs/Home.md +29 -31
  25. package/docs/Indicator.md +2 -2
  26. package/docs/Input.md +70 -79
  27. package/docs/InputId.md +84 -84
  28. package/docs/InputParams.md +4 -4
  29. package/docs/LedOptions.md +10 -10
  30. package/docs/Momentary.md +70 -77
  31. package/docs/Motion.md +2 -2
  32. package/docs/Mute.md +71 -89
  33. package/docs/PlayerID.md +12 -12
  34. package/docs/PulseOptions.md +8 -8
  35. package/docs/Touchpad.md +120 -94
  36. package/docs/Trigger.md +75 -82
  37. package/docs/TriggerMode.md +22 -22
  38. package/docs/Unisense.md +74 -81
  39. package/docs/UnisenseParams.md +7 -7
  40. package/package.json +2 -2
  41. package/src/elements/analog.spec.ts +17 -0
  42. package/src/elements/analog.ts +2 -2
  43. package/src/elements/axis.spec.ts +31 -0
  44. package/src/elements/unisense.ts +1 -1
  45. package/src/input.ts +27 -9
  46. package/docs/Increment.md +0 -1554
  47. package/docs/Touch.md +0 -1824
@@ -36,7 +36,7 @@
36
36
 
37
37
  #### Defined in
38
38
 
39
- [src/dualsense.ts:22](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/dualsense.ts#L22)
39
+ [src/dualsense.ts:22](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/dualsense.ts#L22)
40
40
 
41
41
  ___
42
42
 
@@ -46,7 +46,7 @@ ___
46
46
 
47
47
  #### Defined in
48
48
 
49
- [src/dualsense.ts:20](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/dualsense.ts#L20)
49
+ [src/dualsense.ts:20](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/dualsense.ts#L20)
50
50
 
51
51
  ___
52
52
 
@@ -56,7 +56,7 @@ ___
56
56
 
57
57
  #### Defined in
58
58
 
59
- [src/dualsense.ts:23](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/dualsense.ts#L23)
59
+ [src/dualsense.ts:23](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/dualsense.ts#L23)
60
60
 
61
61
  ___
62
62
 
@@ -66,7 +66,7 @@ ___
66
66
 
67
67
  #### Defined in
68
68
 
69
- [src/dualsense.ts:25](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/dualsense.ts#L25)
69
+ [src/dualsense.ts:25](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/dualsense.ts#L25)
70
70
 
71
71
  ___
72
72
 
@@ -76,7 +76,7 @@ ___
76
76
 
77
77
  #### Defined in
78
78
 
79
- [src/dualsense.ts:14](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/dualsense.ts#L14)
79
+ [src/dualsense.ts:14](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/dualsense.ts#L14)
80
80
 
81
81
  ___
82
82
 
@@ -90,7 +90,7 @@ ___
90
90
 
91
91
  #### Defined in
92
92
 
93
- [src/input.ts:6](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L6)
93
+ [src/input.ts:6](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/input.ts#L6)
94
94
 
95
95
  ___
96
96
 
@@ -100,7 +100,7 @@ ___
100
100
 
101
101
  #### Defined in
102
102
 
103
- [src/dualsense.ts:26](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/dualsense.ts#L26)
103
+ [src/dualsense.ts:26](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/dualsense.ts#L26)
104
104
 
105
105
  ___
106
106
 
@@ -110,7 +110,7 @@ ___
110
110
 
111
111
  #### Defined in
112
112
 
113
- [src/dualsense.ts:18](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/dualsense.ts#L18)
113
+ [src/dualsense.ts:18](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/dualsense.ts#L18)
114
114
 
115
115
  ___
116
116
 
@@ -124,7 +124,7 @@ ___
124
124
 
125
125
  #### Defined in
126
126
 
127
- [src/input.ts:5](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L5)
127
+ [src/input.ts:5](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/input.ts#L5)
128
128
 
129
129
  ___
130
130
 
@@ -134,7 +134,7 @@ ___
134
134
 
135
135
  #### Defined in
136
136
 
137
- [src/dualsense.ts:19](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/dualsense.ts#L19)
137
+ [src/dualsense.ts:19](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/dualsense.ts#L19)
138
138
 
139
139
  ___
140
140
 
@@ -148,7 +148,7 @@ ___
148
148
 
149
149
  #### Defined in
150
150
 
151
- [src/input.ts:8](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L8)
151
+ [src/input.ts:8](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/input.ts#L8)
152
152
 
153
153
  ___
154
154
 
@@ -158,7 +158,7 @@ ___
158
158
 
159
159
  #### Defined in
160
160
 
161
- [src/dualsense.ts:17](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/dualsense.ts#L17)
161
+ [src/dualsense.ts:17](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/dualsense.ts#L17)
162
162
 
163
163
  ___
164
164
 
@@ -168,7 +168,7 @@ ___
168
168
 
169
169
  #### Defined in
170
170
 
171
- [src/dualsense.ts:27](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/dualsense.ts#L27)
171
+ [src/dualsense.ts:27](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/dualsense.ts#L27)
172
172
 
173
173
  ___
174
174
 
@@ -178,7 +178,7 @@ ___
178
178
 
179
179
  #### Defined in
180
180
 
181
- [src/dualsense.ts:24](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/dualsense.ts#L24)
181
+ [src/dualsense.ts:24](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/dualsense.ts#L24)
182
182
 
183
183
  ___
184
184
 
@@ -192,7 +192,7 @@ ___
192
192
 
193
193
  #### Defined in
194
194
 
195
- [src/input.ts:7](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L7)
195
+ [src/input.ts:7](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/input.ts#L7)
196
196
 
197
197
  ___
198
198
 
@@ -202,7 +202,7 @@ ___
202
202
 
203
203
  #### Defined in
204
204
 
205
- [src/dualsense.ts:28](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/dualsense.ts#L28)
205
+ [src/dualsense.ts:28](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/dualsense.ts#L28)
206
206
 
207
207
  ___
208
208
 
@@ -212,4 +212,4 @@ ___
212
212
 
213
213
  #### Defined in
214
214
 
215
- [src/dualsense.ts:21](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/dualsense.ts#L21)
215
+ [src/dualsense.ts:21](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/dualsense.ts#L21)
package/docs/Exports.md CHANGED
@@ -23,13 +23,11 @@
23
23
  - [DualsenseHID](../wiki/DualsenseHID)
24
24
  - [Gyroscope](../wiki/Gyroscope)
25
25
  - [Haptic](../wiki/Haptic)
26
- - [Increment](../wiki/Increment)
27
26
  - [Indicator](../wiki/Indicator)
28
27
  - [Input](../wiki/Input)
29
28
  - [Momentary](../wiki/Momentary)
30
29
  - [Motion](../wiki/Motion)
31
30
  - [Mute](../wiki/Mute)
32
- - [Touch](../wiki/Touch)
33
31
  - [Touchpad](../wiki/Touchpad)
34
32
  - [Trigger](../wiki/Trigger)
35
33
  - [Unisense](../wiki/Unisense)
@@ -44,7 +42,7 @@
44
42
  - [InputParams](../wiki/InputParams)
45
43
  - [UnisenseParams](../wiki/UnisenseParams)
46
44
 
47
- ### Type Aliases
45
+ ### Type aliases
48
46
 
49
47
  - [Degrees](../wiki/Exports#degrees)
50
48
  - [Force](../wiki/Exports#force)
@@ -65,7 +63,7 @@
65
63
  - [mapAxis](../wiki/Exports#mapaxis)
66
64
  - [mapTrigger](../wiki/Exports#maptrigger)
67
65
 
68
- ## Type Aliases
66
+ ## Type aliases
69
67
 
70
68
  ### Degrees
71
69
 
@@ -75,7 +73,7 @@ A numeric value between 0 and 360.
75
73
 
76
74
  #### Defined in
77
75
 
78
- [src/math.ts:9](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/math.ts#L9)
76
+ [src/math.ts:9](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/math.ts#L9)
79
77
 
80
78
  ___
81
79
 
@@ -87,7 +85,7 @@ A numeric value between -1 and 1.
87
85
 
88
86
  #### Defined in
89
87
 
90
- [src/math.ts:19](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/math.ts#L19)
88
+ [src/math.ts:19](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/math.ts#L19)
91
89
 
92
90
  ___
93
91
 
@@ -97,7 +95,7 @@ ___
97
95
 
98
96
  #### Defined in
99
97
 
100
- [src/input.ts:34](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L34)
98
+ [src/input.ts:34](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/input.ts#L34)
101
99
 
102
100
  ___
103
101
 
@@ -109,7 +107,7 @@ A numeric value between 0 and 1.
109
107
 
110
108
  #### Defined in
111
109
 
112
- [src/math.ts:24](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/math.ts#L24)
110
+ [src/math.ts:24](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/math.ts#L24)
113
111
 
114
112
  ___
115
113
 
@@ -121,7 +119,7 @@ A numeric value between 0 and 1.
121
119
 
122
120
  #### Defined in
123
121
 
124
- [src/math.ts:14](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/math.ts#L14)
122
+ [src/math.ts:14](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/math.ts#L14)
125
123
 
126
124
  ___
127
125
 
@@ -133,7 +131,7 @@ A numeric value between ±Math.PI.
133
131
 
134
132
  #### Defined in
135
133
 
136
- [src/math.ts:4](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/math.ts#L4)
134
+ [src/math.ts:4](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/math.ts#L4)
137
135
 
138
136
  ## Variables
139
137
 
@@ -143,7 +141,7 @@ A numeric value between ±Math.PI.
143
141
 
144
142
  #### Defined in
145
143
 
146
- [src/input.ts:27](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L27)
144
+ [src/input.ts:27](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/input.ts#L27)
147
145
 
148
146
  ___
149
147
 
@@ -153,7 +151,7 @@ ___
153
151
 
154
152
  #### Defined in
155
153
 
156
- [src/input.ts:32](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L32)
154
+ [src/input.ts:32](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/input.ts#L32)
157
155
 
158
156
  ___
159
157
 
@@ -163,7 +161,7 @@ ___
163
161
 
164
162
  #### Defined in
165
163
 
166
- [src/input.ts:31](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L31)
164
+ [src/input.ts:31](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/input.ts#L31)
167
165
 
168
166
  ___
169
167
 
@@ -173,20 +171,19 @@ ___
173
171
 
174
172
  #### Defined in
175
173
 
176
- [src/input.ts:30](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/input.ts#L30)
174
+ [src/input.ts:30](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/input.ts#L30)
177
175
 
178
176
  ## Functions
179
177
 
180
178
  ### mapAxis
181
179
 
182
- ▸ **mapAxis**(`value`, `max?`): `number`
180
+ ▸ **mapAxis**(`value`): `number`
183
181
 
184
182
  #### Parameters
185
183
 
186
- | Name | Type | Default value |
187
- | :------ | :------ | :------ |
188
- | `value` | `number` | `undefined` |
189
- | `max` | `number` | `255` |
184
+ | Name | Type |
185
+ | :------ | :------ |
186
+ | `value` | `number` |
190
187
 
191
188
  #### Returns
192
189
 
@@ -194,7 +191,7 @@ ___
194
191
 
195
192
  #### Defined in
196
193
 
197
- [src/hid/dualsense_hid.ts:51](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/hid/dualsense_hid.ts#L51)
194
+ [src/hid/dualsense_hid.ts:51](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/hid/dualsense_hid.ts#L51)
198
195
 
199
196
  ___
200
197
 
@@ -214,4 +211,4 @@ ___
214
211
 
215
212
  #### Defined in
216
213
 
217
- [src/hid/dualsense_hid.ts:56](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/hid/dualsense_hid.ts#L56)
214
+ [src/hid/dualsense_hid.ts:56](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/hid/dualsense_hid.ts#L56)
package/docs/Haptic.md CHANGED
@@ -24,4 +24,4 @@
24
24
 
25
25
  #### Defined in
26
26
 
27
- [src/haptics/haptic.ts:4](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/haptics/haptic.ts#L4)
27
+ [src/haptics/haptic.ts:4](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/haptics/haptic.ts#L4)
package/docs/Home.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # dualsense-ts
2
2
 
3
- This module provides a natural interface for your DualSense controller.
3
+ This module provides a natural interface for your DualSense controller, so you can focus on input and forget about the device.
4
4
 
5
5
  ## Getting started
6
6
 
@@ -15,7 +15,7 @@ Install it using your preferred package manager:
15
15
 
16
16
  ### Connecting
17
17
 
18
- `dualsense-ts` will try to connect to the first Dualsense controller it finds.
18
+ By default, `dualsense-ts` will try to connect to the first Dualsense controller it finds.
19
19
 
20
20
  ```typescript
21
21
  import { Dualsense } from "dualsense-ts";
@@ -32,25 +32,22 @@ const controller = new Dualsense();
32
32
 
33
33
  ```typescript
34
34
  // Buttons
35
- controller.circle.state; // false
36
- controller.left.bumper.state; // true
35
+ controller.circle.active; // false
36
+ controller.cross.active; // true
37
+ controller.left.bumper.active; // true
37
38
 
38
39
  // Triggers
39
- controller.right.trigger.active; // true
40
- controller.right.trigger.pressure; // 0.72, 0 - 1
41
-
42
- // Analog Sticks - represented as a position on a unit circle
43
- controller.left.analog.x.active; // true, when away from center
44
- controller.left.analog.x.state; // 0.51, -1 to 1
45
- controller.left.analog.direction; // 4.32, radians
46
- controller.left.analog.magnitude; // 0.23, 0 to 1
47
-
48
- // Touchpad - each touch point works like an analog input
49
- controller.touchpad.right.contact.state; // false
50
- +controller.touchpad.right.x; // -0.44, -1 to 1
40
+ controller.right.trigger.active; // true
41
+ controller.right.trigger.pressure; // 0.72 (0 - 1)
42
+
43
+ // Analog Sticks
44
+ controller.left.analog.x.active; // true
45
+ controller.left.analog.x.state; // 0.51 (0 - 1)
46
+ controller.right.analog.y.active; // false
47
+ +controller.right.analog.y; // 0 (0 - 1)
51
48
  ```
52
49
 
53
- - _Callbacks_: Each input is an EventEmitter that provides `input`, `press`, `release`, and `change` events
50
+ - _Callbacks_: Each input is an EventEmitter that provides `input` or `change` events
54
51
 
55
52
  ```typescript
56
53
  // Change events are triggered only when an input's value changes
@@ -60,30 +57,31 @@ controller.triangle.on("change", (input) =>
60
57
  // ▲ changed: true
61
58
  // ▲ changed: false
62
59
 
60
+ controller.triangle.removeAllListeners();
61
+
63
62
  // The callback provides two arguments, so you can monitor nested inputs
64
- // You'll get a reference to your original input, and whichever one changed
65
- controller.dpad.on("press", (dpad, input) =>
66
- assert(dpad === controller.dpad)
67
- console.log(`${input} pressed`)
63
+ controller.dpad.on("change", (dpad, input) =>
64
+ assert(dpad === controller.dpad) // The input you subscribed to
65
+ console.log(`${input} changed: ${input.active}`) // The input that actually changed
68
66
  );
69
- // ↑ pressed
70
- // → pressed
71
- // ↑ pressed
67
+ // ↑ changed: true
68
+ // → changed: true
69
+ // ↑ changed: false
72
70
 
73
71
  // `input` events are triggered whenever there is new information from the controller
74
72
  // Your Dualsense may provide over 250 `input` events per second, so use this sparingly
75
- // These events are not available for nested inputs, like the example above
73
+ // These events are not available for nested inputs, like in the example above
76
74
  controller.left.analog.x.on("input", console.log)
77
75
  ```
78
76
 
79
77
  - _Promises_: Wait for one-off inputs using `await`
80
78
 
81
79
  ```typescript
82
- // Resolves next time `dpad up` is released
83
- const { active } = await controller.dpad.up.promise("release");
80
+ // Wait for up to be pressed or released
81
+ const { active } = await controller.dpad.up.promise();
84
82
 
85
- // Wait for the next press of any dpad button
86
- const { left, up, down, right } = await controller.dpad.promise("press");
83
+ // Wait for the next change to any dpad button's state
84
+ const { left, up, down, right } = await controller.dpad.promise();
87
85
 
88
86
  // Wait for any input at all
89
87
  await controller.promise();
@@ -92,8 +90,8 @@ await controller.promise();
92
90
  - _Async Iterators_: Each input is an async iterator that provides state changes
93
91
 
94
92
  ```typescript
95
- for await (const { pressure } of controller.left.trigger) {
96
- console.log(`L2: ${Math.round(pressure*100)}%`);
93
+ for await (const { left, right, up, down } of controller.dpad) {
94
+ console.log(`dpad: ${left} ${up} ${down} ${right}`);
97
95
  }
98
96
  ```
99
97
 
package/docs/Indicator.md CHANGED
@@ -28,7 +28,7 @@
28
28
 
29
29
  #### Defined in
30
30
 
31
- [src/indicators/indicator.ts:6](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/indicators/indicator.ts#L6)
31
+ [src/indicators/indicator.ts:6](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/indicators/indicator.ts#L6)
32
32
 
33
33
  ## Methods
34
34
 
@@ -49,4 +49,4 @@
49
49
 
50
50
  #### Defined in
51
51
 
52
- [src/indicators/indicator.ts:8](https://github.com/nsfm/dualsense-ts/blob/8aeab4d/src/indicators/indicator.ts#L8)
52
+ [src/indicators/indicator.ts:8](https://github.com/nsfm/dualsense-ts/blob/ab67fa7/src/indicators/indicator.ts#L8)