Skip to content

Commit 8714702

Browse files
zicklagTekhnaeRaav
andauthored
feat!: give InputCollector access to World. (#508)
This makes it easier to get access to other resources that could, for instance, represent UI input. By @TekhnaeRaav. --------- Co-authored-by: Tekhnae Raav <[email protected]>
1 parent 7c15ce8 commit 8714702

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

framework_crates/bones_framework/src/input.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
//! Input resources.
22
3+
use bones_lib::ecs::World;
34
use bones_schema::HasSchema;
45

5-
use self::prelude::{GamepadInputs, KeyboardInputs, MouseInputs};
6-
76
pub mod gamepad;
87
pub mod gilrs;
98
pub mod keyboard;
@@ -49,13 +48,7 @@ pub trait InputCollector<'a, ControlMapping: HasSchema, ControlSource, Control>:
4948
/// Update the internal state with new inputs. This must be called every render frame with the
5049
/// input events. This updates which buttons are pressed, but does not compute what buttons were "just_pressed".
5150
/// use [`InputCollector::update_just_pressed`] to do this.
52-
fn apply_inputs(
53-
&mut self,
54-
mapping: &ControlMapping,
55-
mouse: &MouseInputs,
56-
keyboard: &KeyboardInputs,
57-
gamepad: &GamepadInputs,
58-
);
51+
fn apply_inputs(&mut self, world: &World);
5952

6053
/// Indicate input for this frame has been consumed. An implementation of [`InputCollector`] that is
6154
/// used with a fixed simulation step may track what keys are currently pressed, and what keys were "just pressed",

framework_crates/bones_framework/src/networking.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -705,11 +705,6 @@ where
705705
}
706706
}
707707

708-
/// Helper for accessing nested associated types on [`NetworkInputConfig`].
709-
#[allow(type_alias_bounds)]
710-
type ControlMapping<'a, C: NetworkInputConfig<'a>> =
711-
<C::PlayerControls as PlayerControls<'a, C::Control>>::ControlMapping;
712-
713708
impl<InputTypes> SessionRunner for GgrsSessionRunner<'static, InputTypes>
714709
where
715710
InputTypes: NetworkInputConfig<'static> + 'static,
@@ -724,19 +719,10 @@ where
724719
let mut skip_frames: u32 = 0;
725720

726721
{
727-
let mouse = world.resource::<MouseInputs>();
728-
let keyboard = world.resource::<KeyboardInputs>();
729-
let gamepad = world.resource::<GamepadInputs>();
730-
731722
let player_inputs = world.resource::<InputTypes::PlayerControls>();
732723

733724
// Collect inputs and update controls
734-
self.input_collector.apply_inputs(
735-
&world.resource::<ControlMapping<InputTypes>>(),
736-
&mouse,
737-
&keyboard,
738-
&gamepad,
739-
);
725+
self.input_collector.apply_inputs(world);
740726
self.input_collector.update_just_pressed();
741727

742728
// save local players dense input for use with ggrs

0 commit comments

Comments
 (0)