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

ps-move

v1.1.3

Published

Interface with the Playstation Move motion controller.

Downloads

12

Readme

ps-move

Interface with the Playstation Move motion controller. This module can receive inputs and set the LED color and rumble.

Example

import { PSMove } from 'ps-move';

const move = new PSMove(()=>console.log('Ready!'));

move.on('data', data=>{

    if(data.triangle){
        move.hex('d64462');
        move.update();
    }

    if(data.square){
        move.hsl(35, .95, .63);
        move.update();
    }

    if(data.circle){
        move.rumble(.5);
        move.update();
    }

});

Pairing

You can pair using the PS Move API. It is recommended to follow their documentation, although here's a summary of the steps I took:

  1. Download and extract a PS Move API GitHub Release.
  2. Run a terminal as administrator.
  3. Navigate to the bin directory inside of the extracted folder.
  4. Connect your controller with USB.
  5. Execute psmove pair.
  6. Done!

If you have any trouble, consult the PS Move API Documentation.

Installation

Install using npm:

npm i ps-move

API

PSMove

The main class representing the PlayStation Move motion controller.

const move = new PSMove(()=>console.log('Ready!'));

On the constructor, you can pass a function that will be triggered when the instance is ready.

Properties

battery

Returns the last known Battery data.

console.log(move.battery); // { level: 4, chargingStatus: 'not_charging' }

Methods

hex(), rgb(), hsl()

Gets and sets the color of the LED. Use update() to apply the set color.

move.hex() // #000000
move.hex('#b16570');

move.rgb() // [177, 101, 112]
move.rgb(199, 210, 39);

move.hsl() // [63.85, 0.68, 0.48]
move.hsl(124, .76, .7);

rumble()

Gets and sets the rumble (vibration) of the controller. Must be a number from 0 to 1. Use update() to apply the set rumble.

move.rumble() // 0
move.rumble(.75);

update()

Send a message to the controller with the set color and the set rumble. It returns a Promise<boolean> to inform the success of the update.

if(await move.update()){
    console.log('Success!');
}else{
    console.log('Fail!');
}

destroy()

End the connection with the controller.

await move.destroy();

Events

data

Emits a Data object about the controller. This happens multiple times per second.

move.on('data', data=>{
    // Do something
});

buttonDown, buttonUp

Emits a ButtonEvent object when a button is pressed.

move.on('buttonDown', e=>{
    console.log(e); // { button: 'square', state: true, data: { ... } }
});

triggerChange

Emits a TriggerEvent object when the pressure on the trigger button is changed.

move.on('triggerChange', e=>{
    console.log(e.amount); // 0.8653
});

error

Emits any error received from the controller connection.

move.on('error', error=>{
    // Uh oh!
});

Interfaces

Data

| Name | Type | Description | |-----------------|-----------------------|----------------------------------------------------------------------------------| | select | boolean | SELECT button | | start | boolean | START button | | square | boolean | button | | cross | boolean | button | | circle | boolean | button | | triangle | boolean | button | | ps | boolean | button | | move | boolean | button | | trigger | number | Trigger (T) button pressure from 0 to 1 | | battery | Battery | Battery information | | accelerometer | Vector3 | Vector of the accelerometer | | gyroscope | Vector3 | Vector of the gyroscope |

Battery

| Name | Type | Description | |------------------|--------------------|------------------------------------------------------------------------------| | level | number or null | The battery level from 0 to 5. When charging, it is unknown so it is null. | | chargingStatus | string | Returns not_charging, charging or fully_charged. |

Vector3

| Name | Type | |------|----------| | x | number | | y | number | | z | number |

ButtonEvent

| Name | Type | Description | |----------|-------------------|-------------------------------------------------------------------------------------| | button | string | Returns select, start, square, cross, circle, triangle, ps or move. | | state | boolean | Returns true if the button is pressed. | | data | Data | The related Data object. |

TriggerEvent

| Name | Type | Description | |----------|-------------------|---------------------------------------------| | amount | number | Trigger (T) button pressure from 0 to 1 | | data | Data | The related Data object. |

Changelog

Consult the changelog here: CHANGELOG.md

Acknowledgments

This project wouldn't be possible without the help of the PS Move API. Thank you to @thp! ❤️

License

MIT © bernzrdo