MCPcopy Create free account
hub / github.com/Starry-OS/StarryOS / new

Method new

api/src/vfs/dev/event.rs:59–93  ·  view source on GitHub ↗
(mut device: AxInputDevice)

Source from the content-addressed store, hash-verified

57
58impl EventDev {
59 pub fn new(mut device: AxInputDevice) -> Self {
60 let mut ev_bits = Bitmap::new();
61 for i in 0..EventType::COUNT {
62 let Some(ty) = EventType::from_repr(i) else {
63 continue;
64 };
65 if device
66 .get_event_bits(ty, &mut [])
67 .is_ok_and(|success| success)
68 {
69 ev_bits.set(i as usize, true);
70 }
71 }
72
73 // let mut out = [0u8; 2000];
74 // if device.get_event_bits(EventType::Absolute, &mut out).unwrap() {
75 // let mut bits = Vec::new();
76 // for i in 0..EventType::Absolute.bits_count() {
77 // if (out[i / 8] >> (i % 8)) & 1 != 0 {
78 // bits.push(i);
79 // }
80 // }
81 // warn!("{bits:?}");
82 // } else {
83 // warn!("failure");
84 // }
85 Self {
86 inner: Mutex::new(Inner {
87 device,
88 read_ahead: None,
89 key_state: Bitmap::new(),
90 }),
91 ev_bits,
92 }
93 }
94
95 fn get_event_bits(&self, arg: usize, size: usize, ty: u8) -> AxResult<usize> {
96 let bits = UserPtr::<u8>::from(arg).get_as_mut_slice(size)?;

Callers

nothing calls this directly

Calls 1

get_event_bitsMethod · 0.80

Tested by

no test coverage detected