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

Add algorithms for getGamepads and events #151

Merged
merged 8 commits into from Jul 8, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions index.html
Expand Up @@ -314,7 +314,7 @@ <h3>Receiving new input values</h3>
<li>Let |axisValues:sequence&lt;unsigned long&gt;| be the gamepad's [=list=] of logical axis input values.
<li>Let |axisCount:long| be the length of |axisValues|.
<li>Initialize |rawAxisIndex:long| to be 0.
<li>While |rawAxisIndex| < |axisCount|:
<li>While |rawAxisIndex| is less than |axisCount|:
<ol>
<li>Let |mappedIndex:long| be the value for key |rawAxisIndex| in |gamepad|.{{[[axisMapping]]}}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we are using an [=ordered map=], Infra let's us do:

Suggested change
<li>Let |mappedIndex:long| be the value for key |rawAxisIndex| in |gamepad|.{{[[axisMapping]]}}.
<li>Let |mapping:ordered map| be |gamepad|.{{[[axisMapping]]}}.
<li>Let |mappedIndex:long| be |mapping|["rawAxisIndex"].

And so on...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've replaced the "value for key..." language with ordered map syntax but decided not to pull out |mapping|, maybe I should add it for readability? WDYT?

<li>Let |logicalValue:unsigned long| be the value at index |rawAxisIndex| in |axisValues|.
Expand All @@ -332,7 +332,7 @@ <h3>Receiving new input values</h3>
<li>Let |buttonValues:sequence&lt;unsigned long&gt;| be the gamepad's [=list=] of logical button input values</a>.
<li>Let |buttonCount:long| be the length of |buttonValues|.
<li>Initialize |rawButtonIndex:long| to be 0.
<li>While |rawButtonIndex| < |buttonCount|:
<li>While |rawButtonIndex| is less than |buttonCount|:
<ol>
<li>Let |mappedIndex:long| be the value for key |rawButtonIndex| in |gamepad|.{{[[buttonMapping]]}}.
nondebug marked this conversation as resolved.
Show resolved Hide resolved
<li>Let |logicalValue:unsigned long| be the value at index |rawButtonIndex| in |buttonValues|.
Expand Down Expand Up @@ -870,7 +870,7 @@ <h3 id="event-gamepadconnected">
<ol>
<li>Let |gamepadsLength:long| be the length of |navigator|.{{Navigator/[[gamepads]]}}.
<li>Initialize |gamepadIndex:long| to be 0.
<li>While |gamepadIndex| < |gamepadsLength|:
<li>While |gamepadIndex| is less than |gamepadsLength|:
<ol>
<li>Let |gamepad:Gamepad?| be the value at index |gamepadIndex| in |navigator|.{{Navigator/[[gamepads]]}}.
<li>If |gamepad| is `null`, then return |gamepadIndex|.
Expand Down Expand Up @@ -900,7 +900,7 @@ <h3 id="event-gamepadconnected">
<li>Initialize |mappedIndexList:sequence&lt;long&gt;| to be an empty [=list=].
<li>Initialize |axesLength:long| to be 0.
<li>Initialize |rawInputIndex:long| to be 0.
<li>While |rawInputIndex| < |inputCount|:
<li>While |rawInputIndex| is less than |inputCount|:
<ol>
<li>If the the gamepad axis at index |rawInputIndex| <a>represents a Standard Gamepad axis</a>:
<ol>
Expand All @@ -912,7 +912,7 @@ <h3 id="event-gamepadconnected">
<ol>
<li>Set the value for key |rawInputIndex| in |gamepad|.{{Gamepad/[[axisMapping]]}} to |canonicalIndex|.
<li>Append |canonicalIndex| to |mappedIndexList|.
<li>If |canonicalIndex| + 1 > |axesLength|, then set |axesLength| to |canonicalIndex| + 1.
<li>If |canonicalIndex| + 1 is greater than |axesLength|, then set |axesLength| to |canonicalIndex| + 1.
</ol>
</ol>
<p>
Expand All @@ -930,10 +930,10 @@ <h3 id="event-gamepadconnected">
</ol>
<li>Set the value for key |rawInputIndex| in |gamepad|.{{Gamepad/[[axisMapping]]}} to |axisIndex|.
<li>Append |axisIndex| to |mappedIndexList|.
<li>If |axisIndex| + 1 > |axesLength|, then set |axesLength| to |axisIndex| + 1.
<li>If |axisIndex| + 1 is greater than |axesLength|, then set |axesLength| to |axisIndex| + 1.
</ol>
<li>Set |axisIndex| to 0.
<li>While |axisIndex| < |axesLength|:
<li>While |axisIndex| is less than |axesLength|:
<ol>
<li>Append 0 to |axes|.
<li>Increment |axisIndex|.
Expand All @@ -954,7 +954,7 @@ <h3 id="event-gamepadconnected">
<li>Initialize |mappedIndexList:sequence&lt;long&gt;| to be an empty [=list=].
<li>Initialize |buttonsLength:long| to be 0.
<li>Initialize |rawInputIndex:long| to be 0.
<li>While |rawInputIndex| < |inputCount|:
<li>While |rawInputIndex| is less than |inputCount|:
<ol>
<li>If the the gamepad button at index |rawInputIndex| <a>represents a Standard Gamepad button</a>:
<ol>
Expand All @@ -966,7 +966,7 @@ <h3 id="event-gamepadconnected">
<ol>
<li>Set the value for key |rawInputIndex| in |gamepad|.{{Gamepad/[[buttonMapping]]}} to |canonicalIndex|.
<li>Append |canonicalIndex| to |mappedIndexList|.
<li>If |canonicalIndex| + 1 > |buttonsLength|, then set |buttonsLength| to |canonicalIndex| + 1.
<li>If |canonicalIndex| + 1 is greater than |buttonsLength|, then set |buttonsLength| to |canonicalIndex| + 1.
</ol>
</ol>
<p>
Expand All @@ -984,10 +984,10 @@ <h3 id="event-gamepadconnected">
</ol>
<li>Set the value for key |rawInputIndex| in |gamepad|.{{Gamepad/[[buttonMapping]]}} to |buttonIndex|.
<li>Append |buttonIndex| to |mappedIndexList|.
<li>If |buttonIndex| + 1 > |buttonsLength|, then set |buttonsLength| to |buttonIndex| + 1.
<li>If |buttonIndex| + 1 is greater than |buttonsLength|, then set |buttonsLength| to |buttonIndex| + 1.
</ol>
<li>Set |buttonIndex| to 0.
<li>While |buttonIndex| < |buttonsLength|:
<li>While |buttonIndex| is less than |buttonsLength|:
<ol>
<li>Let |button:GamepadButton| be a {{GamepadButton}}.
<li>Set |button|.{{GamepadButton/pressed}} to `false`.
Expand Down