evolution-drone
evolution-drone is a node JS library for interfacing with
Evolution Controller's Drone gamepad.
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.3
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
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;
});
myDeviceManager.addEventListener(DeviceManager.EventTypes.DEVICE_LOST, function(event) {
var device = event.getData().device;
});
myDeviceManager.startScanningForDevices();
Connecting to a Device and listening for DeviceDataEvents
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
Download Source
The source is available for download from GitHub
Install
For node js, you can install using Node Package Manager npm
npm install evolution-drone
Usage
In node js:
npm will install the bugcore, bugpack, and node-hide dependencies
var drone = require('evolution-drone');
Documentation
Classes
Device
Class used to represent a detected Drone device.
Class
var Device = Class.extend(EventDispatcher, {
_name: "evolution.Device",
View code
Extends
Constructor Summary
Access | Signature |
---|
constructor | Device({{interface: number, manufacturer: string, path: string, product: string, productId: string, release: number, serialNumber: string, vendorId: string}} hidDevice) |
Getters and Setters Summary
Method Summary
------------------------------------------------------------------------------------
### Device(hidDevice)
The constructor for a Device
Method
_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
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
getConnected: function() {
Parameters
Returns
{boolean}
- Whether or not a connection is open with the Device.
Examples
var myDevice = new Device(devices[0]);
myDevice.getConnected();
------------------------------------------------------------------------------------
### Device#getConnection()
Get the connection open with this Device, if one has been opened.
Method
getConnection: function() {
Parameters
Returns
{DeviceConnection}
- The connection open with this Device.
Examples
Device does not have a connection when it is instantiated
var device = new Device();
device.getConnection();
Device does not have a connection when it is first detected
myDeviceManager.addEventListener(DeviceManager.EventTypes.DEVICE_DETECTED, function(event) {
var device = event.getData().device;
device.getConnection()
});
Device has connection after connectToDevice is called
myDeviceManager.addEventListener(DeviceManager.EventTypes.DEVICE_DETECTED, function(event) {
var device = event.getData().device;
device.connectToDevice();
device.getConnection()
});
DeviceConnection
Class used to represent a connection to a Drone device.
Class
var DeviceConnection = Class.extend(EventDispatcher, {
_name: "evolution.DeviceConnection",
View code
Extends
Constructor Summary
Getters and Setters Summary
Method Summary
------------------------------------------------------------------------------------
DeviceDataEvent
Class used to represent a data event from the Drone device.
Class
var DeviceDataEvent = Class.extend(Event, {
_name: "evolution.DeviceDataEvent",
View code
Extends
Constructor Summary
Getters and Setters Summary
Access | Signature | Return Type |
---|
public | 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
------------------------------------------------------------------------------------
DeviceManager
TODO
DeviceService
TODO