gamepad.html
author Matt Brubeck <mbrubeck@mozilla.com>
Mon, 14 Nov 2011 09:44:25 -0800
changeset 140 d111c73bb11b
parent 138 9dc0265c3363
child 154 bbe9fa52b783
permissions -rw-r--r--
Restore missing Touch.target attribute (LC-1).

http://www.w3.org/2010/webevents/wiki/TouchEvents-LCWD-27-Oct-2011#LC-1
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
     1
<!DOCTYPE html>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
     2
<html lang="en">
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
     3
  <head>
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
     4
    <title>Gamepad</title>
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
     5
    <meta http-equiv='Content-Type' content='text/html;charset=utf-8'/>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
     6
    <meta name="viewport" content="width=device-width">
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
     7
    <!--
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
     8
      === NOTA BENE ===
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
     9
      For the three scripts below, if your spec resides on dev.w3 you can check them
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    10
      out in the same tree and use relative links so that they'll work offline,
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    11
     -->
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    12
    <script src='http://dev.w3.org/2009/dap/ReSpec.js/js/respec.js' class='remove'></script>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    13
    <script class='remove'>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    14
      var respecConfig = {
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    15
          // specification status (e.g. WD, LCWD, NOTE, etc.). If in doubt use ED.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    16
          specStatus:           "ED",
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    17
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    18
          // the specification's short name, as in http://www.w3.org/TR/short-name/
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    19
          shortName:            "gamepad",
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    20
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    21
          // if your specification has a subtitle that goes below the main
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    22
          // formal title, define it here
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    23
          // subtitle   :  "an excellent document",
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    24
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    25
          // if you wish the publication date to be other than today, set this
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    26
          //publishDate:  "2011-01-01",
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    27
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    28
          // if the specification's copyright date is a range of years, specify
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    29
          // the start date here:
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    30
          // copyrightStart: "2005"
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    31
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    32
          // if there is a previously published draft, uncomment this and set its YYYY-MM-DD date
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    33
          // and its maturity status
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    34
          // previousPublishDate:  "1977-03-15",
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    35
          // previousMaturity:  "WD",
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    36
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    37
          // if there a publicly available Editor's Draft, this is the link
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    38
          edDraftURI:           "http://dvcs.w3.org/hg/webevents/raw-file/default/gamepad.html",
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    39
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    40
          // if this is a LCWD, uncomment and set the end of its review period
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    41
          // lcEnd: "2009-08-05",
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    42
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    43
          // if you want to have extra CSS, append them to this list
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    44
          // it is recommended that the respec.css stylesheet be kept
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    45
          extraCSS:             ["http://www.w3.org/StyleSheets/TR/W3C-TR.css", "http://dev.w3.org/2009/dap/ReSpec.js/css/respec.css"],
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    46
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    47
          // editors, add as many as you like
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    48
          // only "name" is required
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    49
          editors:  [
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    50
              { name: "Scott Graham", url: "http://h4ck3r.net/",
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    51
                company: "Google", companyURL: "http://www.google.com/" },
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    52
              { name: "Ted Mielczarek", url: "http://ted.mielczarek.org/",
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    53
                company: "Mozilla", companyURL: "http://www.mozilla.org/" },
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    54
          ],
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    55
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    56
          // authors, add as many as you like.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    57
          // This is optional, uncomment if you have authors as well as editors.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    58
          // only "name" is required. Same format as editors.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    59
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    60
          //authors:  [
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    61
          //    { name: "Your Name", url: "http://example.org/",
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    62
          //      company: "Your Company", companyURL: "http://example.com/" },
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    63
          //],
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    64
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    65
          // name of the WG
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    66
          wg:           "Web Events Working Group",
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    67
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    68
          // URI of the public WG page
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    69
          wgURI:        "http://www.w3.org/2010/webevents/",
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    70
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    71
          // name (with the @w3c.org) of the public mailing to which comments are due
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    72
          wgPublicList: "public-webevents",
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    73
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    74
          // URI of the patent status for this WG, for Rec-track documents
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    75
          // !!!! IMPORTANT !!!!
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    76
          // This is important for Rec-track documents, do not copy a patent URI from a random
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    77
          // document unless you know what you're doing. If in doubt ask your friendly neighbourhood
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    78
          // Team Contact.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    79
          wgPatentURI:  "http://www.w3.org/2004/01/pp-impl/45559/status",
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    80
      };
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    81
    </script>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    82
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    83
    <style type="text/css">
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    84
      .event {
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    85
        font-family: monospace;
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    86
        color: #459900;
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    87
      }
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    88
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    89
      pre.idl {
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    90
        white-space: pre-wrap;
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    91
      }
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    92
    </style>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    93
  </head>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    94
  <body>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    95
    <section id='abstract'>
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
    96
      The Gamepad specification defines a low-level interface that represents
