Try "jsdo.it WebSocket Controller" now!

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:

  • Chrome
  • Safari
  • Firefox

Google Chrome, Safari, Firefox (Browsers must be updated to the latest version.)

Smartphone Support:

  • iPhoneiOS 4.2 -(Mobile Safari)
  • Google PlayAndroid 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, AbuttonupWhen button A is pressed / released.
Bbuttondown, BbuttonupWhen button B is pressed / released.
startbuttondown, startbuttonupWhen Start button is pressed / released.
topbuttondown, topbuttonupWhen "Up" button is pressed / released (the angle of the stick is less than 70 and over 290).
bottombuttondown, bottombuttonupWhen "Down" button is pressed / released (the angle of the stick is 110 ~ 250).
leftbuttondown, leftbuttonupWhen "Left" button is pressed / released (the angle of the stick is 200~340).
rightbuttondown, rightbuttonupWhen "Right" button is pressed / released (the angle of the stick is 20~160).
movebuttondownWhen more than one button is pressed, When a user starts to move the stick
movebuttonupWhen all the direction buttons are released, When a user finished moving the stick
stickstartWhen a user starts to move the stick
stickendWhen a user finished moving the stick
stickmoveWhen 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.Abuttonif button A is being pressed or not(true / false)
jsdoitController.buttonState.Bbuttonif button B is being pressed or not(true / false)
jsdoitController.buttonState.startbuttonif START button is being pressed or not(true / false)
jsdoitController.buttonState.topbuttonif "Up" button is being pressed or not(true / false)
jsdoitController.buttonState.bottombuttonif "Down" button is being pressed or not(true / false)
jsdoitController.buttonState.leftbuttonif "Left" button is being pressed or not(true / false)
jsdoitController.buttonState.rightbuttonif "Right" button is being pressed or not(true / false)
jsdoitController.stickState.useif the stick is being moved or not(true / false)
jsdoitController.stickState.degstick angle(0 ~ 360)
jsdoitController.stickState.powerthe degree of the stick inclination(1 ~ 100)
jsdoitController.stickState.powerXthe stick inclination towards X direction(-100 ~ 100)
jsdoitController.stickState.powerYthe stick inclination towards Y direction(-100 ~ 100)

Comment

Recommendations

Facebook page