A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.npmjs.com/package/dualshock-controller below:

dualshock-controller - npm

node-dualshock-controller

dualshock-controller Eventing API layer over HID for the Sony DualShock 3 and DualShock 4 controllers

Installation: OSX/Windows:

npm install dualshock-controller

Linux:

Review the Linux support section.

Using the DualShock library

Important: THE CONTROLLER WILL NOT SEND ANY DATA IF YOU DO NOT PRESS THE PS BUTTON.

var dualShock = require('dualshock-controller');

 

var controller = dualShock(

    {

        

        

        

        config : "dualShock3",

        

        accelerometerSmoothing : true,

        

        analogStickSmoothing : false

    });

 

controller.on('error', err => console.log(err));

 

controller.setExtras({

  rumbleLeft:  0,   

  rumbleRight: 0,   

  red:         0,   

  green:       75,  

  blue:        225, 

  flashOn:     40,  

  flashOff:    10   

});

 

controller.setExtras({

  rumbleLeft:  0,   

  rumbleRight: 0,   

  led: 2 

});

 

controller.on('left:move', data => console.log('left Moved: ' + data.x + ' | ' + data.y));

 

controller.on('right:move', data => console.log('right Moved: ' + data.x + ' | ' + data.y));

 

controller.on('connected', () => console.log('connected'));

 

controller.on('square:press', ()=> console.log('square press'));

 

controller.on('square:release', () => console.log('square release'));

 

 

controller.on('touchpad:x1:active', () => console.log('touchpad one finger active'));

 

controller.on('touchpad:x2:active', () => console.log('touchpad two fingers active'));

 

controller.on('touchpad:x2:inactive', () => console.log('touchpad back to single finger'));

 

controller.on('touchpad:x1', data => console.log('touchpad x1:', data.x, data.y));

 

controller.on('touchpad:x2', data => console.log('touchpad x2:', data.x, data.y));

 

 

controller.on('rightLeft:motion', data => console.log(data));

 

controller.on('forwardBackward:motion', data => console.log(data));

 

controller.on('upDown:motion', data => console.log(data));

 

controller.on('battery:change', data => console.log(data));

 

controller.on('connection:change', data => console.log(data));

 

controller.on('charging:change', data => console.log(data));

 

Linux support:

In order to provide Rumble/Gyro and LED support for all platforms the linux specific joystick implementation has been removed. This means you will need to:

Install node-hid build requirements

To build node-hid you will need to install:

Using apt-get:

sudo apt-get install libudev-dev libusb-1.0-0 libusb-1.0-0-dev build-essential git

npm install -g node-gyp node-pre-gyp

Install node-hid with hidraw support

Once you have run the installation scripts above you can install the node-dualshock module, then replace the installed node-hid with hidraw support enabled node-hid:

npm install dualshock-controller

npm install node-hid --driver=hidraw --build-from-source

Create udev rules

You will need to create a udev rule to be able to access the hid stream as a non root user.

Write the following file in /etc/udev/rules.d/61-dualshock.rules

SUBSYSTEM=="input", GROUP="input", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0268", MODE:="666", GROUP="plugdev"
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0664", GROUP="plugdev"

SUBSYSTEM=="input", GROUP="input", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="05c4", MODE:="666", GROUP="plugdev"
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0664", GROUP="plugdev"

Reload the rules sudo udevadm control --reload-rules, then disconnect/connect the controller.

The MIT License (MIT)

Copyright (c) 2017 Ricardo de Pena

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4