Nationwide Polamorous Matrimony

    evolution-drone

    0.0.4 • Public • Published

    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;
     
        // 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

    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

    /**
     * @class
     * @extends {EventDispatcher} 
     */
    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

    Access Signature Return Type
    public getConnected() {boolean}
    public getConnection() {DeviceConnection}
    public setConnection({DeviceConnection} deviceConnection) None
    public getInterface() {number}
    public getManufacturer() {string}
    public getPath() {string}
    public getProduct() {string}
    public getProductId() {string}
    public getRelease() {number}
    public getSerialNumber() {string}
    public getVendorId() {string}

    Method Summary

    Access Signature Return Type
    public connectToDevice() None
    public disconnectFromDevice() None



    ### Device(hidDevice)

    The constructor for a Device

    Method

    /**
     * @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

    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

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

    Parameters

    • None

    Returns

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

    Examples

    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

    /**
     * @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

    var device = new Device();
    device.getConnection();         // null

    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()      // null
    });

    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}
    });


    DeviceConnection

    Class used to represent a connection to a Drone device.

    Class

    /**
     * @class
     * @extends {EventDispatcher} 
     */
    var DeviceConnection = Class.extend(EventDispatcher, {
     
        _name: "evolution.DeviceConnection",

    View code

    Extends

    Constructor Summary

    Access Signature
    constructor DeviceConnection({HID} hidConnection)

    Getters and Setters Summary

    Access Signature Return Type
    public getHidConnection() {HID}

    Method Summary

    Access Signature Return Type
    public closeConnection() None
    public destroyConnection() None




    DeviceDataEvent

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

    Class

    /**
     * @class
     * @extends {Event} 
     */
    var DeviceDataEvent = Class.extend(Event, /** @lends {DeviceDataEvent.prototype} */{
     
        _name: "evolution.DeviceDataEvent",

    View code

    Extends

    Constructor Summary

    Access Signature
    constructor DeviceDataEvent({string} type, {*} data)

    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

    Access Signature Return Type
    public getLeftStick() {{ x: number, y: number, pressed: boolean }}
    public getLeftStickX() {number}
    public getLeftStickY() {number}
    public getRightStick() {{ x: number, y: number, pressed: boolean }}
    public getRightStickX() {number}
    public getRightStickY() {number}
    public isAButtonPressed() {boolean}
    public isBButtonPressed() {boolean}
    public isDirectionDownPressed() {boolean}
    public isDirectionLeftPressed() {boolean}
    public isDirectionRightPressed() {boolean}
    public isDirectionUpPressed() {boolean}
    public isLeftBumperPressed() {boolean}
    public isLeftStickPressed() {boolean}
    public isLeftTriggerPressed() {boolean}
    public isRightBumperPressed() {boolean}
    public isRightStickPressed() {boolean}
    public isRightTriggerPressed() {boolean}
    public isSelectButtonPressed() {boolean}
    public isStartButtonPressed() {boolean}
    public isXButtonPressed() {boolean}
    public isYButtonPressed() {boolean}




    DeviceManager

    TODO


    DeviceService

    TODO

    Keywords

    none

    Install

    npm i evolution-drone

    DownloadsWeekly Downloads

    3

    Version

    0.0.4

    License

    none

    Last publish

    Collaborators

    • brianneisler