Web Info & Tutorials

August 6th, 2007

THE WII REMOTE API: NOW YOUR USERBASE IS FOUR.

The Opera folk have released an API that allows you, the developer, to be able to monitor all of the remotes that are connected with The Wii Remote API.

This means that you can watch up to four people buzzing around the screen:

Polling the status of a remote

The Wii Remote data is accessed through the opera.wiiremote object. This object offers a single method opera.wiiremote.update(n) which is used to obtain the status of an individual Wii Remote. The method expects a single parameter; the Wii Remote number. The number is zero-based, so it starts at 0 for the first remote, and ends at 3 for the fourth remote. The method returns a KpadStatus object, which has several properties that give information about the remote.

This update method can be called as often as is needed to obtain a fluid response, but note that the Wii is not as powerful as most desktop computers, so it is important to make sure that it is polled only as often as the script that uses that data can process it. For example, if a script uses the Wii Remote status to update the display of a canvas element, and that update will take perhaps 50 ms to update in Opera on a desktop computer, it may take over 100 ms on a Wii. Attempting to use a polling interval of less than 100 ms will cause the response to appear very sluggish.

Note that the opera.wiiremote object only exists in Opera on Wii, so it is important to check for its existence, as well as the existence of the opera object, before attempting to use it.

Examples

JAVASCRIPT:
  1.  
  2. //Obtaining the roll of the third Wii remote in degrees
  3.  
  4. var remote, roll = 0;
  5. //check if the browser provides access to the Wii Remote data
  6. if( window.opera && opera.wiiremote ) {
  7.   //get the KpadStatus object for the third Wii Remote
  8.   remote = opera.wiiremote.update(2);
  9.   //check that the remote is enabled
  10.   if( remote.isEnabled ) {
  11.     //get the roll angle in radians
  12.     roll = Math.atan2( remote.dpdRollY, remote.dpdRollX );
  13.     //convert the roll to degrees
  14.     roll = roll * ( 180 / Math.PI );
  15.   }
  16. }
  17.  
  18. // Checking what buttons are pressed on the second remote
  19. var remote, buttons = {};
  20. //check if the browser provides access to the Wii Remote data
  21. if( window.opera && opera.wiiremote ) {
  22.   //get the KpadStatus object for the third Wii Remote
  23.   remote = opera.wiiremote.update(1);
  24.   //check that the remote is enabled
  25.   if( remote.isEnabled ) {
  26.     //use the bitwise AND operator to compare against the bitmasks
  27.     buttons.pressedLeft = remote.hold & 1;
  28.     buttons.pressedRight = remote.hold & 2;
  29.     buttons.pressedDown = remote.hold & 4;
  30.     buttons.pressedUp = remote.hold & 8;
  31.     buttons.pressedPlus = remote.hold & 16;
  32.     buttons.pressed2 = remote.hold & 256;
  33.     buttons.pressed1 = remote.hold & 512;
  34.     buttons.pressedB = remote.hold & 1024;
  35.     buttons.pressedA = remote.hold & 2048;
  36.     buttons.pressedMinus = remote.hold & 4096;
  37.     buttons.pressedZ = remote.hold & 8192;
  38.     buttons.pressedC = remote.hold & 16384;
  39.   }
  40. }
  41.  

There are a bunch of demonstrations, including a simple game.

I can't wait to see the Star Wars light sabre web game... and then see a Comet based app that grows beyond the four connected devices!

August 6th, 2007

ME.DIUM WIDGETS AND IE 7

The folk at Me.dium have announced a new widget that you can use to show Me.dium on your own site, and the full release of their IE 7 support.

Below is an example of a Me.dium widget that is bound to ajaxian.com as the central point. Me.dium is now opening up to your signups, so go ahead and try it out. To add a widget yourself, click on the "manage widgets" section.

August 6th, 2007

GOOGLE TALK CLIENT IN JAVASCRIPT

Zhou Renjian has a newborn demonstrate Simple Pipe was utilised to create and reassert a Comet unification between client/browser and computer (Tomcat). A looping-query crapper be utilised instead for chatting, but the underway demonstrate does not alter to that mode.

After the demonstrate was implemented and proven in Java the Java2Script programme was utilised to modify every Java sources into JavaScript. After deploying the application, I took whatever instance employed on optimizations which included lazy loading, lazy creating, and realistic itemize views, which were musts for hurried weight and response. I talk a lowercase most these optimizations here.

Google Talk in JavaScript