An open API service indexing awesome lists of open source software.

https://github.com/brianneisler/evolution-drone

Node JS library for interfacing with Evolution Controller's Drone gamepad.
https://github.com/brianneisler/evolution-drone

Last synced: 4 months ago
JSON representation

Node JS library for interfacing with Evolution Controller's Drone gamepad.

Awesome Lists containing this project

README

        

# evolution-drone

evolution-drone is a node JS library for interfacing with
[Evolution Controller's Drone gamepad](http://www.evolutioncontrollers.com/).

This library provides a basic DeviceManager that continuously scans for Drone devices.
Once a device is detected, an event will be dispatched that contains the new Device
instance. You can then use this instance to connect to the Drone controller.

After you connect to a Device, that instance will then emit DeviceDataEvents that contain
details of how the controller is being used.

This library is a work in progress and a side hobby of mine. If you have interest in
contributing or specific requests, please feel free to open up an issue on github and
I will get back to you.

Latest Version `0.0.4`

NOTE: This documentation is still being written. If you click on a link and it
doesn't go anywhere, it's likely because that portion of the docs hasn't been
written yet. If there are parts of the docs you'd like us to focus on, feel
free to ask!

## Quick Examples

Using DeviceManager
```javascript
var evolution = require('evolution-drone');

var DeviceManager = evolution.DeviceManager;

var myDeviceManager = new DeviceManager();
myDeviceManager.addEventListener(DeviceManager.EventTypes.DEVICE_DETECTED, function(event) {
var device = event.getData().device;

// Use device!
});

myDeviceManager.addEventListener(DeviceManager.EventTypes.DEVICE_LOST, function(event) {
var device = event.getData().device;

// Device was lost, do what you must....
});

myDeviceManager.startScanningForDevices();
```

Connecting to a Device and listening for DeviceDataEvents
```javascript
var evolution = require('evolution-drone');
var DeviceDataEvent = evolution.DeviceDataEvent;
var DeviceManager = evolution.DeviceManager;

var myDeviceManager = new DeviceManager();
myDeviceManager.addEventListener(DeviceManager.EventTypes.DEVICE_DETECTED, function(event) {
var device = event.getData().device;
device.addEventListener(DeviceDataEvent.EventTypes.DATA, function(event) {
console.log(event.getData());
});
device.connectToDevice();
});
myDeviceManager.startScanningForDevices();
```

## Dependencies

evolution-drone is dependent upon the following libraries
* [bugcore](https://github.com/airbug/bugcore)
* [bugpack](https://github.com/airbug/bugpack)
* [node-hid](https://github.com/node-hid/node-hid)

## Download Source

The source is available for download from [GitHub](https://github.com/brianneisler/evolution-drone)

## Install

For node js, you can install using Node Package Manager [npm](https://www.npmjs.org/package/evolution-drone)

npm install evolution-drone

## Usage

In node js:

npm will install the bugcore, bugpack, and node-hide dependencies

```javascript
var drone = require('evolution-drone');

```

## Documentation

### Classes

* [`Device`](#Device)
* [`DeviceConnection`](#DeviceConnection)
* [`DeviceDataEvent`](#DeviceDataEvent)
* [`DeviceManager`](#DeviceManager)
* [`DeviceService`](#DeviceService)



## Device

Class used to represent a detected Drone device.

__Class__

```javascript
/**
* @class
* @extends {EventDispatcher}
*/
var Device = Class.extend(EventDispatcher, {

_name: "evolution.Device",
```
[View code](https://github.com/brianneisler/evolution-drone/blob/v0.0.4/libraries/evolution-drone/js/src/core/Device.js)

__Extends__

* [`EventDispatcher`](https://github.com/airbug/bugcore#EventDispatcher)

__Constructor Summary__

Access | Signature
--- | ---
constructor | [Device](#Device_constructor)({{interface: number, manufacturer: string, path: string, product: string, productId: string, release: number, serialNumber: string, vendorId: string}} hidDevice)

__Getters and Setters Summary__

Access | Signature | Return Type
--- | --- | ---
public | [getConnected](#Device_getConnected)() | {boolean}
public | [getConnection](#Device_getConnection)() | {[DeviceConnection](#DeviceConnection)}
public | [setConnection](#Device_setConnection)({[DeviceConnection](#DeviceConnection)} deviceConnection) | None
public | [getInterface](#Device_getInterface)() | {number}
public | [getManufacturer](#Device_getManufacturer)() | {string}
public | [getPath](#Device_getPath)() | {string}
public | [getProduct](#Device_getProduct)() | {string}
public | [getProductId](#Device_getProductId)() | {string}
public | [getRelease](#Device_getRelease)() | {number}
public | [getSerialNumber](#Device_getSerialNumber)() | {string}
public | [getVendorId](#Device_getVendorId)() | {string}

__Method Summary__

Access | Signature | Return Type
--- | --- | ---
public | [connectToDevice](#Device_connectToDevice)() | None
public | [disconnectFromDevice](#Device_disconnectFromDevice)() | None



------------------------------------------------------------------------------------


### Device(hidDevice)

The constructor for a Device

__Method__

```javascript
/**
* @constructs
* @param {{
* interface: number,
* manufacturer: string,
* path: string,
* product: string,
* productId: string,
* release: number,
* serialNumber: string,
* vendorId: string
* }} hidDevice
*/
_constructor: function(hidDevice) {
```

__Parameters__

Name | Type | Description
--- | --- | ---
`hidDevice` | {{interface: number, manufacturer: string, path: string, product: string, productId: string, release: number, serialNumber: string, vendorId: string}} | The hid device that was output by node-hid

__Examples__

Instantiating a Device using node-hid
```js
var hid = require('node-hid');
var devices = hid.devices();
var myDevice = new Device(devices[0]);
```



------------------------------------------------------------------------------------


### Device#getConnected()

Get whether or not a connection is open with this Device

__Method__

```javascript
/**
* @return {boolean}
*/
getConnected: function() {
```

__Parameters__

* None

__Returns__

* {boolean} - Whether or not a connection is open with the Device.

__Examples__

```javascript
var myDevice = new Device(devices[0]);
myDevice.getConnected(); // false, Devices do not automatically have a connection open when they're detected.
```



------------------------------------------------------------------------------------


### Device#getConnection()

Get the connection open with this Device, if one has been opened.

__Method__

```javascript
/**
* @return {DeviceConnection}
*/
getConnection: function() {
```

__Parameters__

* None

__Returns__

* {DeviceConnection} - The connection open with this Device.

__Examples__

Device does not have a connection when it is instantiated
```javascript
var device = new Device();
device.getConnection(); // null
```

Device does not have a connection when it is first detected
```javascript
myDeviceManager.addEventListener(DeviceManager.EventTypes.DEVICE_DETECTED, function(event) {
var device = event.getData().device;
device.getConnection() // null
});
```

Device has connection after connectToDevice is called
```javascript
myDeviceManager.addEventListener(DeviceManager.EventTypes.DEVICE_DETECTED, function(event) {
var device = event.getData().device;
device.connectToDevice();
device.getConnection() // {DeviceConnection}
});
```



## DeviceConnection

Class used to represent a connection to a Drone device.

__Class__

```javascript
/**
* @class
* @extends {EventDispatcher}
*/
var DeviceConnection = Class.extend(EventDispatcher, {

_name: "evolution.DeviceConnection",
```
[View code](https://github.com/brianneisler/evolution-drone/blob/v0.0.4/libraries/evolution-drone/js/src/core/DeviceConnection.js)

__Extends__

* [`EventDispatcher`](https://github.com/airbug/bugcore#EventDispatcher)

__Constructor Summary__

Access | Signature
--- | ---
constructor | [DeviceConnection](#DeviceConnection_constructor)({[HID](https://github.com/node-hid/node-hid#complete-api)} hidConnection)

__Getters and Setters Summary__

Access | Signature | Return Type
--- | --- | ---
public | [getHidConnection](#DeviceConnection_getHidConnection)() | {[HID](https://github.com/node-hid/node-hid#complete-api)}

__Method Summary__

Access | Signature | Return Type
--- | --- | ---
public | [closeConnection](#DeviceConnection_closeConnection)() | None
public | [destroyConnection](#DeviceConnection_destroyConnection)() | None



------------------------------------------------------------------------------------



## DeviceDataEvent

Class used to represent a data event from the Drone device.

__Class__

```javascript
/**
* @class
* @extends {Event}
*/
var DeviceDataEvent = Class.extend(Event, /** @lends {DeviceDataEvent.prototype} */{

_name: "evolution.DeviceDataEvent",
```
[View code](https://github.com/brianneisler/evolution-drone/blob/v0.0.4/libraries/evolution-drone/js/src/core/events/DeviceDataEvent.js)

__Extends__

* [`Event`](https://github.com/airbug/bugcore#Event)

__Constructor Summary__

Access | Signature
--- | ---
constructor | [DeviceDataEvent](#DeviceDataEvent_constructor)({string} type, {*} data)

__Getters and Setters Summary__

Access | Signature | Return Type
--- | --- | ---
public | [getData](#DeviceDataEvent_getData)() | {{a: boolean, b: boolean, x: boolean, y: boolean, lb: boolean, rb: boolean, lt: boolean, rt: boolean, select: boolean, start: boolean, dup: boolean, dleft: boolean, dright: boolean, ddown: boolean, leftStick: { x: number, y: number, pressed: boolean }, rightStick: { x: number, y: number, pressed: boolean }}}

__Method Summary__

Access | Signature | Return Type
--- | --- | ---
public | [getLeftStick](#DeviceDataEvent_getLeftStick)() | {{ x: number, y: number, pressed: boolean }}
public | [getLeftStickX](#DeviceDataEvent_getLeftStickX)() | {number}
public | [getLeftStickY](#DeviceDataEvent_getLeftStickY)() | {number}
public | [getRightStick](#DeviceDataEvent_getRightStick)() | {{ x: number, y: number, pressed: boolean }}
public | [getRightStickX](#DeviceDataEvent_getRightStickX)() | {number}
public | [getRightStickY](#DeviceDataEvent_getRightStickY)() | {number}
public | [isAButtonPressed](#DeviceDataEvent_isAButtonPressed)() | {boolean}
public | [isBButtonPressed](#DeviceDataEvent_isBButtonPressed)() | {boolean}
public | [isDirectionDownPressed](#DeviceDataEvent_isDirectionDownPressed)() | {boolean}
public | [isDirectionLeftPressed](#DeviceDataEvent_isDirectionLeftPressed)() | {boolean}
public | [isDirectionRightPressed](#DeviceDataEvent_isDirectionRightPressed)() | {boolean}
public | [isDirectionUpPressed](#DeviceDataEvent_isDirectionUpPressed)() | {boolean}
public | [isLeftBumperPressed](#DeviceDataEvent_isLeftBumperPressed)() | {boolean}
public | [isLeftStickPressed](#DeviceDataEvent_isLeftStickPressed)() | {boolean}
public | [isLeftTriggerPressed](#DeviceDataEvent_isLeftTriggerPressed)() | {boolean}
public | [isRightBumperPressed](#DeviceDataEvent_isRightBumperPressed)() | {boolean}
public | [isRightStickPressed](#DeviceDataEvent_isRightStickPressed)() | {boolean}
public | [isRightTriggerPressed](#DeviceDataEvent_isRightTriggerPressed)() | {boolean}
public | [isSelectButtonPressed](#DeviceDataEvent_isSelectButtonPressed)() | {boolean}
public | [isStartButtonPressed](#DeviceDataEvent_isStartButtonPressed)() | {boolean}
public | [isXButtonPressed](#DeviceDataEvent_isXButtonPressed)() | {boolean}
public | [isYButtonPressed](#DeviceDataEvent_isYButtonPressed)() | {boolean}



------------------------------------------------------------------------------------



## DeviceManager

TODO



## DeviceService

TODO