125
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
    97
      gamepad devices.
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    98
    </section>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
    99
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   100
    <section id='introduction' class='informative'>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   101
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   102
      <h2>Introduction</h2>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   103
125
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   104
      <p>Some <a>user agent</a>s have connected gamepad devices. These devices
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   105
      are desirable and suited to input for gaming applications, and for
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   106
      &quot;10 foot&quot; user interfaces (presentations, media viewers).</p>
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   107
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   108
      <p>Currently, the only way for a gamepad to be used as input would be
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   109
      to emulate mouse or keyboard events, however this would lose information
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   110
      and require additional software outside of the <a>user agent</a> to
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   111
      accomplish emulation.</p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   112
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   113
      <p>Meanwhile, native applications are capable of accessing these devices
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   114
      via system APIs.</p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   115
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   116
      <p>The Gamepad API provides a solution to this problem by specifying
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   117
      interfaces that allow web applications to directly act on gamepad
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   118
      data.</p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   119
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   120
      <p>This specification references interfaces from a number of other
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   121
      specifications:</p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   122
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   123
      <ul>
117
fd9ea2f17eaa document->navigator
Scott Graham <scottmg@google.com>
parents: 114
diff changeset
   124
      <li><a class="externalDFN">Navigator</a> [[!NAVIGATOR]]</li>
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   125
      <li><a class="externalDFN">DOMTimeStamp</a> [[!WEBIDL]]</li>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   126
      <li><a class="externalDFN">WindowAnimationTiming</a> [[ANIMATION-TIMING]]</li>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   127
      </ul>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   128
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   129
    </section>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   130
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   131
    <section id='conformance'>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   132
      <p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   133
        This specification defines conformance criteria that apply to a single
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   134
        product: the <dfn id="dfn-user-agent">user agent</dfn> that implements
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   135
        the interfaces that it contains.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   136
      </p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   137
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   138
      <p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   139
        Implementations that use ECMAScript to implement the APIs defined in
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   140
        this specification MUST implement them in a manner consistent with the
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   141
        ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]] as
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   142
        this specification uses that specification and terminology.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   143
      </p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   144
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   145
      <p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   146
        A conforming implementation is required to implement all fields
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   147
        defined in this specification.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   148
      </p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   149
    </section>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   150
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   151
    <section>
114
c788513485e5 rough attempt at scope qualification
Scott Graham <scottmg@google.com>
parents: 113
diff changeset
   152
c788513485e5 rough attempt at scope qualification
Scott Graham <scottmg@google.com>
parents: 113
diff changeset
   153
      <h2>Scope</h2>
c788513485e5 rough attempt at scope qualification
Scott Graham <scottmg@google.com>
parents: 113
diff changeset
   154
c788513485e5 rough attempt at scope qualification
Scott Graham <scottmg@google.com>
parents: 113
diff changeset
   155
      <p>Interfacing with external devices designed to control games has the
c788513485e5 rough attempt at scope qualification
Scott Graham <scottmg@google.com>
parents: 113
diff changeset
   156
      potential to become large and intractable if approached in full
