npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cylon-joystick-node-4-and-5

v0.20.0

Published

Cylon module for any HID joystick

Downloads

23

Readme

Cylon.js for Joysticks and Controllers

NOTE: This module will be deprecated when the cylon-joystick supports node 4 and 5.

Cylon.js (http://cylonjs.com) is a JavaScript framework for robotics, physical computing, and the Internet of Things (IoT).

This repository contains the adaptor/driver for communicating with joysticks and game controllers. It can be used with any [SDL][http://www.libsdl.org/]-compatible controller.

Default bindings are provided for the Xbox 360, DualShock 3, DualShock 4, and Logitech F310 controllers.

The cylon-gamepad implementation is made possible by the gamepad module https://github.com/creationix/node-gamepad created by @creationix thank you!

Want to use Ruby on robots? Check out our sister project Artoo (http://artoo.io)

Want to use the Go programming language to power your robots? Check out our sister project Gobot (http://gobot.io).

Build Status Code Climate Test Coverage

How to Install

Installing Cylon.js with Joystick support is pretty easy.

$ npm install cylon cylon-joystick

Note

  • OS X does not provide native support for Xbox 360 controllers. As such, a third-party driver is required.
  • If you're using a PS3 controller and want to communicate with it over USB, plug it in and then press the PlayStation button to make sure it's connected.

How to Use

var Cylon = require('cylon');

Cylon.robot({
  connections: {
    joystick: { adaptor: 'joystick' }
  },

  devices: {
    controller: { driver: 'dualshock-3' }
  },

  work: function(my) {
    ["square", "circle", "x", "triangle"].forEach(function(button) {
      my.controller.on(button + ":press", function() {
        console.log("Button " + button + " pressed.");
      });

      my.controller.on(button + ":release", function() {
        console.log("Button " + button + " released.");
      });
    });

    my.controller.on("left_x:move", function(pos) {
      console.log("Left Stick - X:", pos);
    });

    my.controller.on("right_x:move", function(pos) {
      console.log("Right Stick - X:", pos);
    });

    my.controller.on("left_y:move", function(pos) {
      console.log("Left Stick - Y:", pos);
    });

    my.controller.on("right_y:move", function(pos) {
      console.log("Right Stick - Y:", pos);
    });
  }
}).start();

How to Connect

Plug your USB joystick or game controller into your USB port. If your device is supported by SDL, you are now ready.

Custom joysticks

If you don't have one of the joysticks we support natively, or want to make changes to the configuration, cylon-joystick supports custom bindings.

To use a custom joystick with Cylon, simply supply the joystick bindings file when you're describing the device:

var Cylon = require('cylon');

var config = __dirname + "/controller.json"

Cylon.robot({
  connections: {
    joystick: { adaptor: 'joystick' }
  },

  devices: {
    controller: { driver: "joystick", config: config }
  },

  work: function(my) {
    // your custom mappings will be reflected here as events
  }
}).start();

A joystick bindings file needs to contain the device's productID and vendorID, as this is how cylon-joystick will find the appropriate device.

For an example of what a bindings file should look like, here is the Xbox 360 controller bindings file we use.

cylon-joystick-explorer

cylon-joystick includes the cylon-joystick-explorer binary. It's useful for figuring out what compatible gamepads you have connected, as well as making it easier to generate custom bindings JSON files.

For best use, install cylon-joystick globally:

$ npm install -g cylon-joystick

Then just run the command:

$ cylon-joystick-explorer

Documentation

We're busy adding documentation to our web site at http://cylonjs.com/ please check there as we continue to work on Cylon.js

Thank you!

Contributing

For our contribution guidelines, please go to https://github.com/hybridgroup/cylon/blob/master/CONTRIBUTING.md .

Release History

For the release history, please go to https://github.com/hybridgroup/cylon-joystick/blob/master/RELEASES.md .

License

Copyright (c) 2013-2016 The Hybrid Group. Licensed under the Apache 2.0 license.