GithubHelp home page GithubHelp logo

nvdnkpr / node-joystick-logitech-f710 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from janpieper/node-joystick-logitech-f710

0.0 2.0 0.0 264 KB

Node.js module to read joystick data from Logitech Gamepad F710

License: The Unlicense

node-joystick-logitech-f710's Introduction

Logitech Gamepad F710

Node.js module to read joystick data from Logitech Gamepad F710.

Build Status NPM version

Installation

Using NPM

npm install node-joystick-logitech-f710

Example

var Joystick = require("joystick-logitech-f710");

Joystick.create("/dev/input/js0", function (err, joystick) {
  if (err) {
    throw err;
  }

  joystick.on("button:a:press", function () {
    console.log("jump");
  });

  joystick.on("button:b:press", function () {
    console.log("fire");
  });
});

Available Events

Buttons

  • Button A
    • button:a:press
    • button:a:release
  • Button B
    • button:b:press
    • button:b:release
  • Button X
    • button:x:press
    • button:x:release
  • Button Y
    • button:y:press
    • button:y:release
  • Button LB
    • button:lb:press
    • button:lb:release
  • Button RB
    • button:rb:press
    • button:rb:release
  • Button LT
    • button:lt:press
    • button:lt:release
  • Button RT
    • button:rt:press
    • button:rt:release
  • Button Back
    • button:back:press
    • button:back:release
  • Button Start
    • button:start:press
    • button:start:release
  • Left Stick
    • button:ls:press
    • button:ls:release
  • Right Stick
    • button:rs:press
    • button:rs:release

Example

joystick.on("button:start:press", function () {
  console.log("start button has been pressed");
});

Sticks

  • Cross
    • stick:1:vertical:up
    • stick:1:vertical:down
    • stick:1:vertical:zero
    • stick:1:horizontal:right
    • stick:1:horizontal:left
    • stick:1:horizontal:zero
  • Left Stick
    • stick:2:vertical:up
    • stick:2:vertical:down
    • stick:2:vertical:zero
    • stick:2:horizontal:right
    • stick:2:horizontal:left
    • stick:2:horizontal:zero
  • Right Stick
    • stick:3:vertical:up
    • stick:3:vertical:down
    • stick:3:vertical:zero
    • stick:3:horizontal:right
    • stick:3:horizontal:left
    • stick:3:horizontal:zero

Each of these events will be emitted with the current stick position. Possible position values (unscaled):

  • *:up = 1..32767
  • *:down = 1..32767
  • *:right = 1..32767
  • *:left = 1..32767
  • *:zero = 0

This should help to understand what values you can expect:

       32767
         |
32767 -- 0 -- 32767
         |
       32767

You can scale the maximum axes position to a value between 1 and 32767:

joystick.setMaximumAxesPosition(100);

Now you can expect the following position values:

        100
         |
  100 -- 0 -- 100
         |
        100

Example

joystick.on("stick:1:vertical:up", function (position) {
  console.log("current up position: " + position);
});

TODOs

  • Identify stick switch after pressing "Select" button to have more specific event names
  • Trigger gamepad vibration

node-joystick-logitech-f710's People

Contributors

janpieper avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.