mod rdevin;
pub use crate::rdevin::{
Button, DisplayError, Event, EventType, GrabError, Key, KeyCode, KeyboardState, RawKey,
SimulateError, UnicodeInfo,
};
pub mod keycodes;
#[cfg(target_os = "linux")]
pub mod linux;
#[cfg(target_os = "macos")]
pub mod macos;
#[cfg(target_os = "windows")]
pub mod windows;
pub mod codes_conv;
#[cfg(target_os = "macos")]
pub use crate::keycodes::macos::{code_from_key, key_from_code};
#[cfg(target_os = "macos")]
use crate::macos::{
display_size as _display_size, grab as _grab, listen as _listen, simulate as _simulate,
};
#[cfg(target_os = "macos")]
pub use crate::macos::{Keyboard, ListenError};
#[cfg(any(target_os = "android", target_os = "linux"))]
pub use crate::keycodes::linux::{code_from_key, key_from_code};
#[cfg(target_os = "linux")]
use crate::linux::{display_size as _display_size, listen as _listen, simulate as _simulate};
#[cfg(target_os = "linux")]
pub use crate::linux::{Keyboard, ListenError};
#[cfg(target_os = "windows")]
pub use crate::keycodes::windows::{code_from_key, key_from_code};
#[cfg(target_os = "windows")]
use crate::windows::{
display_size as _display_size, grab as _grab, listen as _listen, simulate as _simulate,
};
#[cfg(target_os = "windows")]
pub use crate::windows::{Keyboard, ListenError};
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn listen<T>(callback: T) -> Result<(), ListenError>
where
T: FnMut(Event) + 'static,
{
_listen(callback)
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn simulate(event_type: &EventType) -> Result<(), SimulateError> {
_simulate(event_type)
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn display_size() -> Result<(u64, u64), DisplayError> {
_display_size()
}
#[cfg(not(any(target_os = "android", target_os = "ios", target_os = "linux")))]
pub fn grab<T>(callback: T) -> Result<(), GrabError>
where
T: Fn(Event) -> Option<Event> + 'static,
{
_grab(callback)
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub(crate) fn keyboard_only() -> bool {
!std::env::var("KEYBOARD_ONLY")
.unwrap_or_default()
.is_empty()
}