Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 572119 of Gamepad API

  • Revision slug: Web/API/Gamepad_API
  • Revision title: Gamepad API
  • Revision id: 572119
  • Created:
  • Creator: Ted_Mielczarek
  • Is current revision? No
  • Comment

Revision Content

{{SeeCompatTable}}

The Gamepad API is a way for developers to access and respond to signals from gamepads and other game controllers in a simple, consistent way. It contains three interfaces, two events and one specialist function, to respond to gamepads being connected and disconnected, and to access other information about the gamepads themselves, and what buttons and other controls are currently being pressed.

Reference

The following interfaces are defined in the Gamepad API

  • {{domxref("Gamepad")}}
  • {{domxref("GamepadButton")}}
  • {{domxref("GamepadEvent")}}

The Gamepad API also defines some events and a specialist function:

Gamepad Window events
Specialist events on the {{domxref("Window")}} object that allows us to react when a gamepad is connected or disconnected: {{event('gamepadconnected')}} and {{event('gamepaddisconnected')}}. Event handlers can be easily set using {{domxref("Window.ongamepadconnected")}} and {{domxref("Window.ongamepaddisconnected")}}.
{{domxref("Navigator.getGamepads()")}}
An extension to the {{domxref("Navigator")}} object that returns an array of {{domxref("Gamepad")}} objects, one for each connected gamepad.

Tutorials and guides

Specifications

Specification Status Comment
{{SpecName('Gamepad', '', 'The Gamepad API specification')}} {{Spec2('Gamepad')}}  

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
General support

21.0 {{ property_prefix("webkit") }}
25.0

{{ CompatGeckoDesktop("29.0") }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
General support {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}

See also

Revision Source

<p>{{SeeCompatTable}}</p>
<p>The <strong>Gamepad API</strong> is a way for developers to access and respond to signals from gamepads and other game controllers in a simple, consistent way. It contains three interfaces, two events and one specialist function, to respond to gamepads being connected and disconnected, and to access other information about the gamepads themselves, and what buttons and other controls are currently being pressed.</p>
<h2 id="Reference">Reference</h2>
<p>The following interfaces are defined in the Gamepad API</p>
<div class="index">
 <ul>
  <li>{{domxref("Gamepad")}}</li>
  <li>{{domxref("GamepadButton")}}</li>
  <li>{{domxref("GamepadEvent")}}</li>
 </ul>
</div>
<p>The Gamepad API also defines some events and a specialist function:</p>
<dl>
 <dt>
  Gamepad <code>Window</code> events</dt>
 <dd>
  Specialist events on the {{domxref("Window")}} object that allows us to react when a gamepad is connected or disconnected: {{event('gamepadconnected')}} and {{event('gamepaddisconnected')}}. Event handlers can be easily set using {{domxref("Window.ongamepadconnected")}} and {{domxref("Window.ongamepaddisconnected")}}.</dd>
 <dt>
  {{domxref("Navigator.getGamepads()")}}</dt>
 <dd>
  An extension to the {{domxref("Navigator")}} object that returns an array of {{domxref("Gamepad")}} objects, one for each connected gamepad.</dd>
</dl>
<h2 id="Tutorials_and_guides">Tutorials and guides</h2>
<ul>
 <li><a href="/en-US/docs/Web/Guide/API/Gamepad">Using the Gamepad API</a></li>
</ul>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('Gamepad', '', 'The Gamepad API specification')}}</td>
   <td>{{Spec2('Gamepad')}}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Chrome</th>
    <th>Firefox (Gecko)</th>
    <th>Internet Explorer</th>
    <th>Opera</th>
    <th>Safari (WebKit)</th>
   </tr>
   <tr>
    <td>General support</td>
    <td>
     <p>21.0 {{ property_prefix("webkit") }}<br />
      25.0</p>
    </td>
    <td>{{ CompatGeckoDesktop("29.0") }}</td>
    <td>{{ CompatNo() }}</td>
    <td>{{ CompatNo() }}</td>
    <td>{{ CompatNo() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<div id="compat-mobile">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Android</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>IE Phone</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>General support</td>
    <td>{{ CompatNo() }}</td>
    <td>{{ CompatNo() }}</td>
    <td>{{ CompatNo() }}</td>
    <td>{{ CompatNo() }}</td>
    <td>{{ CompatNo() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<h2 id="See_also">See also</h2>
<ul>
 <li><a class="external text" href="https://dvcs.w3.org/hg/webevents/raw-file/default/gamepad.html" rel="nofollow">Editor's Draft at the W3C</a></li>
 <li><a class="external text" href="https://hacks.mozilla.org/2013/12/the-gamepad-api/" rel="nofollow">The Gamepad API</a> by Ted Mielczarek and Robert Nyman</li>
 <li><a href="https://luser.github.io/gamepadtest/">Simple API demo page</a> (<a href="https://github.com/luser/gamepadtest">source</a>)</li>
</ul>
Revert to this revision