aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/gamepadevent
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/gamepadevent
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/gamepadevent')
-rw-r--r--files/zh-cn/web/api/gamepadevent/gamepad/index.html51
-rw-r--r--files/zh-cn/web/api/gamepadevent/gamepadevent/index.html50
-rw-r--r--files/zh-cn/web/api/gamepadevent/index.html64
3 files changed, 165 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/gamepadevent/gamepad/index.html b/files/zh-cn/web/api/gamepadevent/gamepad/index.html
new file mode 100644
index 0000000000..98e2d27351
--- /dev/null
+++ b/files/zh-cn/web/api/gamepadevent/gamepad/index.html
@@ -0,0 +1,51 @@
+---
+title: GamepadEvent.gamepad
+slug: Web/API/GamepadEvent/gamepad
+translation_of: Web/API/GamepadEvent/gamepad
+---
+<div>{{APIRef("Gamepad API")}}</div>
+
+<p><strong>{{domxref("GamepadEvent")}} interface </strong>的 <code><strong>GamepadEvent.gamepad</strong></code> 属性返回一个 {{domxref("Gamepad")}} 对象,为触发 {{event("gamepadconnected")}} 和{{event("gamepaddisconnected")}} 事件提供相关联控制器数据的访问。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">只读 属性 Gamepad gamepad;</pre>
+
+<h2 id="示例">示例</h2>
+
+<p>在触发的 {{domxref("Window.gamepadconnected")}} 事件上调用 <code>gamepad</code> 属性。</p>
+
+<pre class="brush: js">window.addEventListener("gamepadconnected", function(e) {
+ console.log("控制器已连接于 %d 位:%s. %d 个按钮, %d 个坐标方向。",
+ e.gamepad.index, e.gamepad.id,
+ e.gamepad.buttons.length, e.gamepad.axes.length);
+});</pre>
+
+<h2 id="值">值</h2>
+
+<p>一个 {{domxref("Gamepad")}} 对象。</p>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ <tr>
+ <td>{{SpecName("Gamepad", "#widl-GamepadEvent-gamepad", "GamepadEvent.gamepad")}}</td>
+ <td>{{Spec2("Gamepad")}}</td>
+ <td>初始定义</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("api.GamepadEvent.gamepad")}}</p>
+
+<h2 id="另请参阅">另请参阅</h2>
+
+<p><a href="/en-US/docs/Web/Guide/API/Gamepad">使用 Gamepad API</a></p>
diff --git a/files/zh-cn/web/api/gamepadevent/gamepadevent/index.html b/files/zh-cn/web/api/gamepadevent/gamepadevent/index.html
new file mode 100644
index 0000000000..3fd374433c
--- /dev/null
+++ b/files/zh-cn/web/api/gamepadevent/gamepadevent/index.html
@@ -0,0 +1,50 @@
+---
+title: GamepadEvent()
+slug: Web/API/GamepadEvent/GamepadEvent
+translation_of: Web/API/GamepadEvent/GamepadEvent
+---
+<p>{{APIRef("Gamepad API")}}</p>
+
+<p><strong><code>GamepadEvent_</code></strong> 构造函数用于创建一个新的 {{domxref("GamepadEvent")}} 对象。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">var gamepadEvent = new GamepadEvent(typeArg, options)</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><em>typeArg</em></dt>
+ <dd>一个 {{domxref("DOMString")}} ,必须为 <code>gamepadconnected</code> 或 <code>gamepaddisconnected</code>。</dd>
+ <dt><em>options</em> {{optional_inline}}</dt>
+ <dd>选项如下所示:
+ <ul>
+ <li><code>gamepad</code>: 一个 {{domxref("Gamepad")}} 实例,描述了与事件相关的控制器(对象)。</li>
+ </ul>
+ </dd>
+</dl>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('Gamepad','#gamepadevent-interface','GamepadEvent_')}}</td>
+ <td>{{Spec2('Gamepad')}}</td>
+ <td>初始定义</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p> </p>
+
+
+
+<p>{{Compat("api.Gamepad.Gamepad")}}</p>
diff --git a/files/zh-cn/web/api/gamepadevent/index.html b/files/zh-cn/web/api/gamepadevent/index.html
new file mode 100644
index 0000000000..6e2927bd82
--- /dev/null
+++ b/files/zh-cn/web/api/gamepadevent/index.html
@@ -0,0 +1,64 @@
+---
+title: GamepadEvent
+slug: Web/API/GamepadEvent
+translation_of: Web/API/GamepadEvent
+---
+<p>{{APIRef("Gamepad API")}}</p>
+
+<p>Gamepad API 的 GamepadEvent 接口包含对连接到系统的控制器的引用,这也是 gamepad 事件events {{domxref("Window.gamepadconnected")}} 与 {{domxref("Window.gamepaddisconnected")}} 被触发时响应的内容。</p>
+
+<h2 id="构造函数">构造函数</h2>
+
+<dl>
+ <dt>{{domxref("GamepadEvent.GamepadEvent","GamepadEvent()")}}</dt>
+ <dd>返回一个新的 <code>GamepadEvent</code> 对象。</dd>
+</dl>
+
+<h2 id="属性">属性</h2>
+
+<dl>
+ <dt>{{ domxref("GamepadEvent.gamepad") }} {{readonlyInline}}</dt>
+ <dd>返回一个 {{ domxref("Gamepad") }} 对象,提供触发事件的控制器数据的访问。</dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<p>在触发的 {{domxref("Window.gamepadconnected")}} 事件上调用控制器属性。</p>
+
+<pre class="brush: js">window.addEventListener("gamepadconnected", function(e) {
+ console.log("控制器已连接于 %d 位:%s。 %d 个按键,%d 个坐标方向。",
+ e.gamepad.index, e.gamepad.id,
+ e.gamepad.buttons.length, e.gamepad.axes.length);
+});</pre>
+
+<p>与 {{domxref("Window.gamepaddisconnected")}} 事件上的。</p>
+
+<pre class="brush: js">window.addEventListener("gamepaddisconnected", function(e) {
+ console.log("控制器已从 %d 位断开:%s",
+ e.gamepad.index, e.gamepad.id);
+});</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ <tr>
+ <td>{{SpecName("Gamepad", "#gamepadevent-interface", "GamepadEvent")}}</td>
+ <td>{{Spec2("Gamepad")}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
+
+<p>{{Compat("api.GamepadEvent")}}</p>
+
+<h2 id="另请参阅">另请参阅</h2>
+
+<p><a href="/en-US/docs/Web/Guide/API/Gamepad">使用 Gamepad API</a></p>