gilrs-core 0.6.8

Minimal event-based abstraction for working with gamepads
Documentation
use std::time::SystemTime;

/// Returns true if nth bit in array is 1.
#[allow(dead_code)]
pub(crate) fn test_bit(n: u16, array: &[u8]) -> bool {
    (array[(n / 8) as usize] >> (n % 8)) & 1 != 0
}

#[cfg(not(target_arch = "wasm32"))]
pub fn time_now() -> SystemTime {
    SystemTime::now()
}

#[cfg(target_arch = "wasm32")]
pub fn time_now() -> SystemTime {
    use js_sys::Date;
    use std::time::Duration;

    let offset = Duration::from_millis(Date::now() as u64);
    SystemTime::UNIX_EPOCH + offset
}