dualsense-ts 2.0.2 → 2.0.13

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 (50) hide show
  1. package/dist/dualsense.d.ts.map +1 -1
  2. package/dist/dualsense.js +1 -0
  3. package/dist/dualsense.js.map +1 -1
  4. package/dist/elements/mute.d.ts +1 -0
  5. package/dist/elements/mute.d.ts.map +1 -1
  6. package/dist/elements/mute.js +1 -0
  7. package/dist/elements/mute.js.map +1 -1
  8. package/dist/elements/unisense.d.ts.map +1 -1
  9. package/dist/elements/unisense.js +5 -1
  10. package/dist/elements/unisense.js.map +1 -1
  11. package/docs/.nojekyll +1 -0
  12. package/docs/Accelerometer.md +13 -0
  13. package/docs/Analog.md +1712 -0
  14. package/docs/AnalogParams.md +105 -0
  15. package/docs/Axis.md +1577 -0
  16. package/docs/Brightness.md +39 -0
  17. package/docs/CommandScopeA.md +83 -0
  18. package/docs/CommandScopeB.md +72 -0
  19. package/docs/Dpad.md +1591 -0
  20. package/docs/DpadParams.md +116 -0
  21. package/docs/DualSenseCommand.md +1448 -0
  22. package/docs/Dualsense.md +1690 -0
  23. package/docs/DualsenseHID.md +1158 -0
  24. package/docs/DualsenseHIDState.md +457 -0
  25. package/docs/DualsenseParams.md +215 -0
  26. package/docs/Exports.md +214 -0
  27. package/docs/Gyroscope.md +13 -0
  28. package/docs/Haptic.md +27 -0
  29. package/docs/Home.md +105 -0
  30. package/docs/Indicator.md +52 -0
  31. package/docs/Input.md +1382 -0
  32. package/docs/InputId.md +457 -0
  33. package/docs/InputParams.md +62 -0
  34. package/docs/LedOptions.md +50 -0
  35. package/docs/Momentary.md +1549 -0
  36. package/docs/Motion.md +38 -0
  37. package/docs/Mute.md +1569 -0
  38. package/docs/PlayerID.md +61 -0
  39. package/docs/PulseOptions.md +39 -0
  40. package/docs/Touchpad.md +1613 -0
  41. package/docs/Trigger.md +1620 -0
  42. package/docs/TriggerMode.md +116 -0
  43. package/docs/Unisense.md +1591 -0
  44. package/docs/UnisenseParams.md +105 -0
  45. package/docs/_Sidebar.md +4 -0
  46. package/package.json +7 -2
  47. package/src/dualsense.ts +1 -0
  48. package/src/elements/mute.ts +1 -0
  49. package/src/elements/unisense.ts +5 -1
  50. package/tsconfig.json +10 -1