c788513485e5 rough attempt at scope qualification
Scott Graham <scottmg@google.com>
parents: 113
diff changeset
   157
      generality. In this specification we explicitly choose to narrow scope
c788513485e5 rough attempt at scope qualification
Scott Graham <scottmg@google.com>
parents: 113
diff changeset
   158
      to provide a useful subset of functionality that can be widely
c788513485e5 rough attempt at scope qualification
Scott Graham <scottmg@google.com>
parents: 113
diff changeset
   159
      implemented and broadly useful.</p>
c788513485e5 rough attempt at scope qualification
Scott Graham <scottmg@google.com>
parents: 113
diff changeset
   160
125
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   161
      <p>Specifically, we choose to only support the functionality required to
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   162
      support gamepads. Support for gamepads requires two input types: buttons
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   163
      and axes. Both buttons and axes are reported as analog values, buttons
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   164
      ranging from [0..1], and axes ranging from [-1..1].</p>
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   165
      
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   166
      <p>While the primary goal is support for gamepad devices, supporting
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   167
      these two types of analog inputs allows support for other similar devices
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   168
      common to current gaming systems including joysticks, driving wheels,
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   169
      pedals, and accelerometers. As such, the name "gamepad" is exemplary
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   170
      rather than trying to be a generic name for the entire set of devices
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   171
      addressed by this specification.</p>
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   172
      
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   173
      <p>We specifically exclude support for more complex devices that may also
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   174
      be used in some gaming contexts, including those that that do motion
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   175
      sensing, depth sensing, video analysis, gesture recognition, and so
db70f053a525 attempt to clairify scope section
Scott Graham <scottmg@google.com>
parents: 117
diff changeset
   176
      on.</p>
114
c788513485e5 rough attempt at scope qualification
Scott Graham <scottmg@google.com>
parents: 113
diff changeset
   177
c788513485e5 rough attempt at scope qualification
Scott Graham <scottmg@google.com>
parents: 113
diff changeset
   178
    </section>
c788513485e5 rough attempt at scope qualification
Scott Graham <scottmg@google.com>
parents: 113
diff changeset
   179
c788513485e5 rough attempt at scope qualification
Scott Graham <scottmg@google.com>
parents: 113
diff changeset
   180
    <section>
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   181
      <h2><a>Gamepad</a> Interface</h2>
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   182
      <p>
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   183
        This interface defines an individual gamepad device.
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   184
      </p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   185
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   186
      <dl title='interface Gamepad' class='idl'>
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   187
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   188
        <dt>readonly attribute string id</dt>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   189
        <dd>
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   190
          An identification string for the gamepad.
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   191
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   192
          This string identifies the brand or style of connected gamepad
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   193
          device. Typically, this will include the USB vendor and a product
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   194
          ID.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   195
        </dd>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   196
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   197
        <dt>readonly attribute long index</dt>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   198
        <dd>
