forked from w3c/gamepad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extensions.html
434 lines (373 loc) · 15.8 KB
/
extensions.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
<!DOCTYPE html>
<html lang="en">
<head>
<title>Gamepad Extensions</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--
=== NOTA BENE ===
For the three scripts below, if your spec resides on dev.w3 you can check them
out in the same tree and use relative links so that they'll work offline,
-->
<script src='https://www.w3.org/Tools/respec/respec-w3c-common' class='remove'></script>
<script class='remove'>
var respecConfig = {
// specification status (e.g. WD, LCWD, NOTE, etc.). If in doubt use ED.
specStatus: "ED",
// the specification's short name, as in http://www.w3.org/TR/short-name/
shortName: "gamepad-extensions",
// if your specification has a subtitle that goes below the main
// formal title, define it here
// subtitle : "an excellent document",
// if you wish the publication date to be other than today, set this
//publishDate: "2011-01-01",
// if the specification's copyright date is a range of years, specify
// the start date here:
// copyrightStart: "2005"
// if there is a previously published draft, uncomment this and set its YYYY-MM-DD date
// and its maturity status
processVersion: "2016",
// if there a publicly available Editor's Draft, this is the link
edDraftURI: "https://w3c.github.io/gamepad/extensions.html",
// if this is a LCWD, uncomment and set the end of its review period
// lcEnd: "2009-08-05",
// editors, add as many as you like
// only "name" is required
editors: [
{ name: "Brandon Jones", url: "http://tojicode.com/",
company: "Google", companyURL: "http://www.google.com/",
w3cid: 87824 },
],
otherLinks: [{
key: 'Repository and Participation',
data: [
{
value: 'We are on GitHub.',
href: 'https://github.com/w3c/gamepad/'
}, {
value: 'File a bug/issue.',
href: 'https://github.com/w3c/gamepad/issues/new?title=[Extensions]+'
}, {
value: 'Commit history.',
href: 'https://github.com/w3c/gamepad/commits'
}, {
value: 'Mailing list search.',
href: 'https://www.w3.org/Search/Mail/Public/search?keywords=&hdr-1-name=subject&hdr-1-query=gamepad&index-grp=Public_FULL&index-type=t&type-index=public-webapps'
}
]
}],
// authors, add as many as you like.
// This is optional, uncomment if you have authors as well as editors.
// only "name" is required. Same format as editors.
//authors: [
// { name: "Your Name", url: "http://example.org/",
// company: "Your Company", companyURL: "http://example.com/" },
//],
// name of the WG
wg: "Web Platform Working Group",
// URI of the public WG page
wgURI: "https://www.w3.org/WebPlatform/WG/",
license: "w3c-software-doc",
// name (with the @w3c.org) of the public mailing to which comments are due
wgPublicList: "public-webapps",
// URI of the patent status for this WG, for Rec-track documents
// !!!! IMPORTANT !!!!
// This is important for Rec-track documents, do not copy a patent URI from a random
// document unless you know what you're doing. If in doubt ask your friendly neighbourhood
// Team Contact.
wgPatentURI: "https://www.w3.org/2004/01/pp-impl/83482/status",
};
</script>
<style>
.event {
color: #459900;
font-family: monospace;
}
pre.idl {
white-space: pre-wrap;
}
</style>
</head>
<body>
<section id='abstract'>
Extensions to the base Gamepad specification to enable access to more
advanced device capabilities.
</section>
<section id='sotd'>
If you have comments for this spec, please send them to
<a href="mailto:[email protected]">[email protected]</a>
with a Subject: prefix of <code>[gamepad]</code>. See
<a href="https://www.w3.org/Bugs/Public/buglist.cgi?product=WebAppsWG&component=Gamepad&resolution=---">Bugzilla</a>
for this specification's open bugs.
</section>
<section id='introduction' class='informative'>
<h2>Introduction</h2>
<p>The Gamepad API provides a tightly scoped interface to gamepad devices
and is focused on the most common elements of those devices, namely axis
and button inputs. It specifically excludes support for more complex
devices (e.g., those that do motion tracking or haptic feedback).</p>
<p>However, some uses of gamepads (e.g., those paired with Virtual
Reality headsets) rely heavily on those more advanced features. This
supplemetary spec describes extensions to the base API to accommodate
those use cases. If they prove to be broadly useful, the hope is that
they will be eventually merged into the <a href="./">main spec</a>.</p>
</section>
<section id='conformance'></section>
<section>
<h2><dfn>GamepadHand</dfn> Enum</h2>
<p>
This enum defines the set of possible hands a gamepad may be held by.
</p>
<pre class="idl">
enum GamepadHand {
"", /* unknown, both hands, or not applicable */
"left",
"right"
};
</pre>
<dl data-dfn-for="GamepadHand">
<dt><dfn>""</dfn> (the empty string)</dt>
<dd>
The empty string indicates the hand that is holding the gamepad is
unknown or not applicable (e.g., if the gamepad is held with
two hands).
</dd>
<dt><dfn>left</dfn></dt>
<dd>
Gamepad is held or is most likely to be held in the left hand.
</dd>
<dt><dfn>right</dfn></dt>
<dd>
Gamepad is held or is most likely to be held in the right hand.
</dd>
</dl>
</section>
<section>
<h2><dfn>GamepadHapticActuator</dfn> Interface</h2>
<p>
Each <code>GamepadHapticActuator</code> corresponds to a motor or other
actuator that can apply a force for the purposes of haptic feedback.
</p>
<pre class="idl">
[Exposed=Window]
interface GamepadHapticActuator {
readonly attribute GamepadHapticActuatorType type;
Promise<boolean> pulse(double value, double duration);
};
</pre>
<dl data-dfn-for="GamepadHapticActuator">
<dt><dfn>pulse()</dfn></dt>
<dd>
<p>
<code>pulse()</code> applies a value to the actuator for
<var>duration</var> milliseconds. The value passed to
<code>pulse()</code> is clamped to limits defined by the actuator
type. The returned Promise will resolve <code>true</code> once the
pulse has completed.
</p>
<p>
Repeated calls to <code>pulse()</code> override the previous
values.
</p>
</dd>
</dl>
</section>
<section>
<h2><dfn>GamepadHapticActuatorType</dfn> Enum</h2>
<p>
The actuator type determines the force applied for a given
<var>value</var> in <code>GamepadHapticActuator.pulse()</code>.
</p>
<pre class="idl">
enum GamepadHapticActuatorType {
"vibration"
};
</pre>
<dl data-dfn-for="GamepadHapticActuatorType">
<dt><dfn>vibration</dfn></dt>
<dd>
Vibration is a rumbling effect often implemented as an offset weight
driven on a rotational axis. The <code>value</code> of a vibration
force determines the frequency of the rumble effect and is
normalized between <code>0.0</code> and <code>1.0</code>. The
neutral value is <code>0.0</code>.
</dd>
</dl>
</section>
<section>
<h2><dfn>GamepadPose</dfn> Interface</h2>
<p>
This interface defines the gamepad's position, orientation, velocity,
and acceleration.
</p>
<pre class="idl">
[Exposed=Window]
interface GamepadPose {
readonly attribute boolean hasOrientation;
readonly attribute boolean hasPosition;
readonly attribute Float32Array? position;
readonly attribute Float32Array? linearVelocity;
readonly attribute Float32Array? linearAcceleration;
readonly attribute Float32Array? orientation;
readonly attribute Float32Array? angularVelocity;
readonly attribute Float32Array? angularAcceleration;
};
</pre>
<dl data-dfn-for="GamepadPose">
<dt><dfn>hasOrientation</dfn></dt>
<dd>
The <code>hasOrientation</code> attribute MUST return whether the
gamepad is capable of tracking its orientation.
</dd>
<dt><dfn>hasPosition</dfn></dt>
<dd>
The <code>hasPosition</code> attribute MUST return whether the
gamepad is capable of tracking its position.
</dd>
<dt><dfn>position</dfn></dt>
<dd>
<p>
Position of the gamepad as a 3D vector, given in meters from an
origin point, which is determined by the gamepad hardware and
MAY be the position of the gamepad when first polled if no other
reference point is available. The coordinate system uses these axis
definitions, assuming the user is holding the gamepad in the
forward orientation:
</p>
<ul>
<li>Positive X is to the user's right.</li>
<li>Positive Y is up.</li>
<li>Positive Z is behind the user.</li>
</ul>
<p>
MUST be <code>null</code> if the gamepad is incapable of providing
positional data. When not <code>null</code>, MUST be a
three-element array.
</p>
</dd>
<dt><dfn>linearVelocity</dfn></dt>
<dd>
Linear velocity of the gamepad in meters per second. MUST be
<code>null</code> if the sensor is incapable of providing linear
velocity. When not <code>null</code>, MUST be a three-element array.
</dd>
<dt><dfn>linearAcceleration</dfn></dt>
<dd>
Linear acceleration of the gamepad in meters per second. MUST be
<code>null</code> if the sensor is incapable of providing linear
acceleration. When not <code>null</code>, MUST be a three-element
array.
</dd>
<dt><dfn>orientation</dfn></dt>
<dd>
Orientation of the gamepad as a quaternion. An orientation of
<code>[0, 0, 0, 1]</code> is considered to be <code>forward</code>.
The forward direction MUST be determined by the gamepad hardware. The
forward direction MAY be the orientation of the hardware when it was
first polled if no other reference orientation is available. If the
sensor is incapable of providing orientation data, the orientation
MUST be <code>null</code>. When not <code>null</code>, the
<code>orientation</code> MUST be a four-element array.
</dd>
<dt><dfn>angularVelocity</dfn></dt>
<dd>
Angular velocity of the gamepad in meters per second. MUST be
<code>null</code> if the sensor is incapable of providing angular
velocity. When not <code>null</code>, the
<code>angularVelocity</code> MUST be a three-element array.
</dd>
<dt><dfn>angularAcceleration</dfn></dt>
<dd>
Angular acceleration of the gamepad in meters per second. MUST be
<code>null</code> if the sensor is incapable of providing angular
acceleration. When not <code>null</code>,
<code>angularAcceleration</code> MUST be a three-element array.
</dd>
</dl>
</section>
<section data-dfn-for="GamepadTouch">
<h2><dfn>GamepadTouch</dfn> Interface</h2>
<p>
This interface defines a single touch event on a gamepad device that
supports input. The event consists of a touch id that uniquely
identifies the touch point from the time the input medium (e.g. finger,
stylus, etc) makes contact with the touch device, up to the time the
input medium is no longer making contact with the touch device.
</p>
<pre class="idl">
[Exposed=Window, SecureContext]
interface GamepadTouch {
readonly attribute unsigned long touchId;
readonly attribute octet surfaceId;
readonly attribute Float32Array position;
readonly attribute Uint32Array? surfaceDimensions;
};
</pre>
<dl>
<dt><dfn>touchId</dfn> attribute</dt>
<dd>
Unique id of the touch event. Range is [0, 4294967295]. The user agent
is responsible for incrementing the touchId for each subsequent touch
event based on information provided by the device API. {{GamepadTouch/touchId}} SHOULD
be set to a default value of 0 when a new {{Gamepad}} object is created.
</dd>
<dt><dfn>surfaceId</dfn></dt>
<dd>
Unique id of the surface that generated the touch event.
</dd>
<dt><dfn>position</dfn></dt>
<dd>
x, y coordinates of the touch event. Range of each coordinate is
normalized to [-1.0, 1.0]. Along the x-axis, -1.0 references the
leftmost coordinate and 1.0 references the rightmost coordinate. Along
the y-axis, -1.0 references the topmost coordinate and 1.0 references
the bottommost coordinate. MUST be a two-element array.
</dd>
<dt><dfn>surfaceDimensions</dfn></dt>
<dd>
Width and height of the touch surface in integer units. When not
<code>null</code>, MUST be a two-element array.
</dl>
</section>
<section>
<h2>Partial <dfn>Gamepad</dfn> Interface</h2>
<p>
This partial interface supplements the Gamepad interface described in
the main <a href="https://w3c.github.io/gamepad/">Gamepad spec</a>.
</p>
<pre class="idl">
partial interface Gamepad {
readonly attribute GamepadHand hand;
readonly attribute FrozenArray<GamepadHapticActuator> hapticActuators;
readonly attribute GamepadPose? pose;
readonly attribute FrozenArray<GamepadTouch>? touchEvents;
};
</pre>
<dl data-dfn-for="Gamepad">
<dt><dfn>hand</dfn></dt>
<dd>
Describes the hand the controller is held in or is most likely to be
held in.
</dd>
<dt><dfn>hapticActuators</dfn></dt>
<dd>
A list of all the haptic actuators in the gamepad. The same object
MUST be returned until the user agent needs to return different
values (or values in a different order).
</dd>
<dt><dfn>pose</dfn></dt>
<dd>
The current pose of the gamepad, if supported by the hardware.
Includes position, orientation, velocity, and acceleration. If the
hardware cannot supply any pose values, MUST be set to
<code>null</code>.
</dd>
<dt><dfn>touchEvents</dfn></dt>
<dd>
A list of touch events generated from all touch surfaces. <code>null</code>
if the device does not support touch events.
</dd>
</dl>
</section>
</body>
</html>