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

ns-joycon

v0.2.5

Published

Extract data from connected Jon-Con of Nintendo Switch.

Downloads

25

Readme

ns-joycon - Bridge between Joy-Con and Node.js

ns-joycon controls buffer stream by HID, and extracts the data from accelerometer, gyroscope and HD Rumble.

This project is an implementation from dekuNukem/Nintendo_Switch_Reverse_Engineering by Node.js.

Node Limitation Build Status Package Downloads


Quick start

Installation

npm install ns-joycon
# If you encounter some problems when `npm install ns-joycon`.
npm install ns-joycon --unsafe-perm

DEMO

Checkout the demo project at wazho/ns-joycon-showcases.

Usage

Connect your Joy-Con(s) using bluetooth with PC (currently Linux only).

And then execute program by administrator below (root can access hardware).

const JoyCon = require('ns-joycon');    // JavaScript
// import * as JoyCon from 'ns-joycon'; // TypeScript or Babel

JoyCon.findControllers((devices) => {
  // When found any device.
  devices.forEach(async (device) => {
    console.log(`Found a device (${device.meta.serialNumber})`);
    // Add a handler for new device.
    device.manageHandler('add', (packet) => {
        console.log(device.meta.product, packet);
    });
    await device.enableIMU();
  });
});

Tests

npm test

APIs

JoyCon.findControllers(callback)

Find controllers that are detected.

  • Arguments

    callback is of the form callback(devices)

device.manageHandler(action, callback)

Add a handler to process packet data.

  • Arguments

    action is add | remove

    callback is of the form callback(data)

device.requestDeviceInfo()

Request Joy-Con to provide its device info.

  • Return value

    Promise<DeviceInfo> is { firmwareVersion, type, macAddress, spiColorInUsed }

device.enableIMU()

Enable inertial measurement unit (IMU).

After this script, controller will send Input Report 0x30 per 15 ms.

  • Return value

    Promise<void>

device.disableIMU()

Disable inertial measurement unit (IMU).

  • Return value

    Promise<void>

device.enableVibration()

Enable vibration for a while.

  • Return value

    Promise<void>

device.disableVibration()

Disable vibration in immediately.

  • Return value

    Promise<void>


Extracted data

Real data from Joy-Con (R) below.

<Buffer 30, 3e, 4e, 0a, 10, 00, 00, 00,
        00, c7, 18, 76, 09, 1a, 00, f1,
        09, d5, f3, b4, ff, 5b, ff, 90,
        ff, 17, 00, de, 09, c7, f3, af,
        ff, 5e, ff, 8f, ff, 0a, 00, cd,
        09, c7, f3, b8, ff, 65, ff, 89,
        ff>

Input Report ID

// inputReportID
{
  "_raw": "<Buffer 30>",
  "_hex": ["30"]
}

Timer

// Timer
{
  "_raw": "<Buffer 2c>",
  "_hex": ["2c"]
}

Battery Level

// batteryLevel
{
  "_raw": "<Buffer 4e>",
  "_hex": ["4"],
  "level": "medium"
}

Connection Info

// connectionInfo
{
  "_raw": "<Buffer 4e>",
  "_hex": ["e"]
}

Button Status

// buttonStatus
{
  "_raw": "<Buffer 00 00 00>",
  "_hex": [ "00", "00", "00" ],
  "y": false,
  "x": false,
  "b": false,
  "a": false,
  "r": false,
  "zr": false,
  "down": false,
  "up": false,
  "right": false,
  "left": false,
  "l": false,
  "zl": false,
  "sr": false,
  "sl": false,
  "minus": false,
  "plus": false,
  "rightStick": false,
  "leftStick": false,
  "home": false,
  "caputure": false,
  "chargingGrip": false
}

Analog Sticks

Stick Left

// analogStickLeft
{
  "_raw": "<Buffer 00 00 00>",
  "_hex": [ "00", "00", "00" ],
  "horizontal": 0,
  "vertical": 0
}

Stick Right

// analogStickRight
{
  "_raw": "<Buffer 70 c8 75>",
  "_hex": [ "70", "c8", "75" ],
  "horizontal": 2160,
  "vertical": 1884
}

Vibrator

// vibrator
{
  "_raw": "<Buffer 0a>",
  "_hex": [ "0a" ]
}

Accelerometers

// accelerometers
[
  {
    "x": {
      "_raw": "<Buffer 67 01>",
      "_hex": [ "67", "01" ],
      "acc": 0.087596
    },
    "y": {
      "_raw": "<Buffer 23 00>",
      "_hex": [ "23", "00" ],
      "acc": 0.00854
    },
    "z": {
      "_raw": "<Buffer 61 f0>",
      "_hex": [ "61", "f0" ],
      "acc": -0.975756
    }
  },
  // Repeat two more, totally collected three times.
]

Gyroscopes

// gyroscopes
[
  [
    {
      "_raw": "<Buffer 17 00>",
      "_hex": [ "17", "00" ],
      "dps": 1.40369,
      "rps": 0.003896
    },
    {
      "_raw": "<Buffer ca ff>",
      "_hex": [ "ca", "ff" ],
      "dps": -3.29562,
      "rps": -0.009148
    },
    {
      "_raw": "<Buffer d8 ff>",
      "_hex": [ "d8", "ff" ],
      "dps": -2.4412,
      "rps": -0.006776
    }
  ],
  // Repeat two more, totally collected three times.
]

[Extra] Actual Accelerometer

Average of 3 times accelerometers.

// actualAccelerometer
{
  "acc": {
    "x": 0.001305,
    "y": 0.000137,
    "z": -0.014623
  }
}

[Extra] Actual Gyroscope

Average of 3 times gyroscopes.

// actualGyroscope
{
  "dps": [ 0.02014, -0.049129, -0.035703 ],
  "rps": [ 0.000056, -0.000136, -0.000099 ]
}