pecacheu / dualshock Goto Github PK
View Code? Open in Web Editor NEWNode.js module for DualShock (3 and 4) controllers.
License: GNU General Public License v3.0
Node.js module for DualShock (3 and 4) controllers.
License: GNU General Public License v3.0
How to reproduce:
$ node
> ds = require('dualshock');
> g = ds.open(ds.getDevices("ds4")[0]);
> g.rumble(255,255);
How to fix:
In ds4.js
just remove second argument in 99 line:
- dev.write(msg, true);
+ dev.write(msg);
Why?
I probably think it's because of a new version of node-hid
. You have tested 5 months ago, when node-hid
didn't check for count of arguments.
Thanks for your great work!
I tried to use version 3.1.2 on a Mac, but unfortunately node-gyp cannot build the modules due to the missing windows.h
. After removing the sbc references, npm install
is able to build the module (I am aware that it might crash at some point, where sbc is needed - audio, correct?).
I am able to run a simple example now, but unfortunately, still the rumble/LED feature for the DS4 does not work via Bluetooth. Is this related to sbc as well or is there another issue? Using the USB connection it works as intended.
ds = require('dualshock')
devices = ds.getDevices("ds4");
gamepad = ds.open(devices[0])
gamepad.rumble(255, 255, 5, 5);
gamepad.setLed(255,0,0);
Doing an npm install dualshock does not work on ubuntu arm7 because of a conflict for the int64_t defined within it...
../sbc/sbc.h:37:17: error: conflicting declaration ‘typedef int64_t ssize_t’
/usr/include/arm-linux-gnueabihf/sys/types.h:108:19: note: previous declaration as ‘typedef __ssize_t ssize_t’
My platform:
user@ubuntu:~/code/dualshock$ uname -a
Linux ubuntu 5.4.0-1042-raspi #46-Ubuntu SMP PREEMPT Fri Jul 30 00:36:54 UTC 2021 armv7l armv7l armv7l GNU/Linux
user@ubuntu:~/code/dualshock$ node -v
v18.16.0
user@ubuntu:~/code/dualshock$ npm -v
9.5.1
Full stack of npm install
npm ERR! code 1
npm ERR! path /home/user/code/spwm-motor-control/rbot-io/node_modules/dualshock
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! make: Entering directory '/home/user/code/spwm-motor-control/rbot-io/node_modules/dualshock/build'
npm ERR! CXX(target) Release/obj.target/sbc/main.o
npm ERR! make: Leaving directory '/home/user/code/spwm-motor-control/rbot-io/node_modules/dualshock/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | arm
npm ERR! gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
npm ERR! gyp http GET https://nodejs.org/download/release/v18.16.0/node-v18.16.0-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v18.16.0/node-v18.16.0-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v18.16.0/SHASUMS256.txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v18.16.0/SHASUMS256.txt
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/user/code/spwm-motor-control/rbot-io/node_modules/dualshock/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/user/.cache/node-gyp/18.16.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/home/user/.cache/node-gyp/18.16.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/home/user/.cache/node-gyp/18.16.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/user/code/spwm-motor-control/rbot-io/node_modules/dualshock',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../main.cc:8:
npm ERR! ../sbc/sbc.h:37:17: error: conflicting declaration ‘typedef int64_t ssize_t’
npm ERR! 37 | typedef int64_t ssize_t;
npm ERR! | ^~~~~~~
npm ERR! In file included from /usr/include/stdlib.h:394,
npm ERR! from /usr/include/c++/9/cstdlib:75,
npm ERR! from /usr/include/c++/9/ext/string_conversions.h:41,
npm ERR! from /usr/include/c++/9/bits/basic_string.h:6496,
npm ERR! from /usr/include/c++/9/string:55,
npm ERR! from /usr/include/c++/9/stdexcept:39,
npm ERR! from /usr/include/c++/9/array:39,
npm ERR! from /usr/include/c++/9/tuple:39,
npm ERR! from /usr/include/c++/9/bits/unique_ptr.h:37,
npm ERR! from /usr/include/c++/9/memory:80,
npm ERR! from /home/user/.cache/node-gyp/18.16.0/include/node/v8.h:21,
npm ERR! from /home/user/.cache/node-gyp/18.16.0/include/node/node.h:73,
npm ERR! from ../main.cc:1:
npm ERR! /usr/include/arm-linux-gnueabihf/sys/types.h:108:19: note: previous declaration as ‘typedef __ssize_t ssize_t’
npm ERR! 108 | typedef __ssize_t ssize_t;
npm ERR! | ^~~~~~~
npm ERR! ../main.cc: In function ‘void sbcEncode(const v8::FunctionCallbackInfo<v8::Value>&)’:
npm ERR! ../main.cc:135:94: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
npm ERR! 135 | nBuf->Set(ctx,String::NewFromUtf8(iso,"unparsed").ToLocalChecked(),Number::New(iso,len-iPos));
npm ERR! | ^
npm ERR! In file included from /home/user/.cache/node-gyp/18.16.0/include/node/v8-array-buffer.h:13,
npm ERR! from /home/user/.cache/node-gyp/18.16.0/include/node/v8.h:24,
npm ERR! from /home/user/.cache/node-gyp/18.16.0/include/node/node.h:73,
npm ERR! from ../main.cc:1:
npm ERR! /home/user/.cache/node-gyp/18.16.0/include/node/v8-object.h:244:37: note: declared here
npm ERR! 244 | V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
npm ERR! | ^~~
npm ERR! ../main.cc:136:73: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, uint32_t, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
npm ERR! 136 | for(size_t i=0; i<oPos; i++) nBuf->Set(ctx,i,Number::New(iso,sbcOut[i]));
npm ERR! | ^
npm ERR! In file included from /home/user/.cache/node-gyp/18.16.0/include/node/v8-array-buffer.h:13,
npm ERR! from /home/user/.cache/node-gyp/18.16.0/include/node/v8.h:24,
npm ERR! from /home/user/.cache/node-gyp/18.16.0/include/node/node.h:73,
npm ERR! from ../main.cc:1:
npm ERR! /home/user/.cache/node-gyp/18.16.0/include/node/v8-object.h:247:37: note: declared here
npm ERR! 247 | V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
npm ERR! | ^~~
npm ERR! In file included from ../main.cc:1:
npm ERR! ../main.cc: At global scope:
npm ERR! /home/user/.cache/node-gyp/18.16.0/include/node/node.h:997:43: warning: cast between incompatible function types from ‘void (*)(v8::Local<v8::Object>)’ to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
npm ERR! 997 | (node::addon_register_func) (regfunc), \
npm ERR! | ^
npm ERR! /home/user/.cache/node-gyp/18.16.0/include/node/node.h:1031:3: note: in expansion of macro ‘NODE_MODULE_X’
npm ERR! 1031 | NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
npm ERR! | ^~~~~~~~~~~~~
npm ERR! ../main.cc:150:1: note: in expansion of macro ‘NODE_MODULE’
npm ERR! 150 | NODE_MODULE(sbc, init)
npm ERR! | ^~~~~~~~~~~
npm ERR! make: *** [sbc.target.mk:115: Release/obj.target/sbc/main.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 5.4.0-1042-raspi
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/user/code/spwm-motor-control/rbot-io/node_modules/dualshock
npm ERR! gyp ERR! node -v v18.16.0
npm ERR! gyp ERR! node-gyp -v v9.3.1
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2023-04-19T18_00_13_758Z-debug-0.log
When I ran npm install dualshock
and did require('dualshock')
, i have seen:
$ node
> ds=require('dualshock')
Error: Cannot find module 'chalk'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
In package.json
there is nothing about chalk
. Please, add it to file.
From the looks of things, the latest commit 9858d05 has broken the module from compiling on Windows.
When reverting that commit, it appears to fix this issue.
It seems when trying to get the battery status on the onchanged event it always reports as a different number such as 13 or 12, 11. Checking something like DS4Windows shows 60%
Any way to fix it?
Hey! Thanks for an awesome lib for Dualshock remote.
I just noticed that I cannot install the latest version (3.1.3) on Linux because of node-hid
lib and Windows.h
file.
I can successfully install 3.1.1 version (and node-hid
official package)
I think this is because we need latest updates to support Speaker, but if it's not ready for Linux, maybe we can make them optional, so we can install the latest version successfully?
Cheers 😉
I can't install the package over npm.
2019-07-30T13_56_32_352Z-debug.log
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.