Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions framework_crates/bones_framework/src/input.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//! Input resources.

use bones_lib::ecs::World;
use bones_schema::HasSchema;

use self::prelude::{GamepadInputs, KeyboardInputs, MouseInputs};

pub mod gamepad;
pub mod gilrs;
pub mod keyboard;
Expand Down Expand Up @@ -49,13 +48,7 @@ pub trait InputCollector<'a, ControlMapping: HasSchema, ControlSource, Control>:
/// Update the internal state with new inputs. This must be called every render frame with the
/// input events. This updates which buttons are pressed, but does not compute what buttons were "just_pressed".
/// use [`InputCollector::update_just_pressed`] to do this.
fn apply_inputs(
&mut self,
mapping: &ControlMapping,
mouse: &MouseInputs,
keyboard: &KeyboardInputs,
gamepad: &GamepadInputs,
);
fn apply_inputs(&mut self, world: &World);

/// Indicate input for this frame has been consumed. An implementation of [`InputCollector`] that is
/// used with a fixed simulation step may track what keys are currently pressed, and what keys were "just pressed",
Expand Down
16 changes: 1 addition & 15 deletions framework_crates/bones_framework/src/networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,6 @@ where
}
}

/// Helper for accessing nested associated types on [`NetworkInputConfig`].
#[allow(type_alias_bounds)]
type ControlMapping<'a, C: NetworkInputConfig<'a>> =
<C::PlayerControls as PlayerControls<'a, C::Control>>::ControlMapping;

impl<InputTypes> SessionRunner for GgrsSessionRunner<'static, InputTypes>
where
InputTypes: NetworkInputConfig<'static> + 'static,
Expand All @@ -724,19 +719,10 @@ where
let mut skip_frames: u32 = 0;

{
let mouse = world.resource::<MouseInputs>();
let keyboard = world.resource::<KeyboardInputs>();
let gamepad = world.resource::<GamepadInputs>();

let player_inputs = world.resource::<InputTypes::PlayerControls>();

// Collect inputs and update controls
self.input_collector.apply_inputs(
&world.resource::<ControlMapping<InputTypes>>(),
&mouse,
&keyboard,
&gamepad,
);
self.input_collector.apply_inputs(world);
self.input_collector.update_just_pressed();

// save local players dense input for use with ggrs
Expand Down