W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2012

GamepadObserver (ie. MutationObserver + Gamepad)

From: Rick Waldron <waldron.rick@gmail.com>
Date: Wed, 2 May 2012 17:48:50 -0400
Message-ID: <CAHfnhfpsa2epU5smyEcaOZhtdO5okDXi8kW+hqDHDg5PFwCtTA@mail.gmail.com>
To: Webapps WG <public-webapps@w3.org>
Instead of traditional DOM events being used for Other Events[1], and
considering the high frequency of Gamepad state changes, it might make
sense to provide an API similar to MutationObserver, where a MutationRecord
is created that has snapshots of current and previous states of axes or
buttons...


This is entirely hypothetical:

(new GamepadObserver(function(mutations) {

  console.log( mutations );
  /*
  {
    previousState: {
      readonly attribute string       id;
      readonly attribute long         index;
      readonly attribute DOMTimeStamp timestamp;

// Either or both of the following, bases on the options list

      readonly attribute float[]      axes;
      readonly attribute float[]      buttons;
    }

    currentState: {
      readonly attribute string       id;
      readonly attribute long         index;
      readonly attribute DOMTimeStamp timestamp;

// Either or both of the following, bases on the options list

      readonly attribute float[]      axes;
      readonly attribute float[]      buttons;
    }
  }
  */
})).observe(navigator.gamepads[0], { axesList: true });

//  axesList, buttonsList


[1] http://dvcs.w3.org/hg/gamepad/raw-file/tip/gamepad.html#other-events


Rick
Received on Wednesday, 2 May 2012 21:49:40 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:52 GMT