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

logitech-dual-action-controller

v1.0.2

Published

Make a logitech gamepad do something useful

Downloads

7

Readme

Logitech Dual Action Controller for Node

Provides an EventEmitter with events for the buttons, dpad and analog sticks on the Logitech Dual Action Controller.

Heavily inspired by andrew/node-xbox-controller

Install

 npm install logitech-dual-action-controller

Usage

Step 1. Plug in the controller

Step 2. Add some event listeners

// Create a new one
var controller = new require('logitech-dual-action-controller')()

controller.on('1:release', console.log)

controller.on('left:move', function (data) {
  // horizontal positon of left analog stick -100 to 100 and 0 at the center.
  var rotateSpeed = data.x
  rotateRobot(rotateSpeed)
})

Events

The dual action has 12 numbered buttons, 1 to 12, a dpad and 2 analog sticks.

Buttons: There are :press and :release events for buttons 1 to 12 like so: 1:press 1:release

Dpad: There are :press and :release events for the dpad directions like so: dup:press, dleft:release. There is a dcenter:press event if you just want to know when they stop pressing the dpad.

Analog sticks: There are left:move and right:move events for the analog sticks, with a data parameter object like { x: 0, y: 0 } representing the position of the stick from -100 to 100 with 0 at the center.

        100
         |
  -100 - o - 100
         |
       -100

Source | Events | Description -----------------------|---------------------------|----------------------------------------------- 1,2,3,4 | #:press #:release | arcade buttons (replace # with button number) 5,6,7,8 | #:press #:release | shoulder button 9,10 | #:press #:release | start(ish), select(ish) 11,12 | #:press #:release | left stick press, right stick press dup,dright,ddown,dleft | #:press #:release | dpad digital directions left,right | left:move, right:move | analog stick movement with x,y position in data param

HID info, for them experts.

{
  vendorId: 1133,
  productId: 49686,
  path: 'USB_046d_c216_14300000',
  serialNumber: '',
  manufacturer: 'Logitech',
  product: 'Logitech Dual Action',
  release: 768,
  interface: -1
}

We get an 8 byte Buffer from each data event.

  • byte 0: left analog stick horizontal
  • byte 1: left analog stick vertical
  • byte 2: right analog stick horizontal
  • byte 3: right analog stick vertical
  • byte 4: dpad direction and buttons 1,2,3,4
  • byte 5: buttons 5,6,7,8,9,10,11,12
  • byte 6: mode switch... flips the dpad and left analog stick. 4 is on, 5 is off.
  • byte 7: nothing. Seems to always return 252.

See: http://www.autohotkey.com/board/topic/64178-hid-template-and-example-for-logitech-dual-action/