From 69c695dcc875e070e7a2a5263328f2752ec3cd1c Mon Sep 17 00:00:00 2001 From: RockasMockas <6405564+RockasMockas@users.noreply.github.com> Date: Sun, 6 Oct 2024 19:16:10 +0200 Subject: [PATCH] Docs + fixed dep --- framework_crates/bones_bevy_renderer/src/input.rs | 2 -- framework_crates/bones_framework/Cargo.toml | 2 +- framework_crates/bones_framework/src/input/gilrs.rs | 4 +++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/framework_crates/bones_bevy_renderer/src/input.rs b/framework_crates/bones_bevy_renderer/src/input.rs index 014b63edda..77b28b1e59 100644 --- a/framework_crates/bones_bevy_renderer/src/input.rs +++ b/framework_crates/bones_bevy_renderer/src/input.rs @@ -1,5 +1,3 @@ -// framework_crates/bones_bevy_renderer/src/input.rs - use super::*; use bevy::{ input::{ diff --git a/framework_crates/bones_framework/Cargo.toml b/framework_crates/bones_framework/Cargo.toml index 50e69d3865..9bf487bea5 100644 --- a/framework_crates/bones_framework/Cargo.toml +++ b/framework_crates/bones_framework/Cargo.toml @@ -101,6 +101,7 @@ instant = { version = "0.1", features = ["wasm-bindgen"] } noise = "0.9" once_cell = "1.17" thiserror = "1.0" +gilrs = "0.11.0" # Tracing tracing = "0.1" @@ -154,7 +155,6 @@ iroh-quinn = "0.10" iroh-net = "0.22" tokio = { version = "1", features = ["rt-multi-thread", "macros"] } turborand = { version = "0.10.0", features = ["atomic"] } -gilrs = "0.11.0" directories = "5.0" diff --git a/framework_crates/bones_framework/src/input/gilrs.rs b/framework_crates/bones_framework/src/input/gilrs.rs index b230770ae2..d1278172dc 100644 --- a/framework_crates/bones_framework/src/input/gilrs.rs +++ b/framework_crates/bones_framework/src/input/gilrs.rs @@ -1,4 +1,3 @@ -// framework_crates/bones_framework/src/input/gilrs.rs use crate::prelude::*; use gilrs::{ev::filter::axis_dpad_to_button, EventType, Filter, Gilrs as GilrsContext}; use once_cell::sync::Lazy; @@ -11,6 +10,7 @@ static GILRS_CONTEXT: Lazy>> = Lazy::new(|| { )) }); +/// Processes gilrs gamepad events into Bones-native GamepadInputs pub fn process_gamepad_events() -> GamepadInputs { let mut gamepad_inputs = GamepadInputs::default(); let mut gilrs = GILRS_CONTEXT.lock().unwrap(); @@ -67,6 +67,7 @@ pub fn process_gamepad_events() -> GamepadInputs { gamepad_inputs } +/// Converts a gilrs button to a bones-native button fn convert_button(button: gilrs::Button) -> Option { match button { gilrs::Button::South => Some(GamepadButton::South), @@ -92,6 +93,7 @@ fn convert_button(button: gilrs::Button) -> Option { } } +/// Converts a gilrs axis to a bones-native axis fn convert_axis(axis: gilrs::Axis) -> Option { match axis { gilrs::Axis::LeftStickX => Some(GamepadAxis::LeftStickX),