@sensslen/node-gamepad 1.0.8-beta.17 → 1.0.8-beta.19
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/README.md +38 -38
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,60 +1,63 @@
|
|
|
1
1
|
# node-gamepad [](https://www.codefactor.io/repository/github/sensslen/node-gamepad)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
`node-gamepad` is a Node.js package for interfacing your applications with a variety of gamepad controllers. It is written in TypeScript and provides type definitions for a better development experience.
|
|
4
|
+
|
|
5
|
+
> **Note:** XBOX 360 Controllers (and all of their derivatives) are known to behave badly and are **not supported** by this library.
|
|
5
6
|
|
|
6
7
|
## Installation
|
|
7
8
|
|
|
8
|
-
```
|
|
9
|
+
```sh
|
|
9
10
|
npm install @sensslen/node-gamepad
|
|
10
11
|
```
|
|
11
12
|
|
|
12
13
|
### Supported Controllers
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
1. logitech/gamepadf710
|
|
23
|
-
1. microsoft/sidewinder-precision-2
|
|
15
|
+
The following controllers are actively maintained and tested:
|
|
16
|
+
|
|
17
|
+
- Logitech Rumblepad 2
|
|
18
|
+
- Logitech Gamepad F310
|
|
19
|
+
- Logitech Gamepad F710
|
|
20
|
+
|
|
21
|
+
You can also create your own controller definitions by providing a custom configuration to the constructor. Contributions for additional controller support are welcome!
|
|
22
|
+
|
|
24
23
|
|
|
25
24
|
## How to Use
|
|
26
25
|
|
|
27
|
-
Plug in a supported controller and run a variation of the code below (with an actual supported controller).
|
|
28
|
-
Slternatively you can also run the code below and then plug in a supported controller.
|
|
26
|
+
Plug in a supported controller and run a variation of the code below (with an actual supported controller). Alternatively, you can also run the code below and then plug in a supported controller.
|
|
29
27
|
|
|
30
|
-
###
|
|
28
|
+
### TypeScript Example
|
|
31
29
|
|
|
32
30
|
```ts
|
|
33
|
-
import { NodeGamepad } from 'node-gamepad';
|
|
34
|
-
import * as f310 from 'node-gamepad/controllers/logitech/gamepadf310';
|
|
31
|
+
import { NodeGamepad } from '@sensslen/node-gamepad';
|
|
32
|
+
import * as f310 from '@sensslen/node-gamepad/controllers/logitech/gamepadf310';
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
const gamepad = new NodeGamepad(f310);
|
|
37
35
|
|
|
38
36
|
gamepad.start();
|
|
39
37
|
|
|
40
|
-
gamepad.on('connected',
|
|
41
|
-
|
|
38
|
+
gamepad.on('connected', () => {
|
|
39
|
+
console.log('connected');
|
|
42
40
|
});
|
|
43
|
-
gamepad.on('disconnected',
|
|
44
|
-
|
|
41
|
+
gamepad.on('disconnected', () => {
|
|
42
|
+
console.log('disconnected');
|
|
45
43
|
});
|
|
46
44
|
|
|
47
|
-
gamepad.on('up:press',
|
|
48
|
-
|
|
45
|
+
gamepad.on('up:press', () => {
|
|
46
|
+
console.log('up');
|
|
49
47
|
});
|
|
50
|
-
gamepad.on('down:press',
|
|
51
|
-
|
|
48
|
+
gamepad.on('down:press', () => {
|
|
49
|
+
console.log('down');
|
|
52
50
|
});
|
|
53
51
|
|
|
54
|
-
//
|
|
55
|
-
//
|
|
52
|
+
// Don't forget to stop when you are finished:
|
|
53
|
+
// gamepad.stop();
|
|
54
|
+
// The gamepad class also registers for app termination just in case.
|
|
56
55
|
```
|
|
57
56
|
|
|
57
|
+
|
|
58
|
+
> **Note:** Type definitions are included for all event handlers and configuration objects. JavaScript users also benefit from improved autocompletion and documentation in modern editors.
|
|
59
|
+
|
|
60
|
+
|
|
58
61
|
## Supported Events
|
|
59
62
|
|
|
60
63
|
This package supports up to 3 different types of components: joysticks, buttons and statuses (like battery level, charging, etc). It's possible that a controller could make use of all 3 different components or even introduce additional components. The idea here is the dictionary file will dictate how the controller will be used and how to read data from it.
|
|
@@ -74,19 +77,16 @@ A status value is read from a pin on the hardware and then can be mapped to a "s
|
|
|
74
77
|
|
|
75
78
|
1. `{name}:change`
|
|
76
79
|
|
|
80
|
+
|
|
77
81
|
## Contributing Controllers
|
|
78
82
|
|
|
79
|
-
Please feel free to provide your own custom controller
|
|
80
|
-
configurations to the constructor. It would b highly appreciated if you make the configuration publically available by opening a pull request.
|
|
81
83
|
|
|
82
|
-
|
|
84
|
+
You are welcome to provide your own custom controller configurations to the constructor. Contributions of new controller definitions are highly appreciated. Please consider making them publicly available by opening a pull request.
|
|
83
85
|
|
|
84
|
-
|
|
86
|
+
---
|
|
85
87
|
|
|
86
|
-
|
|
88
|
+
> **Note:** This project is written in [TypeScript](https://www.typescriptlang.org/), providing type definitions and improved editor support. It can be used from both TypeScript and JavaScript projects. Type definitions are included for all event handlers and configuration objects. JavaScript users also benefit from improved autocompletion and documentation in modern editors.
|
|
87
89
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
90
|
+
## License
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sensslen/node-gamepad",
|
|
3
|
-
"version": "1.0.8-beta.
|
|
3
|
+
"version": "1.0.8-beta.19",
|
|
4
4
|
"description": "node-gamepad is a package for node that allows you to effortlessly interface your node applications with a variety of gamepad controllers. This is a port of node-gamepad library to typescript by also removing some of the restrictions implied by this library (namely allowing gamepads to be subcleassed and also improving usb interaction)",
|
|
5
5
|
"homepage": "https://github.com/sensslen/node-gamepad",
|
|
6
6
|
"bugs": {
|