oxygengine_input/
system.rs

1use crate::{
2    component::InputStackInstance,
3    resources::{controller::InputController, stack::InputStack},
4};
5use core::ecs::{life_cycle::EntityChanges, Comp, Universe, WorldRef};
6
7pub type InputSystemResources<'a> = (
8    WorldRef,
9    &'a mut InputController,
10    &'a mut InputStack,
11    &'a EntityChanges,
12    Comp<&'a mut InputStackInstance>,
13);
14
15pub fn input_system(universe: &mut Universe) {
16    let (world, mut controller, mut stack, entity_changes, ..) =
17        universe.query_resources::<InputSystemResources>();
18
19    for (entity, instance) in world.query::<&mut InputStackInstance>().iter() {
20        if let InputStackInstance::Setup(listener) = &instance {
21            let mut listener = listener.to_owned();
22            listener.bound_entity = Some(entity);
23            *instance = InputStackInstance::Listener(stack.register(listener));
24        }
25    }
26
27    controller.process(universe);
28    stack.process(&controller, &entity_changes);
29}