Try "jsdo.it WebSocket Controller" now!

This is a controller connecting a smartphone browser to a PC browser via WebSocket.
With jsdo.it, you can make a game using WebSocket right away.
Read the QR code on the right side with your smartphone or access
--
(Reload if the connection is lost.)
Supporting Browser:
Google Chrome, Safari, Firefox (Browsers must be updated to the latest version.)
Smartphone Support:
iOS 4.2 -(Mobile Safari)
Android Users: Use Firefox or Google Chrome to access.
Fork a sample code and create!
You can start making codes based on the sample code by clicking the "Fork" button.
Detailed instruction to use "jsdoitController.js" to handle a controller is available at the bottom of this page."
Write codes using "jsdo.it WebSocket Controller".

Load "jsdoitController.js" from "+" button in the JavaScript tab on the code edit page.
Initialization of "jsdoitController.js" using the following method will enable you to use "jsdo.it WebSocket Controller".
jsdoitController.initialize();
How to use "jsdoitController.js"
An original event is fired by loading "jsdoitController.js".
window.addEventListener("Abuttondown", function(event){
// Process when button "A" is pressed.
}, false);
window.addEventListener("Abuttonup", function(event){
// Process when button "A" is released.
}, false);
This is the list of events fired by "jsdoitController.js".
| Abuttondown, Abuttonup | When button A is pressed / released. |
|---|---|
| Bbuttondown, Bbuttonup | When button B is pressed / released. |
| startbuttondown, startbuttonup | When Start button is pressed / released. |
| topbuttondown, topbuttonup | When "Up" button is pressed / released (the angle of the stick is less than 70 and over 290). |
| bottombuttondown, bottombuttonup | When "Down" button is pressed / released (the angle of the stick is 110 ~ 250). |
| leftbuttondown, leftbuttonup | When "Left" button is pressed / released (the angle of the stick is 200~340). |
| rightbuttondown, rightbuttonup | When "Right" button is pressed / released (the angle of the stick is 20~160). |
| movebuttondown | When more than one button is pressed, When a user starts to move the stick |
| movebuttonup | When all the direction buttons are released, When a user finished moving the stick |
| stickstart | When a user starts to move the stick |
| stickend | When a user finished moving the stick |
| stickmove | When a user is moving the stick |
In addition, status of buttons and values of the stick can be gained by using the following methods.
var AbuttonState = jsdoitController.buttonState.Abutton;
console.log(AbuttonState); // example -> true
var stickPower = jsdoitController.stickState.power;
console.log(stickPower); // example -> 70
This is the list of values gained through "jsdoitController.js"./p>
| jsdoitController.buttonState.Abutton | if button A is being pressed or not(true / false) |
|---|---|
| jsdoitController.buttonState.Bbutton | if button B is being pressed or not(true / false) |
| jsdoitController.buttonState.startbutton | if START button is being pressed or not(true / false) |
| jsdoitController.buttonState.topbutton | if "Up" button is being pressed or not(true / false) |
| jsdoitController.buttonState.bottombutton | if "Down" button is being pressed or not(true / false) |
| jsdoitController.buttonState.leftbutton | if "Left" button is being pressed or not(true / false) |
| jsdoitController.buttonState.rightbutton | if "Right" button is being pressed or not(true / false) |
| jsdoitController.stickState.use | if the stick is being moved or not(true / false) |
| jsdoitController.stickState.deg | stick angle(0 ~ 360) |
| jsdoitController.stickState.power | the degree of the stick inclination(1 ~ 100) |
| jsdoitController.stickState.powerX | the stick inclination towards X direction(-100 ~ 100) |
| jsdoitController.stickState.powerY | the stick inclination towards Y direction(-100 ~ 100) |




