Skip to content

Commit b7d3158

Browse files
robtfmleanmendoza
andauthored
multi-button ui (#1081)
* multi-button ui * fix callback type * partial * lint * leave public Callback type unchanged, make new MultiCallback type * lint + doc * add event arg to single callback * onInputXXX * forgot about iaAny * fix ternary precedence * fix comparison * use correct event ordering for getInputCommands() * fix button cast * fix doc comments * lints * build... * rest of the lints * fix tests * fix lint * fix initial empty pointerEvents * update snapshot --------- Co-authored-by: Lean Mendoza <8042536+leanmendoza@users.noreply.github.com>
1 parent a99dfdf commit b7d3158

13 files changed

Lines changed: 436 additions & 216 deletions

File tree

packages/@dcl/ecs/src/engine/input.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ export type IInputSystem = {
8282
pointerEventType: PointerEventType,
8383
entity?: Entity
8484
) => PBPointerEventsResult | null
85+
86+
/**
87+
* @public
88+
* Get an ordered iterator over events received within the current frame.
89+
* @returns the iterator
90+
*/
91+
getInputCommands: () => Generator<PBPointerEventsResult>
8592
}
8693

8794
const InputStateUpdateSystemPriority = 1 << 20
@@ -294,11 +301,18 @@ export function createInputSystem(engine: IEngine): IInputSystem {
294301
return globalState.buttonState.get(inputAction)?.state === PointerEventType.PET_DOWN
295302
}
296303

304+
function* getInputCommands() {
305+
for (let i = globalState.thisFrameCommands.length - 1; i >= 0; i--) {
306+
yield globalState.thisFrameCommands[i]
307+
}
308+
}
309+
297310
return {
298311
isPressed,
299312
getClick,
300313
getInputCommand,
301314
isClicked,
302-
isTriggered
315+
isTriggered,
316+
getInputCommands
303317
}
304318
}

0 commit comments

Comments
 (0)