@@ -0,0 +1,214 @@
1
+ # dualsense-ts
2
+
3
+ ## Table of contents
4
+
5
+ ### Enumerations
6
+
7
+ - [Brightness](../wiki/Brightness)
8
+ - [CommandScopeA](../wiki/CommandScopeA)
9
+ - [CommandScopeB](../wiki/CommandScopeB)
10
+ - [InputId](../wiki/InputId)
11
+ - [LedOptions](../wiki/LedOptions)
12
+ - [PlayerID](../wiki/PlayerID)
13
+ - [PulseOptions](../wiki/PulseOptions)
14
+ - [TriggerMode](../wiki/TriggerMode)
15
+
16
+ ### Classes
17
+
18
+ - [Accelerometer](../wiki/Accelerometer)
19
+ - [Analog](../wiki/Analog)
20
+ - [Axis](../wiki/Axis)
21
+ - [Dpad](../wiki/Dpad)
22
+ - [Dualsense](../wiki/Dualsense)
23
+ - [DualsenseHID](../wiki/DualsenseHID)
24
+ - [Gyroscope](../wiki/Gyroscope)
25
+ - [Haptic](../wiki/Haptic)
26
+ - [Indicator](../wiki/Indicator)
27
+ - [Input](../wiki/Input)
28
+ - [Momentary](../wiki/Momentary)
29
+ - [Motion](../wiki/Motion)
30
+ - [Mute](../wiki/Mute)
31
+ - [Touchpad](../wiki/Touchpad)
32
+ - [Trigger](../wiki/Trigger)
33
+ - [Unisense](../wiki/Unisense)
34
+
35
+ ### Interfaces
36
+
37
+ - [AnalogParams](../wiki/AnalogParams)
38
+ - [DpadParams](../wiki/DpadParams)
39
+ - [DualSenseCommand](../wiki/DualSenseCommand)
40
+ - [DualsenseHIDState](../wiki/DualsenseHIDState)
41
+ - [DualsenseParams](../wiki/DualsenseParams)
42
+ - [InputParams](../wiki/InputParams)
43
+ - [UnisenseParams](../wiki/UnisenseParams)
44
+
45
+ ### Type Aliases
46
+
47
+ - [Degrees](../wiki/Exports#degrees)
48
+ - [Force](../wiki/Exports#force)
49
+ - [InputEvent](../wiki/Exports#inputevent)
50
+ - [Intensity](../wiki/Exports#intensity)
51
+ - [Magnitude](../wiki/Exports#magnitude)
52
+ - [Radians](../wiki/Exports#radians)
53
+
54
+ ### Variables
55
+
56
+ - [InputChanged](../wiki/Exports#inputchanged)
57
+ - [InputIcon](../wiki/Exports#inputicon)
58
+ - [InputName](../wiki/Exports#inputname)
59
+ - [InputSet](../wiki/Exports#inputset)
60
+
61
+ ### Functions
62
+
63
+ - [mapAxis](../wiki/Exports#mapaxis)
64
+ - [mapTrigger](../wiki/Exports#maptrigger)
65
+
66
+ ## Type Aliases
67
+
68
+ ### Degrees
69
+
70
+ Ƭ **Degrees**: `number`
71
+
72
+ A numeric value between 0 and 360.
73
+
74
+ #### Defined in
75
+
76
+ [src/math.ts:9](https://github.com/nsfm/dualsense-ts/blob/29d69a7/src/math.ts#L9)
77
+
78
+ ___
79
+
80
+ ### Force
81
+
82
+ Ƭ **Force**: `number`
83
+
84
+ A numeric value between -1 and 1.
85
+
86
+ #### Defined in
87
+
88
+ [src/math.ts:19](https://github.com/nsfm/dualsense-ts/blob/29d69a7/src/math.ts#L19)
89
+
90
+ ___
91
+
92
+ ### InputEvent
93
+
94
+ Ƭ **InputEvent**: ``"change"`` \| ``"input"`` \| ``"press"`` \| ``"release"``
95
+
96
+ #### Defined in
97
+
98
+ [src/input.ts:34](https://github.com/nsfm/dualsense-ts/blob/29d69a7/src/input.ts#L34)
99
+
100
+ ___
101
+
102
+ ### Intensity
103
+
104
+ Ƭ **Intensity**: `number`
105
+
106
+ A numeric value between 0 and 1.
107
+
108
+ #### Defined in
109
+
110
+ [src/math.ts:24](https://github.com/nsfm/dualsense-ts/blob/29d69a7/src/math.ts#L24)
111
+
112
+ ___
113
+
114
+ ### Magnitude
115
+
116
+ Ƭ **Magnitude**: `number`
117
+
118
+ A numeric value between 0 and 1.
119
+
120
+ #### Defined in
121
+
122
+ [src/math.ts:14](https://github.com/nsfm/dualsense-ts/blob/29d69a7/src/math.ts#L14)
123
+
124
+ ___
125
+
126
+ ### Radians
127
+
128
+ Ƭ **Radians**: `number`
129
+
130
+ A numeric value between ±Math.PI.
131
+
132
+ #### Defined in
133
+
134
+ [src/math.ts:4](https://github.com/nsfm/dualsense-ts/blob/29d69a7/src/math.ts#L4)
135
+
136
+ ## Variables
137
+
138
+ ### InputChanged
139
+
140
+ • `Const` **InputChanged**: typeof [`InputChanged`](../wiki/Exports#inputchanged)
141
+
142
+ #### Defined in
143
+
144
+ [src/input.ts:27](https://github.com/nsfm/dualsense-ts/blob/29d69a7/src/input.ts#L27)
145
+
146
+ ___
147
+
148
+ ### InputIcon
149
+
150
+ • `Const` **InputIcon**: typeof [`InputIcon`](../wiki/Exports#inputicon)
151
+
152
+ #### Defined in
153
+
154
+ [src/input.ts:32](https://github.com/nsfm/dualsense-ts/blob/29d69a7/src/input.ts#L32)
155
+
156
+ ___
157
+
158
+ ### InputName
159
+
160
+ • `Const` **InputName**: typeof [`InputName`](../wiki/Exports#inputname)
161
+
162
+ #### Defined in
163
+
164
+ [src/input.ts:31](https://github.com/nsfm/dualsense-ts/blob/29d69a7/src/input.ts#L31)
165
+
166
+ ___
167
+
168
+ ### InputSet
169
+
170
+ • `Const` **InputSet**: typeof [`InputSet`](../wiki/Exports#inputset)
171
+
172
+ #### Defined in
173
+
174
+ [src/input.ts:30](https://github.com/nsfm/dualsense-ts/blob/29d69a7/src/input.ts#L30)
175
+
176
+ ## Functions
177
+
178
+ ### mapAxis
179
+
180
+ ▸ **mapAxis**(`value`): `number`
181
+
182
+ #### Parameters
183
+
184
+ | Name | Type |
185
+ | :------ | :------ |
186
+ | `value` | `number` |
187
+
188
+ #### Returns
189
+
190
+ `number`
191
+
192
+ #### Defined in
193
+
194
+ [src/hid/dualsense_hid.ts:51](https://github.com/nsfm/dualsense-ts/blob/29d69a7/src/hid/dualsense_hid.ts#L51)
195
+
196
+ ___
197
+
198
+ ### mapTrigger
199
+
200
+ ▸ **mapTrigger**(`value`): `number`
201
+
202
+ #### Parameters
203
+
204
+ | Name | Type |
205
+ | :------ | :------ |
206
+ | `value` | `number` |
207
+
208
+ #### Returns
209
+
210
+ `number`
211
+
212
+ #### Defined in
213
+
214
+ [src/hid/dualsense_hid.ts:56](https://github.com/nsfm/dualsense-ts/blob/29d69a7/src/hid/dualsense_hid.ts#L56)
@@ -0,0 +1,13 @@
1
+ # Class: Gyroscope
2
+
3
+ ## Table of contents
4
+
5
+ ### Constructors
6
+
7
+ - [constructor](../wiki/Gyroscope#constructor)
8
+
9
+ ## Constructors
10
+
11
+ ### constructor
12
+
13
+ • **new Gyroscope**()
package/docs/Haptic.md ADDED
@@ -0,0 +1,27 @@
1
+ # Class: Haptic
2
+
3
+ ## Table of contents
4
+
5
+ ### Constructors
6
+
7
+ - [constructor](../wiki/Haptic#constructor)
8
+
9
+ ### Properties
10
+
11
+ - [vibration](../wiki/Haptic#vibration)
12
+
13
+ ## Constructors
14
+
15
+ ### constructor
16
+
17
+ • **new Haptic**()
18
+
19
+ ## Properties
20
+
21
+ ### vibration
22
+
23
+ • `Readonly` **vibration**: `number` = `0`
24
+
25
+ #### Defined in
26
+
27
+ [src/haptics/haptic.ts:4](https://github.com/nsfm/dualsense-ts/blob/29d69a7/src/haptics/haptic.ts#L4)
package/docs/Home.md ADDED
@@ -0,0 +1,105 @@
1
+ # dualsense-ts
2
+
3
+ This module provides a natural interface for your DualSense controller, so you can focus on input and forget about the device.
4
+
5
+ ## Getting started
6
+
7
+ ### Installation
8
+
9
+ This package is distributed via npm: [dualsense-ts](https://npmjs.org/package.dualsense-ts)
10
+
11
+ Install it using your preferred package manager:
12
+
13
+ - `yarn add dualsense-ts`
14
+ - `npm add dualsense-ts`
15
+
16
+ ### Connecting
17
+
18
+ By default, `dualsense-ts` will try to connect to the first Dualsense controller it finds.
19
+
20
+ ```typescript
21
+ import { Dualsense } from "dualsense-ts";
22
+
23
+ // Grab a controller connected via USB or Bluetooth
24
+ const controller = new Dualsense();
25
+ ```
26
+
27
+ ### Input
28
+
29
+ `dualsense-ts` provides several interfaces for reading input:
30
+
31
+ - _Synchronous_: It's safe to read the current input state at any time
32
+
33
+ ```typescript
34
+ // Buttons
35
+ controller.circle.active; // false
36
+ controller.cross.active; // true
37
+ controller.left.bumper.active; // true
38
+
39
+ // 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)
48
+ ```
49
+
50
+ - _Callbacks_: Each input is an EventEmitter that provides `input` or `change` events
51
+
52
+ ```typescript
53
+ // Change events are triggered only when an input's value changes
54
+ controller.triangle.on("change", (input) =>
55
+ console.log(`${input} changed: ${input.active}`)
56
+ );
57
+ // ▲ changed: true
58
+ // ▲ changed: false
59
+
60
+ controller.triangle.removeAllListeners();
61
+
62
+ // 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
66
+ );
67
+ // ↑ changed: true
68
+ // → changed: true
69
+ // ↑ changed: false
70
+
71
+ // `input` events are triggered whenever there is new information from the controller
72
+ // 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
74
+ controller.left.analog.x.on("input", console.log)
75
+ ```
76
+
77
+ - _Promises_: Wait for one-off inputs using `await`
78
+
79
+ ```typescript
80
+ // Wait for up to be pressed or released
81
+ const { active } = await controller.dpad.up.promise();
82
+
83
+ // Wait for the next change to any dpad button's state
84
+ const { left, up, down, right } = await controller.dpad.promise();
85
+
86
+ // Wait for any input at all
87
+ await controller.promise();
88
+ ```
89
+
90
+ - _Async Iterators_: Each input is an async iterator that provides state changes
91
+
92
+ ```typescript
93
+ for await (const { left, right, up, down } of controller.dpad) {
94
+ console.log(`dpad: ${left} ${up} ${down} ${right}`);
95
+ }
96
+ ```
97
+
98
+ ## Other features
99
+
100
+ Check out the [roadmap](./ROADMAP.md) for more info about upcoming features.
101
+
102
+ ## Credits
103
+
104
+ - [CamTosh](https://github.com/CamTosh)'s [node-dualsense](https://github.com/CamTosh/node-dualsense)
105
+ - [flok](https://github.com/flok)'s [pydualsense](https://github.com/flok/pydualsense)
@@ -0,0 +1,52 @@
1
+ # Class: Indicator
2
+
3
+ ## Table of contents
4
+
5
+ ### Constructors
6
+
7
+ - [constructor](../wiki/Indicator#constructor)
8
+
9
+ ### Properties
10
+
11
+ - [brightness](../wiki/Indicator#brightness)
12
+
13
+ ### Methods
14
+
15
+ - [setColor](../wiki/Indicator#setcolor)
16
+
17
+ ## Constructors
18
+
19
+ ### constructor
20
+
21
+ • **new Indicator**()
22
+
23
+ ## Properties
24
+
25
+ ### brightness
26
+
27
+ • `Readonly` **brightness**: `number` = `0`
28
+
29
+ #### Defined in
30
+
31
+ [src/indicators/indicator.ts:6](https://github.com/nsfm/dualsense-ts/blob/29d69a7/src/indicators/indicator.ts#L6)
32
+
33
+ ## Methods
34
+
35
+ ### setColor
36
+
37
+ ▸ **setColor**(`__namedParameters`, `controller`): `void`
38
+
39
+ #### Parameters
40
+
41
+ | Name | Type |
42
+ | :------ | :------ |
43
+ | `__namedParameters` | `Uint8Array` |
44
+ | `controller` | `HID` |
45
+
46
+ #### Returns
47
+
48
+ `void`
49
+
50
+ #### Defined in
51
+
52
+ [src/indicators/indicator.ts:8](https://github.com/nsfm/dualsense-ts/blob/29d69a7/src/indicators/indicator.ts#L8)