Skip to content

Commit

Permalink
Wip165 (#2)
Browse files Browse the repository at this point in the history
* Change touchEvent to touch

* Algorithm fixes

* Run tidy

* Remove event references
  • Loading branch information
bradleyneedham authored Jan 9, 2025
1 parent 11ac046 commit 141c3a2
Showing 1 changed file with 36 additions and 63 deletions.
99 changes: 36 additions & 63 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ <h2>
`null`
</td>
<td>
List of generated touch events.
List of generated touches.
</td>
</tr>
<tr>
Expand Down Expand Up @@ -477,9 +477,9 @@ <h2>
</dt>
<dd>
<p>
A list of {{GamepadTouch}} events generated from all touch
surfaces. If the device does not support touch events, MUST be set
to `null`.
A list of {{GamepadTouch}} objects generated from all touch
surfaces. If the device does not support touches, MUST be set to
`null`.
</p>
<p>
The {{Gamepad/touches}} getter steps are:
Expand Down Expand Up @@ -683,43 +683,35 @@ <h3>
steps:
</p>
<ol class="algorithm">
<li>Let |surfaceId:unsigned long| be 0.
</li>
<li>Remove any existing events from
<li>Remove any existing objects from
{{Gamepad}}.{{Gamepad/[[touches]]}}.
</li>
<li>Repeat the following steps for each touch surface on |gamepad| in
touch surface enumeration order:
<ol>
<li>Let |surfaceDimensions| be an `null`.
<li>Let |surfaceId:unsigned long| be the current surface
enumeration index.
</li>
<li>If the touch surface exposes maximum surface dimensions in
device units:
<ol>
<li>Set |touchEvent|.{{GamepadTouch/surfaceDimensions}}[0] to
the maximum X dimension on the touch surface in device units.
</li>
<li>Set |touchEvent|.{{GamepadTouch/surfaceDimensions}}[1] to
the maximum Y dimension on the touch surface in device units.
</li>
</ol>
device units, then set |touch|.{{GamepadTouch/surfaceDimensions}}
to a {{DOMRect}} with `width` and `height` initialized to the
maximum X and Y dimensions on the touch surface in device units.
</li>
<li>Repeat the following steps for each active touch point
reported by the |gamepad| for the current touch surface.
<ol>
<li>Let |nextTouchId:unsigned long| be the next available
touchId for the |gamepad|.
</li>
<li>Let |touchEvent:GamepadTouch| be a {{GamepadTouch}}.
<li>Let |touch:GamepadTouch| be a {{GamepadTouch}}.
</li>
<li>Set |touchEvent|.{{GamepadTouch/surfaceId}} to be
|surfaceId|.
<li>Set |touch|.{{GamepadTouch/surfaceId}} to be |surfaceId|.
</li>
<li>If the touch data is part of an existing active touch
point tracked by the user agent:
<ol>
<li>Set |touchEvent|.{{GamepadTouch/touchId}} to the
touchId of the active touch point.
<li>Set |touch|.{{GamepadTouch/touchId}} to the touchId
of the active touch point.
</li>
<li>Otherwise, set touchId to nextTouchId and increment
nextTouchId.
Expand All @@ -731,48 +723,28 @@ <h3>
</li>
</ol>
</li>
<li>Let |position| be a [=new=] {{Float32Array}} with length
2.
<li>Let |position| be a [=new=] {{DOMPoint}} with `x`
initialized to device X coordinate relative to the device
touch surface and normalized to [-1.0,1.0] where -1.0 is the
leftmost coordinate and 1.0 is the rightmost coordinate and
`y` initialized to the device touch surface and normalized to
[-1.0,1.0] where -1.0 is the leftmost coordinate and 1.0 is
the rightmost coordinate.
</li>
<li>
<p>
|position|[0] should be set to the device X coordinate
relative to the device touch surface and normalized to
[-1.0,1.0] where -1.0 is the leftmost coordinate and 1.0
is the rightmost coordinate.
</p>
<p class="note" title=
"Possible implementation (if surfaceDimensions are available)">
`position[0] = (2.0 * touchData.x / surfaceDimensions[0])
- 1`
</p>
</li>
<li>
<p>
|position|[1] should be set to the device Y coordinate
relative to the device touch surface and normalized to
[-1.0,1.0] where -1.0 is the topmost coordinate and 1.0
is the bottommost coordinate.
</p>
<p class="note" title=
"Possible implementation (if surfaceDimensions are available)">
`position[1] = (2.0 * touchData.y / surfaceDimensions[1])
- 1`
</p>
<p class="note" title=
"Possible implementation (if surfaceDimensions are available)">
`x = (2.0 * touchData.x / surfaceDimensions.width) - 1`
</p>
<p class="note" title=
"Possible implementation (if surfaceDimensions are available)">
`y = (2.0 * touchData.y / surfaceDimensions.height) - 1`
</p>
<li>Add |touch| to {{Gamepad}}.{{Gamepad/[[touches]]}}.
</li>
</ol>
</li>
<li>Set |touchEvent|.{{GamepadTouch/position}} to be
|position:Float32Array|.
</li>
<li>Add |touchEvent| to {{Gamepad}}.{{Gamepad/[[touches]]}}.
</li>
</ol>
</li>
<li>Increment |surfaceId|
</li>
<li>Increment |surfaceId|
</li>
</ol>
</section>
<section>
Expand Down Expand Up @@ -1214,18 +1186,19 @@ <h2>
<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
A {{DOMPoint}} which holds the x, y coordinates of the touch event.
The z and w value are currently unused. The 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.
references the bottommost coordinate.
</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.
A {{DOMRect}} initialized with the width and height of the touch
surface in integer units. If not available then <code>null</code>.
</dd>
</dl>
</section>
Expand Down

0 comments on commit 141c3a2

Please sign in to comment.