node-dualshock-controller
node-dualshock-controller copied to clipboard
Feature Request: Button Hold Duty Cycle
Is there a way to set the dutycycle of the button hold function.
Right now when I hold a button on the controller the '{button}:hold' functions fire off rather fast.
I need the functions like controller.on('square:hold', () => console.log('square hold'));
to fire off much slower, like every 250ms.
I think it would be easiest to be able to pass a buttonHoldDutycycle option when init the controller &/OR be able pass the cycle rate per button decoration controller.on('square:hold', 250, () => console.log('square hold'));
.
Concept:
var dualShock = require('dualshock-controller');
//pass options to init the controller.
var controller = dualShock(
{
//you can use a ds4 by uncommenting this line.
//config: "dualshock4-generic-driver",
//if using ds4 comment this line.
config : "dualShock3",
//smooths the output from the acelerometers (moving averages) defaults to true
accelerometerSmoothing : true,
//smooths the output from the analog sticks (moving averages) defaults to false
analogStickSmoothing : false
// Button Hold Dutycycle
buttonHoldDutycycle : 250 // 250ms
});
//connect the controller
controller.connect();
// Button Hold (will cycle at a rate of 250mm because of passed buttonHoldDutycycle in controller int)
controller.on('square:hold', () => console.log('square hold'));
// Button Hold (will cycle at a rate of 500mm because of passed 500 in function)
controller.on('triangle:hold', 500, () => console.log('triangle hold'));
@AustinSaintAubin yea, this makes sense.