Slither.io PS4







Slither.io PS4 Controller Support



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!

Slither.io Mods User Script

How to install Slither.io Mods?

 




10 Comments

  1. Any way to get PS4 Controller to work on Android? I have a Galaxy S8+ and the position on the screen likes to cramp up my thumb.

  2. //Added enter support (by pressing x or options on home screen

    // Tested in Chrome.
    // Left stick to steer, X to accelerate

  3. Would love to see this in extension form, I could not get it to work.

  4. I still can’t get it to work with my PS4 controller. I added the javascript line to the bookmark, but it still does not work. can you give a more detailed guide on how to use it if it does work.

Reply To filip Cancel Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.