#![allow(unsafe_code)]
use crate::{Event, Remap};
use std::task::{Context, Poll};
#[cfg_attr(
any(target_arch = "wasm32", target_arch = "asmjs"),
cfg_attr(target_os = "wasi", path = "raw/wasi.rs"),
cfg_attr(target_os = "ardaku", path = "raw/ardaku.rs"),
cfg_attr(
any(target_os = "unknown", target_os = "emscripten"),
path = "raw/dom.rs"
)
)]
#[cfg_attr(
not(any(target_arch = "wasm32", target_arch = "asmjs")),
cfg_attr(target_os = "linux", path = "raw/linux.rs"),
cfg_attr(target_os = "android", path = "raw/android.rs"),
cfg_attr(target_os = "macos", path = "raw/macos.rs"),
cfg_attr(target_os = "ios", path = "raw/ios.rs"),
cfg_attr(target_os = "windows", path = "raw/windows.rs"),
cfg_attr(target_os = "fuchsia", path = "raw/fuchsia.rs"),
cfg_attr(target_os = "redox", path = "raw/redox.rs"),
cfg_attr(
any(
target_os = "freebsd",
target_os = "dragonfly",
target_os = "bitrig",
target_os = "openbsd",
target_os = "netbsd"
),
path = "raw/bsd.rs",
)
)]
mod ffi;
struct FakeGlobal;
impl Global for FakeGlobal {}
struct FakeListener;
impl Listener for FakeListener {
fn poll(&mut self, _cx: &mut Context<'_>) -> Poll<crate::Controller> {
Poll::Pending
}
}
pub(crate) trait Listener: Send {
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<crate::Controller>;
}
pub(crate) trait Controller: Send {
fn id(&self) -> u64 {
0
}
fn poll(&mut self, _cx: &mut Context<'_>) -> Poll<Event> {
Poll::Pending
}
fn rumble(&mut self, _left: f32, _right: f32) {}
fn name(&self) -> &str {
"Unknown"
}
fn pressure(&self, input: f64) -> f64 {
input
}
fn axis(&self, input: f64) -> f64 {
input
}
}
pub(crate) trait Global: std::any::Any {
fn enable(&self) {}
fn disable(&self) {}
fn listener(&self, _remap: Remap) -> Box<dyn Listener> {
Box::new(FakeListener)
}
}
thread_local! {
pub(crate) static GLOBAL: Box<dyn Global> = ffi::global();
}