Slither.io PS4 Controller Support
From: @strbeanjoe
I added DualShock 4 support to Slither.io (works on chrome)
Code
//Added enter support (by pressing x or options on home screen
// Tested in Chrome.
// Left stick to steer, X to accelerate
(function () {
if (!(“getGamepads” in navigator)) {
return;
}
var pollPad = function() {
var ps4 = navigator.getGamepads()[0];
if (ps4) {
var x = ps4.axes[0], y = ps4.axes[1];
if (Math.sqrt(x*x+y*y) < 0.1) x = y = 0; // deadzone radius
xm = 100 * x;
ym = 100 * y;
var xbutton = ps4.buttons[0].value;
setAcceleration(xbutton);
// map ps4 options key to enter button
var options = navigator.getGamepads()[0].buttons[9].value;
if(options || xbutton )
{
// start game
play_btn.elem.onclick();
}
var b = mc.getContext(“2d”);
b.save();
b.beginPath();
b.strokeStyle = ps4.buttons[0].value ? “white” : “lightGreen”;
b.arc(xm + mc.width/2, ym+mc.height/2, 8, 0, Math.PI * 2);
b.stroke();
b.restore();
}
window.requestAnimationFrame(pollPad);
};
pollPad();
})();
Bookmarklet
javascript:!function(){if("getGamepads"in navigator){var t=function(){var e=navigator.getGamepads()[0];if(e){var a=e.axes[0],i=e.axes[1];Math.sqrt(a*a+i*i)<.1&&(a=i=0),xm=100*a,ym=100*i,setAcceleration(e.buttons[0].value);var n=mc.getContext("2d");n.save(),n.beginPath(),n.strokeStyle=e.buttons[0].value?"white":"lightGreen",n.arc(xm+mc.width/2,ym+mc.height/2,8,0,2*Math.PI),n.stroke(),n.restore()}window.requestAnimationFrame(t)};t()}}(); void(0);
Soruce 1 Source 2
Slither.io Mods v3 Released!
How to install Slither.io Mods?