117
fd9ea2f17eaa document->navigator
Scott Graham <scottmg@google.com>
parents: 114
diff changeset
   199
          The index of the gamepad in the <a>Navigator</a>.
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   200
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   201
          When multiple gamepads are connected to a <a>user agent</a>,
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   202
          indices MUST be assigned on a first-come, first-serve basis,
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   203
          starting at zero. If a gamepad is disconnected, previously assigned
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   204
          indices MUST NOT be reassigned to gamepads that continue to be
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   205
          connected. However, if a gamepad is disconnected, and subsequently
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   206
          the same or a different gamepad is then connected, index entries
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   207
          MUST be reused.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   208
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   209
        </dd>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   210
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   211
        <dt>readonly attribute DOMTimeStamp timestamp</dt>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   212
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   213
        <dd>
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   214
          Last time the data for this gamepad was updated.
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   215
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   216
          Timestamp is a monotonically increasing value that allows the author
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   217
          to determine if the <code>axes</code> and <code>button</code> data
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   218
          have been updated from the hardware, relative to a previously saved
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   219
          timestamp.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   220
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   221
        </dd>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   222
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   223
        <dt>readonly attribute float[] axes</dt>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   224
        <dd>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   225
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   226
          Array of values for all axes of the gamepad.
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   227
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   228
          All axis values MUST be linearly normalized to the range [-1.0 ..
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   229
          1.0]. As appropriate, -1.0 SHOULD correspond to "up" or "left", and
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   230
          1.0 SHOULD correspond to "down" or "right".
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   231
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   232
          Axes that are drawn from a 2D input device SHOULD appear next to
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   233
          each other in the axes array, X then Y.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   234
          
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   235
          It is RECOMMENDED that axes appear in decreasing order of
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   236
          importance, such that element 0 and 1 typically represent the X and
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   237
          Y axis of a directional stick.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   238
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   239
        </dd>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   240
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   241
        <dt>readonly attribute float[] buttons</dt>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   242
        <dd>
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   243
          Array of values for all buttons of the gamepad.
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   244
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   245
          All button values MUST be linearly normalized to the range [0.0 ..
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   246
          1.0]. 0.0 MUST mean fully unpressed, and 1.0 MUST mean fully
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   247
          pressed.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   248
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   249
          It is RECOMMENDED that buttons appear in decreasing importance such
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   250
          that the primary button, secondary button, tertiary button, and so
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   251
          on appear as elements 0, 1, 2, ... in the buttons array.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   252
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   253
        </dd>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   254
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   255
      </dl>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   256
    </section>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   257
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   258
    <section>
117
fd9ea2f17eaa document->navigator
Scott Graham <scottmg@google.com>
parents: 114
diff changeset
   259
      <h2><a>Navigator</a> Interface extension</h2>
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   260
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   261
      <p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   262
117
fd9ea2f17eaa document->navigator
Scott Graham <scottmg@google.com>
parents: 114
diff changeset
   263
        This partial interface defines an extension to the <a>Navigator</a>
