diff options
Diffstat (limited to 'gpu_display')
-rw-r--r-- | gpu_display/src/event_device.rs | 16 | ||||
-rw-r--r-- | gpu_display/src/gpu_display_x.rs | 22 |
2 files changed, 21 insertions, 17 deletions
diff --git a/gpu_display/src/event_device.rs b/gpu_display/src/event_device.rs index 5f1bbc7..5aae55c 100644 --- a/gpu_display/src/event_device.rs +++ b/gpu_display/src/event_device.rs @@ -3,14 +3,14 @@ // found in the LICENSE file. use data_model::DataInit; -use linux_input_sys::input_event; +use linux_input_sys::{virtio_input_event, InputEventDecoder}; use std::collections::VecDeque; use std::io::{self, Error, ErrorKind, Read, Write}; use std::iter::ExactSizeIterator; use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::net::UnixStream; -const EVENT_SIZE: usize = input_event::EVENT_SIZE; +const EVENT_SIZE: usize = virtio_input_event::SIZE; const EVENT_BUFFER_LEN_MAX: usize = 16 * EVENT_SIZE; // /// Half-way build `EventDevice` with only the `event_socket` defined. Finish building the @@ -93,7 +93,7 @@ impl EventDevice { self.event_buffer.is_empty() } - pub fn send_report<E: IntoIterator<Item = input_event>>( + pub fn send_report<E: IntoIterator<Item = virtio_input_event>>( &mut self, events: E, ) -> io::Result<bool> @@ -111,14 +111,14 @@ impl EventDevice { } self.event_buffer - .extend(input_event::syn().as_slice().iter()); + .extend(virtio_input_event::syn().as_slice().iter()); self.flush_buffered_events() } /// Sends the given `event`, returning `Ok(true)` if, after this function returns, there are no /// buffered events remaining. - pub fn send_event_encoded(&mut self, event: input_event) -> io::Result<bool> { + pub fn send_event_encoded(&mut self, event: virtio_input_event) -> io::Result<bool> { if !self.flush_buffered_events()? { return Ok(false); } @@ -137,14 +137,14 @@ impl EventDevice { Ok(false) } - pub fn recv_event_encoded(&self) -> io::Result<input_event> { + pub fn recv_event_encoded(&self) -> io::Result<virtio_input_event> { let mut event_bytes = [0u8; 24]; (&self.event_socket).read_exact(&mut event_bytes)?; - match input_event::from_slice(&event_bytes) { + match virtio_input_event::from_slice(&event_bytes) { Some(event) => Ok(*event), None => Err(Error::new( ErrorKind::InvalidInput, - "failed to read input_event", + "failed to read virtio_input_event", )), } } diff --git a/gpu_display/src/gpu_display_x.rs b/gpu_display/src/gpu_display_x.rs index c0074ca..2940f40 100644 --- a/gpu_display/src/gpu_display_x.rs +++ b/gpu_display/src/gpu_display_x.rs @@ -11,7 +11,7 @@ )] mod xlib; -use linux_input_sys::input_event; +use linux_input_sys::virtio_input_event; use std::cmp::max; use std::collections::BTreeMap; use std::ffi::{c_void, CStr, CString}; @@ -333,7 +333,11 @@ impl Surface { } } - fn dispatch_to_event_devices(&mut self, events: &[input_event], device_type: EventDeviceKind) { + fn dispatch_to_event_devices( + &mut self, + events: &[virtio_input_event], + device_type: EventDeviceKind, + ) { for event_device in self.event_devices.values_mut() { if event_device.kind() != device_type { continue; @@ -348,7 +352,7 @@ impl Surface { match ev.as_enum(self.buffer_completion_type) { XEventEnum::KeyEvent(key) => { if let Some(linux_keycode) = self.keycode_translator.translate(key.keycode) { - let events = &[input_event::key( + let events = &[virtio_input_event::key( linux_keycode, key.type_ == xlib::KeyPress as i32, )]; @@ -363,9 +367,9 @@ impl Surface { if button_event.button & xlib::Button1 != 0 { // The touch event *must* be first per the Linux input subsystem's guidance. let events = &[ - input_event::touch(pressed), - input_event::absolute_x(max(0, button_event.x) as u32), - input_event::absolute_y(max(0, button_event.y) as u32), + virtio_input_event::touch(pressed), + virtio_input_event::absolute_x(max(0, button_event.x) as u32), + virtio_input_event::absolute_y(max(0, button_event.y) as u32), ]; self.dispatch_to_event_devices(events, EventDeviceKind::Touchscreen); } @@ -373,9 +377,9 @@ impl Surface { XEventEnum::Motion(motion) => { if motion.state & xlib::Button1Mask != 0 { let events = &[ - input_event::touch(true), - input_event::absolute_x(max(0, motion.x) as u32), - input_event::absolute_y(max(0, motion.y) as u32), + virtio_input_event::touch(true), + virtio_input_event::absolute_x(max(0, motion.x) as u32), + virtio_input_event::absolute_y(max(0, motion.y) as u32), ]; self.dispatch_to_event_devices(events, EventDeviceKind::Touchscreen); } |