Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 4x 14x 4x 4x 10x | import { XrInputSource } from 'playcanvas';
/**
* Latches per input source whether a press may count toward a hold. A source arms itself the
* moment it is seen released, and stays armed from then on - so a button already down when
* tracking starts is ignored until it is released once, and one controller held down can't stop
* another from arming and counting. Callers must poll every frame for every source they care
* about; a press and release between polls is missed.
*/
export class ButtonArmingLatch {
private _armed = new WeakSet<XrInputSource>();
/** Records one frame for `inputSource` and returns whether its current press may count. */
trackPress(inputSource: XrInputSource, pressed: boolean): boolean {
if (!pressed) {
this._armed.add(inputSource);
return false;
}
return this._armed.has(inputSource);
}
}
|