dualsense-ts 2.0.13 → 2.1.30

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