@sensslen/node-gamepad 1.0.3-beta.3 → 1.0.3-beta.7

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/NodeGamepad.d.ts CHANGED
@@ -22,7 +22,7 @@ export declare class NodeGamepad extends EventEmitter {
22
22
  private log;
23
23
  private connect;
24
24
  private stopConnectionProcess;
25
- private registerStopProgramStopEvent;
25
+ private registerProgramExitEvents;
26
26
  private disconnect;
27
27
  private toIDeviceSpec;
28
28
  private onControllerFrame;
package/NodeGamepad.js CHANGED
@@ -25,6 +25,7 @@ var NodeGamepad = /** @class */ (function (_super) {
25
25
  var _this = _super.call(this) || this;
26
26
  _this.config = config;
27
27
  _this.logger = logger;
28
+ _this._usb = undefined;
28
29
  _this._stopped = false;
29
30
  _this._joystickStates = {};
30
31
  _this._buttonStates = {};
@@ -35,15 +36,13 @@ var NodeGamepad = /** @class */ (function (_super) {
35
36
  }
36
37
  NodeGamepad.prototype.start = function () {
37
38
  this.log("Starting connection procedure to device:" + JSON.stringify(this.toIDeviceSpec(this.config)));
38
- this.registerStopProgramStopEvent();
39
+ this.registerProgramExitEvents();
39
40
  this.connect();
40
41
  };
41
42
  NodeGamepad.prototype.stop = function () {
42
43
  if (!this._stopped) {
43
- this.log('stopping');
44
44
  this.stopConnectionProcess();
45
45
  this.disconnect();
46
- this.log('stopped');
47
46
  this._stopped = true;
48
47
  }
49
48
  };
@@ -84,6 +83,7 @@ var NodeGamepad = /** @class */ (function (_super) {
84
83
  this.logDebug("connecting to:" + JSON.stringify(deviceToConnectTo));
85
84
  try {
86
85
  this._usb = new node_hid_1.HID(deviceToConnectTo.path);
86
+ this._usb.setNonBlocking(true);
87
87
  this.log('connected');
88
88
  this.emit('connected');
89
89
  this._connectRetryTimeout = undefined;
@@ -110,11 +110,9 @@ var NodeGamepad = /** @class */ (function (_super) {
110
110
  this._connectRetryTimeout = undefined;
111
111
  }
112
112
  };
113
- NodeGamepad.prototype.registerStopProgramStopEvent = function () {
113
+ NodeGamepad.prototype.registerProgramExitEvents = function () {
114
114
  var _this = this;
115
- process.on('SIGINT', function () { return _this.stop(); });
116
115
  process.on('exit', function () { return _this.stop(); });
117
- process.on('uncaughtException', function () { return _this.stop(); });
118
116
  };
119
117
  NodeGamepad.prototype.disconnect = function () {
120
118
  if (this._usb) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sensslen/node-gamepad",
3
- "version": "1.0.3-beta.3",
3
+ "version": "1.0.3-beta.7",
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": {