|
1 | 1 | import { DOUBLE_TAP_THRESHOLD, DOUBLE_TAP_VARIANCE } from '../constants.js'; |
2 | 2 | import { InputSource } from '../input.js'; |
| 3 | +import { movementState } from '../utils.js'; |
3 | 4 | import { VirtualJoystick } from './virtual-joystick.js'; |
4 | 5 |
|
5 | 6 | /** |
@@ -29,6 +30,12 @@ const endsWith = (str, suffix) => str.indexOf(suffix, str.length - suffix.length |
29 | 30 | * @augments {InputSource<DualGestureSourceDeltas>} |
30 | 31 | */ |
31 | 32 | class DualGestureSource extends InputSource { |
| 33 | + /** |
| 34 | + * @type {ReturnType<typeof movementState>} |
| 35 | + * @private |
| 36 | + */ |
| 37 | + _movementState = movementState(); |
| 38 | + |
32 | 39 | /** |
33 | 40 | * @type {`${'joystick' | 'touch'}-${'joystick' | 'touch'}`} |
34 | 41 | * @private |
@@ -116,6 +123,7 @@ class DualGestureSource extends InputSource { |
116 | 123 | */ |
117 | 124 | _onPointerDown(event) { |
118 | 125 | const { pointerType, pointerId, clientX, clientY } = event; |
| 126 | + this._movementState.down(event); |
119 | 127 |
|
120 | 128 | if (pointerType !== 'touch') { |
121 | 129 | return; |
@@ -151,7 +159,8 @@ class DualGestureSource extends InputSource { |
151 | 159 | * @private |
152 | 160 | */ |
153 | 161 | _onPointerMove(event) { |
154 | | - const { pointerType, pointerId, target, clientX, clientY, movementX, movementY } = event; |
| 162 | + const { pointerType, pointerId, target, clientX, clientY } = event; |
| 163 | + const [movementX, movementY] = this._movementState.move(event); |
155 | 164 |
|
156 | 165 | if (pointerType !== 'touch') { |
157 | 166 | return; |
@@ -188,6 +197,7 @@ class DualGestureSource extends InputSource { |
188 | 197 | */ |
189 | 198 | _onPointerUp(event) { |
190 | 199 | const { pointerType, pointerId } = event; |
| 200 | + this._movementState.up(event); |
191 | 201 |
|
192 | 202 | if (pointerType !== 'touch') { |
193 | 203 | return; |
|
0 commit comments