From 1836ac3c6b2abd5dce487f1d7589cfe7466c0fd2 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Fri, 19 Sep 2025 12:02:54 +1200 Subject: Gate gamepad support behind a feature flag This is to make it possible to compile bedrock-pc without gamepad support, which is useful when the target platform doesn't have the libraries for udev (required by the gilrs dependency). This commit is a bit of a hack, it'd be nice to implement this better some day. --- src/types/controller.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/types/controller.rs') diff --git a/src/types/controller.rs b/src/types/controller.rs index 76b77e3..42d3f8c 100644 --- a/src/types/controller.rs +++ b/src/types/controller.rs @@ -1,11 +1,15 @@ use crate::*; +#[cfg(feature = "gamepad")] pub use gilrs::{Gilrs, GamepadId}; pub struct OwnedGamepad { tag: usize, + #[cfg(feature = "gamepad")] id: Option, + #[cfg(not(feature = "gamepad"))] + id: Option<()>, gamepad: Gamepad, } @@ -15,6 +19,7 @@ impl OwnedGamepad { } /// Returns Some if the ID owns this gamepad. + #[cfg(feature = "gamepad")] pub fn register(&mut self, new_id: GamepadId) -> Option<&mut Gamepad> { if let Some(id) = self.id { match id == new_id { @@ -102,6 +107,7 @@ impl Gamepad { } // Returns true if the state changed. + #[cfg(feature = "gamepad")] pub fn process_event(&mut self, event: &gilrs::Event) -> bool { macro_rules! schmitt { ($name_neg:ident, $name_pos:ident, $v:expr) => {{ -- cgit v1.2.3-70-g09d2