From 99d3f08dc5d4ad63d8596c349f9d207144e2c949 Mon Sep 17 00:00:00 2001 From: "Jorge E. Moreira" Date: Thu, 7 Mar 2019 10:59:54 -0800 Subject: Add a (single touch only) touch screen input device Very similar to the trackpad device, it has the INPUT_PROP_DIRECT property and does not support any buttons, just touch events. Change-Id: I2c963013e402ff2aa1b4b529c6c494dd57f4add9 Reviewed-on: https://chromium-review.googlesource.com/1509697 Commit-Ready: Jorge Moreira Broche Tested-by: kokoro Reviewed-by: Dylan Reid Reviewed-by: Daniel Verkamp --- src/linux.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/linux.rs') diff --git a/src/linux.rs b/src/linux.rs index 6398270..acea1de 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -44,7 +44,7 @@ use sys_util::{ use vhost; use vm_control::{VmRequest, VmResponse, VmRunMode}; -use crate::{Config, DiskOption, TrackpadOption}; +use crate::{Config, DiskOption, TouchDeviceOption}; use arch::{self, LinuxArch, RunnableLinuxVm, VirtioDeviceStub, VmComponents}; @@ -358,7 +358,21 @@ fn create_tpm_device(cfg: &Config) -> DeviceResult { }) } -fn create_trackpad_device(cfg: &Config, trackpad_spec: &TrackpadOption) -> DeviceResult { +fn create_single_touch_device(cfg: &Config, single_touch_spec: &TouchDeviceOption) -> DeviceResult { + let socket = create_input_socket(&single_touch_spec.path).map_err(|e| { + error!("failed configuring virtio single touch: {:?}", e); + e + })?; + + let dev = virtio::new_single_touch(socket, single_touch_spec.width, single_touch_spec.height) + .map_err(Error::InputDeviceNew)?; + Ok(VirtioDeviceStub { + dev: Box::new(dev), + jail: simple_jail(&cfg, "input_device.policy")?, + }) +} + +fn create_trackpad_device(cfg: &Config, trackpad_spec: &TouchDeviceOption) -> DeviceResult { let socket = create_input_socket(&trackpad_spec.path).map_err(|e| { error!("failed configuring virtio trackpad: {}", e); e @@ -651,6 +665,10 @@ fn create_virtio_devices( } } + if let Some(single_touch_spec) = &cfg.virtio_single_touch { + devs.push(create_single_touch_device(cfg, single_touch_spec)?); + } + if let Some(trackpad_spec) = &cfg.virtio_trackpad { devs.push(create_trackpad_device(cfg, trackpad_spec)?); } -- cgit 1.4.1