Slither.io PS4 Playstation Controller Support

Hello friends Slither.io PS4 Playstation Controller Support my added Dualshoch 4 support to Slither.io details and codes;

// Tested in Chrome.
// Left stick to steer, X to accelerate
(function() {
 if(!("getGamepads"innavigator)) {
 return;
 }
 varpollPad = function() {
 varps4 = navigator.getGamepads()[0];
 if(ps4) {
 varx = 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;
 setAcceleration(ps4.buttons[0].value);
 varb = 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);
Source Details - 1
Source Details - 2

Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *