#[cfg(all(feature = "kms", not(feature = "window")))]
pub mod alsa;
#[cfg(any(feature = "kms", feature = "window"))]
pub mod blit;
#[cfg(all(feature = "kms", not(feature = "window")))]
pub mod evdev;
#[cfg(all(feature = "kms", not(feature = "window")))]
pub mod kms;
pub mod null;
#[cfg(feature = "window")]
pub mod window;
use anyhow::Result;
use pixel8_runtime::fb::Framebuffer;
pub trait Platform {
fn present(&mut self, fb: &Framebuffer) -> Result<()>;
fn poll(&mut self) -> InputSnapshot;
}
#[derive(Clone, Copy, Default)]
pub struct InputSnapshot {
pub buttons: [bool; 6],
pub select: bool,
pub start: bool,
pub quit_requested: bool,
pub fps_toggle: bool,
}
#[cfg(any(feature = "kms", feature = "window"))]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum Rotate {
None,
Cw90,
Cw180,
Cw270,
}
#[cfg(any(feature = "kms", feature = "window"))]
impl Rotate {
pub fn from_env_or(default: Rotate) -> Rotate {
match std::env::var("PIXEL8_ROTATE").ok().as_deref() {
Some("0") => Rotate::None,
Some("90") => Rotate::Cw90,
Some("180") => Rotate::Cw180,
Some("270") => Rotate::Cw270,
_ => default,
}
}
}