diff options
author | Ben Bridle <ben@derelict.engineering> | 2025-09-19 12:02:54 +1200 |
---|---|---|
committer | Ben Bridle <ben@derelict.engineering> | 2025-09-19 12:05:46 +1200 |
commit | 1836ac3c6b2abd5dce487f1d7589cfe7466c0fd2 (patch) | |
tree | d1e34ba91f7ecef855dc9652ca2063ac33dabf6c /src/emulators | |
parent | 661b4012654c8b41a782adf6a5cc1092b8942803 (diff) | |
download | bedrock-pc-1836ac3c6b2abd5dce487f1d7589cfe7466c0fd2.zip |
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.
Diffstat (limited to 'src/emulators')
-rw-r--r-- | src/emulators/graphical_emulator.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/emulators/graphical_emulator.rs b/src/emulators/graphical_emulator.rs index 3d7ea4a..503a8f4 100644 --- a/src/emulators/graphical_emulator.rs +++ b/src/emulators/graphical_emulator.rs @@ -1,11 +1,9 @@ use crate::*; -use gilrs::Gilrs; - - pub struct GraphicalEmulator { pub br: BedrockEmulator<GraphicalDeviceBus>, pub debug: DebugState, + #[cfg(feature = "gamepad")] pub gilrs: Option<Gilrs>, pub fullscreen: bool, @@ -19,18 +17,18 @@ pub struct GraphicalEmulator { impl GraphicalEmulator { pub fn new(config: EmulatorConfig, debug: bool) -> Self { - let gilrs = match Gilrs::new() { - Ok(gilrs) => Some(gilrs), - Err(err) => { - info!("Could not start gamepad listener: {}", err); - None - } - }; - Self { br: BedrockEmulator::new(GraphicalDeviceBus::new(&config)), debug: DebugState::new(debug, config.symbols_path.as_ref()), - gilrs, + + #[cfg(feature = "gamepad")] + gilrs: match Gilrs::new() { + Ok(gilrs) => Some(gilrs), + Err(err) => { + info!("Could not start gamepad listener: {}", err); + None + } + }, fullscreen: config.fullscreen, scale: config.zoom.into(), @@ -205,6 +203,8 @@ impl WindowProgram for GraphicalEmulator { fn process(&mut self, requests: &mut EventWriter<Request>) { self.br.dev.stream.flush(); + + #[cfg(feature = "gamepad")] if let Some(gilrs) = &mut self.gilrs { while let Some(event) = gilrs.next_event() { self.br.dev.input.on_gamepad_event(event); |