1#![no_std]
4
5#[macro_use]
6extern crate log;
7extern crate alloc;
8
9use alloc::vec::Vec;
10use core::mem;
11
12use ax_driver::{AxDeviceContainer, prelude::*};
13use ax_lazyinit::LazyInit;
14use ax_sync::Mutex;
15
16static DEVICES: LazyInit<Mutex<Vec<AxInputDevice>>> = LazyInit::new();
17
18pub fn init_input(mut input_devs: AxDeviceContainer<AxInputDevice>) {
20 info!("Initialize input subsystem...");
21
22 let mut devices = Vec::new();
23 while let Some(dev) = input_devs.take_one() {
24 info!(
25 " registered a new {:?} input device: {}",
26 dev.device_type(),
27 dev.device_name(),
28 );
29 devices.push(dev);
30 }
31 DEVICES.init_once(Mutex::new(devices));
32}
33
34pub fn take_inputs() -> Vec<AxInputDevice> {
36 mem::take(&mut DEVICES.lock())
37}