112
867f493eeb09 use partial interface instead of new one for Document extension
Scott Graham <scottmg@google.com>
parents: 111
diff changeset
   264
        interface.
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   265
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   266
      </p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   267
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   268
117
fd9ea2f17eaa document->navigator
Scott Graham <scottmg@google.com>
parents: 114
diff changeset
   269
      <dl title='partial interface Navigator' class='idl'>
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   270
        <dt>readonly attribute Gamepad[] gamepads</dt>
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   271
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   272
        <dd>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   273
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   274
          The currently connected and interacted-with gamepads.
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   275
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   276
          Gamepads MUST only appear in the list if they are currently
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   277
          connected to the <a>user agent</a>, and have been interacted with by
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   278
          the user. Otherwise, they MUST not appear in the list to avoid a
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   279
          malicious page from fingerprinting the user based on connected
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   280
          devices.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   281
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   282
        </dd>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   283
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   284
      </dl>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   285
    </section>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   286
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   287
    <section>
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   288
      <h2><a>GamepadEvent</a> Interface</h2>
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   289
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   290
      <dl title='interface GamepadEvent' class='idl'>
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   291
        <dt>readonly attribute Gamepad gamepad</dt>
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   292
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   293
        <dd>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   294
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   295
            The single gamepad attribute provides access to the associated
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   296
            gamepad data for this event.
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   297
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   298
        </dd>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   299
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   300
      </dl>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   301
    </section>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   302
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   303
      
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   304
    <section class="informative">
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   305
        <h2>Usage Examples</h2>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   306
          
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   307
          <p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   308
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   309
            The example below demonstrates typical access to gamepads. Note
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   310
            the relationship with the <a>WindowAnimationTiming</a>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   311
            [[!ANIMATION-TIMING]] interface.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   312
          </p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   313
          
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   314
          <section>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   315
              <pre class="example">
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   316
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   317
function runAnimation()
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   318
{
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   319
    window.requestAnimationFrame(runAnimation);
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   320
117
fd9ea2f17eaa document->navigator
Scott Graham <scottmg@google.com>
parents: 114
diff changeset
   321
    for (var i = 0; i < navigator.gamepads.length; ++i)
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   322
    {
117
fd9ea2f17eaa document->navigator
Scott Graham <scottmg@google.com>
parents: 114
diff changeset
   323
        var pad = navigator.gamepads[i];
111
fa6eba984b7f joy -> pad
Scott Graham <scottmg@google.com>
parents: 110
diff changeset
   324
        // todo; simple demo of displaying pad.axes and pad.buttons
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   325
    }
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   326
}
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   327
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   328
window.requestAnimationFrame(runAnimation);
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   329
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   330
              </pre>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   331
          </section>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   332
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   333
          <div class="practice"> 
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   334
              <p> 
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   335
              <span id="practice-timing" class="practicelab">Coordination with
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   336
              WindowAnimationTiming</span></p> 
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   337
              <p class="practicedesc"> 
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   338
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   339
              Interactive applications will typically be using the
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   340
              <a>WindowAnimationTiming</a> interface to drive animation, and
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   341
              will want coordinate animation with user gamepad input. As
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   342
              such, the gamepad data should be polled as closely as possible
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   343
              to immediately before the animation callbacks are executed, and
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   344
              with frequency matching that of the animation. That is, if the
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   345
              animation callbacks are running at 60Hz, the gamepad inputs
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   346
              should also be sampled at that rate.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   347
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   348
              </p> 
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   349
          </div> 
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   350
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   351
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   352
    </section>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   353
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   354
    <section>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   355
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   356
      <h3 id="event-gamepadconnected">The <dfn class="event">gamepadconnected</dfn> event</h3>
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   357
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   358
        <p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   359
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   360
          A <a>user agent</a> MUST dispatch this event type to indicate the
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   361
          user has connected a gamepad. If a gamepad was already connected
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   362
          when the page was loaded, the <a>gamepadconnected</a> event will be
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   363
          dispatched when the user presses a button or moves an axis.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   364
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   365
        </p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   366
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   367
    </section>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   368
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   369
    <section>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   370
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   371
        <h3 id="event-gamepaddisconnected">The <dfn class="event">gamepaddisconnected</dfn> event</h3>
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   372
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   373
        <p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   374
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   375
          When a gamepad is disconnected from the <a>user agent</a>, if the
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   376
          <a>user agent</a> has previously dispatched a
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   377
          <a>gamepadconnected</a> event, a <a>gamepaddisconnected</a> event
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   378
          MUST be dispatched.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   379
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   380
        </p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   381
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   382
    </section>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   383
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   384
    <section>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   385
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   386
        <h3>Other events</h3>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   387
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   388
        <p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   389
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   390
        <i>More discussion needed, on whether to include or exclude axis and button
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   391
        changed events, and whether to roll them more together
109
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   392
        (<code>gamepadchanged</code>?), separate somewhat
3d086bcaabe9 joystick -> gamepad
Scott Graham <scottmg@google.com>
parents: 108
diff changeset
   393
        (<code>gamepadaxischanged</code>?), or separate by individual axis
108
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   394
        and button.</i>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   395
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   396
        </p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   397
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   398
    </section>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   399
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   400
    <section class='appendix informative'>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   401
      <h2>Acknowledgements</h2>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   402
      <p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   403
        Many have made contributions in code, comments, or documentation: 
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   404
      </p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   405
        <ul>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   406
            <li>David Humphrey</li>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   407
            <li>Gregg Tavares</li>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   408
            <li>Jason Orendorff</li>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   409
            <li>Olli Pettay</li>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   410
            <li>Rick Waldron</li>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   411
        </ul>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   412
      <p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   413
        Please let me know if I have inadvertently omitted your name.
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   414
      </p>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   415
    </section>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   416
  </body>
d1f13495dcea initial prototype, still called joystick in document, rather than gamepad
Scott Graham <scottmg@google.com>
parents:
diff changeset
   417
</html>