Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update getGamepads to include steps for copying gamepads #172

Open
wants to merge 5 commits into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 62 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -656,13 +656,13 @@ <h3>
<ol>
<li>Let |gamepad:Gamepad| be a newly created {{Gamepad}} instance:
<ol>
<li>Initialize |gamepad|'s {{Gamepad/id}} attribute to an
<li>Initialize |gamepad|.{{Gamepad/id}} to an
identification string for the gamepad.
</li>
<li>Initialize |gamepad|'s {{Gamepad/index}} attribute to the
<li>Initialize |gamepad|.{{Gamepad/index}} to the
result of [=selecting an unused gamepad index=] for |gamepad|.
</li>
<li>Initialize |gamepad|'s {{Gamepad/mapping}} attribute to the
<li>Initialize |gamepad|.{{Gamepad/mapping}} to the
result of [=selecting a mapping=] for the gamepad device.
</li>
<li>Initialize |gamepad|.{{Gamepad/[[connected]]}} to `true`.
Expand Down Expand Up @@ -1702,17 +1702,70 @@ <h3>
<li>[=list/For each=] |gamepad:Gamepad| of
[=this=].{{Navigator/[[gamepads]]}}:
<ol>
<li>If |gamepad| is not `null` and
|gamepad|.{{Gamepad/[[exposed]]}} is `false`:
<li>If |gamepad| is `null` or |gamepad|.{{Gamepad/[[exposed]]}}
is `false`, [=list/append=] `null` to |gamepads|.
</li>
<li>Otherwise:
<ol>
<li>Set |gamepad|.{{Gamepad/[[exposed]]}} to `true`.
<li>Let |axesCopy| be a new [=list=].
</li>
<li>[=list/For each=] |axis| of
|gamepad|.{{Gamepad/[[axes]]}}, [=list/append=] |axis| to
|axesCopy|.
</li>
<li>Let |buttonsCopy| be a new [=list=].
</li>
<li>Set |gamepad|.{{Gamepad/[[timestamp]]}} to |now|.
<li>[=list/For each=] |button| of
|gamepad|.{{Gamepad/[[buttons]]}}:
<ol>
<li>Let |buttonCopy| be a newly created {{GamepadButton}}
instance:
<ol>
<li>Initialize |buttonCopy|.{{GamepadButton/pressed}}
to |button|.{{GamepadButton/pressed}}.
</li>
<li>Initialize |buttonCopy|.{{GamepadButton/touched}}
to |button|.{{GamepadButton/touched}}.
</li>
<li>Initialize |buttonCopy|.{{GamepadButton/value}}
to |button|.{{GamepadButton/value}}.
</li>
</ol>
</li>
<li>[=list/Append=] |buttonCopy| to |buttonsCopy|.
</li>
</ol>
</li>
<li>Let |gamepadCopy:Gamepad| be a newly created {{Gamepad}}
instance:
<ol>
<li>Initialize |gamepadCopy|'s {{Gamepad/id}} attribute
to |gamepad|.{{Gamepad/id}}.
</li>
<li>Initialize |gamepadCopy|'s {{Gamepad/index}}
attribute to |gamepad|.{{Gamepad/index}}.
</li>
<li>Initialize |gamepadCopy|'s {{Gamepad/mapping}}
attribute to |gamepad|.{{Gamepad/mapping}}.
</li>
<li>Initialize |gamepadCopy|.{{Gamepad/[[connected]]}} to
|gamepad|.{{Gamepad/[[connected]]}}.
</li>
<li>Initialize |gamepadCopy|.{{Gamepad/[[timestamp]]}} to
|gamepad|.{{Gamepad/[[timestamp]]}}.
</li>
<li>Initialize |gamepadCopy|.{{Gamepad/[[axes]]}} to
|axesCopy|.
</li>
<li>Initialize |gamepadCopy|.{{Gamepad/[[buttons]]}} to
|buttonsCopy].
</li>
</ol>
</li>
<li>[=list/Append=] |gamepadCopy| to |gamepads|.
</li>
</ol>
</li>
<li>[=list/Append=] |gamepad| to |gamepads|.
</li>
</ol>
</li>
<li>Return |gamepads|.
Expand Down
Loading