gcrecomp_runtime/input/backends/
mod.rs1pub mod gilrs;
2pub mod sdl2;
3#[cfg(target_os = "windows")]
4pub mod xinput;
5
6use anyhow::Result;
7
8pub trait Backend {
11 fn update(&mut self) -> Result<()>;
12 fn enumerate_controllers(&mut self) -> Result<Vec<ControllerInfo>>;
13 fn get_input(&self, controller_id: usize) -> Result<RawInput>;
14}
15
16#[derive(Debug, Clone)]
17pub struct ControllerInfo {
18 pub id: usize,
19 pub name: String,
20 pub controller_type: ControllerType,
21 pub button_count: usize,
22 pub axis_count: usize,
23}
24
25#[derive(Debug, Clone, PartialEq, Eq)]
26pub enum ControllerType {
27 Xbox,
28 PlayStation,
29 SwitchPro,
30 Generic,
31 Keyboard,
32}
33
34#[derive(Debug, Clone)]
35pub struct RawInput {
36 pub buttons: Vec<bool>,
37 pub axes: Vec<f32>,
38 pub triggers: Vec<f32>,
39 pub hat: Option<HatState>,
40}
41
42#[derive(Debug, Clone)]
43pub struct HatState {
44 pub up: bool,
45 pub down: bool,
46 pub left: bool,
47 pub right: bool,
48}